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

[Fix] order: Recognize pathGroup config for first group #1719

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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