Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase of PR #794 (fixes #793) #907

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

## [Unreleased]

### Fixed
- [`order`]: Fix interpreting some external modules being interpreted as internal modules ([#793], [#794] thanks [@ephys])

## [2.7.0] - 2017-07-06
### Changed
Expand Down Expand Up @@ -418,9 +420,9 @@ for info on changes for earlier releases.
[`no-unassigned-import`]: ./docs/rules/no-unassigned-import.md
[`unambiguous`]: ./docs/rules/unambiguous.md
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md

[`memo-parser`]: ./memo-parser/README.md

[#794]: https://github.com/benmosher/eslint-plugin-import/pull/794
[#843]: https://github.com/benmosher/eslint-plugin-import/pull/843
[#871]: https://github.com/benmosher/eslint-plugin-import/pull/871
[#742]: https://github.com/benmosher/eslint-plugin-import/pull/742
Expand Down Expand Up @@ -482,6 +484,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

[#793]: https://github.com/benmosher/eslint-plugin-import/issues/793
[#863]: https://github.com/benmosher/eslint-plugin-import/issues/863
[#839]: https://github.com/benmosher/eslint-plugin-import/issues/839
[#686]: https://github.com/benmosher/eslint-plugin-import/issues/686
Expand Down Expand Up @@ -633,3 +636,4 @@ for info on changes for earlier releases.
[@eelyafi]: https://github.com/eelyafi
[@mastilver]: https://github.com/mastilver
[@jseminck]: https://github.com/jseminck
[@ephys]: https://github.com/ephys
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"eslint-import-resolver-node": "file:./resolvers/node",
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"eslint-module-utils": "file:./utils",
"eslint-import-test-order-redirect": "file:./tests/files/order-redirect",
"eslint-plugin-import": "2.x",
"gulp": "^3.9.0",
"gulp-babel": "6.1.2",
Expand Down
6 changes: 5 additions & 1 deletion src/core/importType.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export function isBuiltIn(name, settings) {

function isExternalPath(path, name, settings) {
const folders = (settings && settings['import/external-module-folders']) || ['node_modules']
return !path || folders.some(folder => -1 < path.indexOf(join(folder, name)))

// extract the part before the first / (redux-saga/effects => redux-saga)
const packageName = name.match(/([^/]+)/)[0]

return !path || folders.some(folder => -1 < path.indexOf(join(folder, packageName)))
}

const externalModuleRegExp = /^\w/
Expand Down
5 changes: 5 additions & 0 deletions tests/files/order-redirect/module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "order-redirect-module",
"private": true,
"main": "../other-module/file.js"
}
Empty file.
5 changes: 5 additions & 0 deletions tests/files/order-redirect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "eslint-import-test-order-redirect",
"version": "1.0.0",
"private": true
}
6 changes: 6 additions & 0 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ ruleTester.run('order', rule, {
import sibling, {foo3} from './foo';
import index from './';`,
}),
// Importing a package which contains nothing but a package.json which resolves elsewhere
test({
code: `
import reduxSagaEffects from 'eslint-import-test-order-redirect/module';
import relParent1 from '../foo';`,
}),
// Multiple module of the same rank next to each other
test({
code: `
Expand Down