Skip to content

Commit

Permalink
[Tests] order: add tests for pathGroupsExcludedImportTypes: ['type']
Browse files Browse the repository at this point in the history
Closes #2159
  • Loading branch information
bz-stripe authored and ljharb committed Jul 19, 2021
1 parent 1012eb9 commit 95e6011
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

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

## [2.23.4] - 2021-05-29

Expand Down Expand Up @@ -808,6 +809,7 @@ for info on changes for earlier releases.

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

[#2158]: https://github.com/benmosher/eslint-plugin-import/pull/2158
[#2138]: https://github.com/benmosher/eslint-plugin-import/pull/2138
[#2121]: https://github.com/benmosher/eslint-plugin-import/pull/2121
[#2099]: https://github.com/benmosher/eslint-plugin-import/pull/2099
Expand Down Expand Up @@ -1250,6 +1252,7 @@ for info on changes for earlier releases.
[@arvigeus]: https://github.com/arvigeus
[@asapach]: https://github.com/asapach
[@astorije]: https://github.com/astorije
[@atav32]: https://github.com/atav32
[@atikenny]: https://github.com/atikenny
[@atos1990]: https://github.com/atos1990
[@barbogast]: https://github.com/barbogast
Expand Down
95 changes: 95 additions & 0 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,36 @@ ruleTester.run('order', rule, {
'newlines-between': 'always',
}],
}),
test({
code: `
import { ReactElement, ReactNode } from 'react';
import { util } from 'Internal/lib';
import { parent } from '../parent';
import { sibling } from './sibling';
`,
options: [{
alphabetize: {
caseInsensitive: true,
order: 'asc',
},
pathGroups: [
{ pattern: 'Internal/**/*', group: 'internal' },
],
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
pathGroupsExcludedImportTypes: [],
}],
}),
...flatMap(getTSParsers, parser => [
// Order of the `import ... = require(...)` syntax
test({
Expand Down Expand Up @@ -2334,6 +2364,71 @@ context('TypeScript', function () {
},
parserConfig,
),
// Option alphabetize: {order: 'asc'} with type group & path group
test(
{
// only: true,
code: `
import c from 'Bar';
import a from 'foo';
import b from 'dirA/bar';
import index from './';
import type { C } from 'dirA/Bar';
import type { A } from 'foo';
`,
parser,
options: [
{
alphabetize: { order: 'asc' },
groups: ['external', 'internal', 'index', 'type'],
pathGroups: [
{
pattern: 'dirA/**',
group: 'internal',
},
],
'newlines-between': 'always',
pathGroupsExcludedImportTypes: ['type'],
},
],
},
parserConfig,
),
// Option alphabetize: {order: 'asc'} with path group
test(
{
// only: true,
code: `
import c from 'Bar';
import type { A } from 'foo';
import a from 'foo';
import type { C } from 'dirA/Bar';
import b from 'dirA/bar';
import index from './';
`,
parser,
options: [
{
alphabetize: { order: 'asc' },
groups: ['external', 'internal', 'index'],
pathGroups: [
{
pattern: 'dirA/**',
group: 'internal',
},
],
'newlines-between': 'always',
pathGroupsExcludedImportTypes: [],
},
],
},
parserConfig,
),
// Option alphabetize: {order: 'desc'} with type group
test(
{
Expand Down

0 comments on commit 95e6011

Please sign in to comment.