Skip to content

Commit 95e6011

Browse files
bz-stripeljharb
authored andcommittedJul 19, 2021
[Tests] order: add tests for pathGroupsExcludedImportTypes: ['type']
Closes #2159
1 parent 1012eb9 commit 95e6011

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
 

‎CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1313

1414
### Changed
1515
- [Docs] `extensions`: removed incorrect cases ([#2138], thanks [@wenfangdu])
16+
- [Tests] `order`: add tests for `pathGroupsExcludedImportTypes: ['type']` ([#2158], thanks [@atav32])
1617

1718
## [2.23.4] - 2021-05-29
1819

@@ -808,6 +809,7 @@ for info on changes for earlier releases.
808809

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

812+
[#2158]: https://github.com/benmosher/eslint-plugin-import/pull/2158
811813
[#2138]: https://github.com/benmosher/eslint-plugin-import/pull/2138
812814
[#2121]: https://github.com/benmosher/eslint-plugin-import/pull/2121
813815
[#2099]: https://github.com/benmosher/eslint-plugin-import/pull/2099
@@ -1250,6 +1252,7 @@ for info on changes for earlier releases.
12501252
[@arvigeus]: https://github.com/arvigeus
12511253
[@asapach]: https://github.com/asapach
12521254
[@astorije]: https://github.com/astorije
1255+
[@atav32]: https://github.com/atav32
12531256
[@atikenny]: https://github.com/atikenny
12541257
[@atos1990]: https://github.com/atos1990
12551258
[@barbogast]: https://github.com/barbogast

‎tests/src/rules/order.js

+95
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,36 @@ ruleTester.run('order', rule, {
745745
'newlines-between': 'always',
746746
}],
747747
}),
748+
test({
749+
code: `
750+
import { ReactElement, ReactNode } from 'react';
751+
752+
import { util } from 'Internal/lib';
753+
754+
import { parent } from '../parent';
755+
756+
import { sibling } from './sibling';
757+
`,
758+
options: [{
759+
alphabetize: {
760+
caseInsensitive: true,
761+
order: 'asc',
762+
},
763+
pathGroups: [
764+
{ pattern: 'Internal/**/*', group: 'internal' },
765+
],
766+
groups: [
767+
'builtin',
768+
'external',
769+
'internal',
770+
'parent',
771+
'sibling',
772+
'index',
773+
],
774+
'newlines-between': 'always',
775+
pathGroupsExcludedImportTypes: [],
776+
}],
777+
}),
748778
...flatMap(getTSParsers, parser => [
749779
// Order of the `import ... = require(...)` syntax
750780
test({
@@ -2334,6 +2364,71 @@ context('TypeScript', function () {
23342364
},
23352365
parserConfig,
23362366
),
2367+
// Option alphabetize: {order: 'asc'} with type group & path group
2368+
test(
2369+
{
2370+
// only: true,
2371+
code: `
2372+
import c from 'Bar';
2373+
import a from 'foo';
2374+
2375+
import b from 'dirA/bar';
2376+
2377+
import index from './';
2378+
2379+
import type { C } from 'dirA/Bar';
2380+
import type { A } from 'foo';
2381+
`,
2382+
parser,
2383+
options: [
2384+
{
2385+
alphabetize: { order: 'asc' },
2386+
groups: ['external', 'internal', 'index', 'type'],
2387+
pathGroups: [
2388+
{
2389+
pattern: 'dirA/**',
2390+
group: 'internal',
2391+
},
2392+
],
2393+
'newlines-between': 'always',
2394+
pathGroupsExcludedImportTypes: ['type'],
2395+
},
2396+
],
2397+
},
2398+
parserConfig,
2399+
),
2400+
// Option alphabetize: {order: 'asc'} with path group
2401+
test(
2402+
{
2403+
// only: true,
2404+
code: `
2405+
import c from 'Bar';
2406+
import type { A } from 'foo';
2407+
import a from 'foo';
2408+
2409+
import type { C } from 'dirA/Bar';
2410+
import b from 'dirA/bar';
2411+
2412+
import index from './';
2413+
`,
2414+
parser,
2415+
options: [
2416+
{
2417+
alphabetize: { order: 'asc' },
2418+
groups: ['external', 'internal', 'index'],
2419+
pathGroups: [
2420+
{
2421+
pattern: 'dirA/**',
2422+
group: 'internal',
2423+
},
2424+
],
2425+
'newlines-between': 'always',
2426+
pathGroupsExcludedImportTypes: [],
2427+
},
2428+
],
2429+
},
2430+
parserConfig,
2431+
),
23372432
// Option alphabetize: {order: 'desc'} with type group
23382433
test(
23392434
{

0 commit comments

Comments
 (0)
Please sign in to comment.