chore: fixing the eslint rule

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-02-17 09:21:34 +01:00
parent 8ae65a0bc1
commit a3576a386e
3 changed files with 20 additions and 5 deletions
@@ -34,6 +34,7 @@ const getPackages = require('./getPackages');
* @property {'value' | 'type'} kind
* @property {string} path
* @property {import('./getPackages').ExtendedPackage} package
* @property {string} packageName
*/
/**
@@ -160,6 +161,7 @@ module.exports = function visitImports(context, visitor) {
kind: info.kind,
path: subPath,
package: pkg,
packageName,
});
}
@@ -151,11 +151,13 @@ module.exports = {
}
return visitImports(context, (node, imp) => {
if (imp.type !== 'external') {
return;
}
// We leave checking of type imports to the repo-tools check
if (imp.kind === 'type') {
// We leave checking of type imports to the repo-tools check,
// and we skip builtins and local imports
if (
imp.kind === 'type' ||
imp.type === 'builtin' ||
imp.type === 'local'
) {
return;
}
@@ -236,5 +236,16 @@ ruleTester.run(RULE, rule, {
),
],
},
{
code: `import '@internal/foo'`,
filename: joinPath(FIXTURE, 'packages/bar/src/index.ts'),
errors: [
ERR_UNDECLARED(
'@internal/foo',
'dependencies',
joinPath('packages', 'bar'),
),
],
},
],
});