Skip to content

Commit 94b4006

Browse files
committed
Allow importing from current package
1 parent 6869b41 commit 94b4006

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rules/no-cross-imports.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ module.exports.create = context => {
4141

4242
return getImport(context, ({ node, value, path }) => {
4343
forbidden.forEach(({ name, location }) => {
44-
if (isSubPath(name, value) || isSubPath(location, path)) {
44+
if (
45+
!isSubPath(location, context.getFilename()) &&
46+
(isSubPath(name, value) || isSubPath(location, path))
47+
) {
4548
context.report({
4649
node,
4750
message: 'Import from package "{{name}}" is not allowed',

tests/rules/no-cross-imports.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ ruleTester.run('no-cross-imports', rule, {
2121
filename: '/some/path',
2222
code: "import '@test/workspace';import '@test/another-workspace';",
2323
},
24+
{
25+
filename: '/test/workspace',
26+
code: "import '@test/workspace';",
27+
},
28+
{
29+
filename: '/test/workspace',
30+
code: "import './some/thing'",
31+
},
2432
],
2533

2634
invalid: [

0 commit comments

Comments
 (0)