Skip to content

Commit

Permalink
Merge remote-tracking branch 'spalger/fix/scoped-no-internal' (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Sep 26, 2016
2 parents 29e1874 + b8663fd commit bd35156
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- `imports-first` is renamed to [`first`]. `imports-first` alias will continue to
exist, but may be removed in a future major release.

### Fixed
- [`no-internal-modules`]: support `@`-scoped packages ([#577]+[#578], thanks [@spalger])

## [1.16.0] - 2016-09-22
### Added
- Added [`no-dynamic-require`] rule: forbid `require()` calls with expressions. ([#567], [#568])
Expand Down Expand Up @@ -336,6 +339,7 @@ for info on changes for earlier releases.
[`no-webpack-loader-syntax`]: ./docs/rules/no-webpack-loader-syntax.md

[#586]: https://github.com/benmosher/eslint-plugin-import/pull/586
[#578]: https://github.com/benmosher/eslint-plugin-import/pull/578
[#568]: https://github.com/benmosher/eslint-plugin-import/pull/568
[#555]: https://github.com/benmosher/eslint-plugin-import/pull/555
[#538]: https://github.com/benmosher/eslint-plugin-import/pull/538
Expand Down Expand Up @@ -382,6 +386,7 @@ for info on changes for earlier releases.
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314

[#577]: https://github.com/benmosher/eslint-plugin-import/issues/577
[#570]: https://github.com/benmosher/eslint-plugin-import/issues/570
[#567]: https://github.com/benmosher/eslint-plugin-import/issues/567
[#566]: https://github.com/benmosher/eslint-plugin-import/issues/566
Expand Down
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 bd35156

Please sign in to comment.