Skip to content

Commit

Permalink
[Fix] order: Recognize pathGroup config for first group
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Marigold Klassen <forivall@gmail.com>
Co-authored-by: Vitaly Gordon <rocket.mind@gmail.com>
  • Loading branch information
2 people authored and ljharb committed Apr 4, 2020
1 parent baf1a8c commit fe6cea9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

### Fixed
- [`group-exports`]: Flow type export awareness ([#1702], thanks [@ernestostifano])
- [`order`]: Recognize pathGroup config for first group ([#1719], [#1724], thanks [@forivall], [@xpl])

## [2.20.2] - 2020-03-28
### Fixed
Expand Down Expand Up @@ -663,6 +664,8 @@ for info on changes for earlier releases.

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

[#1724]: https://github.com/benmosher/eslint-plugin-import/issues/1724
[#1719]: https://github.com/benmosher/eslint-plugin-import/issues/1719
[#1702]: https://github.com/benmosher/eslint-plugin-import/issues/1702
[#1666]: https://github.com/benmosher/eslint-plugin-import/pull/1666
[#1664]: https://github.com/benmosher/eslint-plugin-import/pull/1664
Expand Down Expand Up @@ -1128,3 +1131,5 @@ for info on changes for earlier releases.
[@richardxia]: https://github.com/richardxia
[@TheCrueltySage]: https://github.com/TheCrueltySage
[@ernestostifano]: https://github.com/ernestostifano
[@forivall]: https://github.com/forivall
[@xpl]: https://github.com/xpl
2 changes: 1 addition & 1 deletion src/rules/order.js
Expand Up @@ -318,7 +318,7 @@ function computeRank(context, ranks, name, type, excludedImportTypes) {
if (!excludedImportTypes.has(impType)) {
rank = computePathRank(ranks.groups, ranks.pathGroups, name, ranks.maxPosition)
}
if (!rank) {
if (typeof rank === 'undefined') {
rank = ranks.groups[impType]
}
if (type !== 'import') {
Expand Down
17 changes: 17 additions & 0 deletions tests/src/rules/order.js
Expand Up @@ -307,6 +307,23 @@ ruleTester.run('order', rule, {
],
}],
}),
// Using pathGroups (a test case for https://github.com/benmosher/eslint-plugin-import/pull/1724)
test({
code: `
import fs from 'fs';
import external from 'external';
import externalTooPlease from './make-me-external';
import sibling from './sibling';`,
options: [{
'newlines-between': 'always',
pathGroupsExcludedImportTypes: [],
pathGroups: [
{ pattern: './make-me-external', group: 'external' },
],
groups: [['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'],
}],
}),
// Monorepo setup, using Webpack resolver, workspace folder name in external-module-folders
test({
code: `
Expand Down

0 comments on commit fe6cea9

Please sign in to comment.