Skip to content

Commit

Permalink
[no-internal-modules] allow importing @-scoped modules
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Sep 24, 2016
1 parent e3c41ca commit b8663fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rules/no-internal-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ module.exports = {
}
}, [])

if (steps.length <= 1) return false
const nonScopeSteps = steps.filter(step => step.indexOf('@') !== 0)
if (nonScopeSteps.length <= 1) return false

// before trying to resolve, see if the raw import (with relative
// segments resolved) matches an allowed pattern
Expand Down
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions tests/src/rules/no-internal-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ruleTester.run('no-internal-modules', rule, {
code: 'import get from "lodash.get"',
filename: testFilePath('./internal-modules/plugins/plugin2/index.js'),
}),
test({
code: 'import b from "@org/package"',
filename: testFilePath('./internal-modules/plugins/plugin2/internal.js'),
}),
test({
code: 'import b from "../../api/service"',
filename: testFilePath('./internal-modules/plugins/plugin2/internal.js'),
Expand Down Expand Up @@ -100,6 +104,17 @@ ruleTester.run('no-internal-modules', rule, {
},
],
}),
test({
code: 'import b from "@org/package/internal"',
filename: testFilePath('./internal-modules/plugins/plugin2/internal.js'),
errors: [
{
message: 'Reaching to "@org/package/internal" is not allowed.',
line: 1,
column: 15,
},
],
}),
test({
code: 'import get from "debug/node"',
filename: testFilePath('./internal-modules/plugins/plugin.js'),
Expand Down

0 comments on commit b8663fd

Please sign in to comment.