Skip to content

Commit defcf08

Browse files
committed
[Tests] order: add a passing test
Closes #2662
1 parent 5ff9e45 commit defcf08

File tree

1 file changed

+82
-4
lines changed

1 file changed

+82
-4
lines changed

tests/src/rules/order.js

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,16 +1096,15 @@ ruleTester.run('order', rule, {
10961096
// orderImportKind option that is not used
10971097
test({
10981098
code: `
1099-
import B from './B';
1100-
import b from './b';
1101-
`,
1099+
import B from './B';
1100+
import b from './b';
1101+
`,
11021102
options: [
11031103
{
11041104
'alphabetize': { order: 'asc', orderImportKind: 'asc', 'caseInsensitive': true },
11051105
},
11061106
],
11071107
}),
1108-
11091108
],
11101109
invalid: [
11111110
// builtin before external module (require)
@@ -3275,5 +3274,84 @@ flowRuleTester.run('order', rule, {
32753274
message: '`./local/sub` typeof import should occur before import of `./local/sub`',
32763275
}],
32773276
}),
3277+
test({
3278+
code: `
3279+
import { cfg } from 'path/path/path/src/Cfg';
3280+
import { l10n } from 'path/src/l10n';
3281+
import { helpers } from 'path/path/path/helpers';
3282+
import { tip } from 'path/path/tip';
3283+
3284+
import { controller } from '../../../../path/path/path/controller';
3285+
import { component } from '../../../../path/path/path/component';
3286+
`,
3287+
output: semver.satisfies(eslintPkg.version, '< 3') ? `
3288+
import { cfg } from 'path/path/path/src/Cfg';
3289+
import { tip } from 'path/path/tip';
3290+
import { l10n } from 'path/src/l10n';
3291+
import { helpers } from 'path/path/path/helpers';
3292+
3293+
import { component } from '../../../../path/path/path/component';
3294+
import { controller } from '../../../../path/path/path/controller';
3295+
` : `
3296+
import { helpers } from 'path/path/path/helpers';
3297+
import { cfg } from 'path/path/path/src/Cfg';
3298+
import { l10n } from 'path/src/l10n';
3299+
import { tip } from 'path/path/tip';
3300+
3301+
import { component } from '../../../../path/path/path/component';
3302+
import { controller } from '../../../../path/path/path/controller';
3303+
`,
3304+
options: [
3305+
{
3306+
'groups': [
3307+
['builtin', 'external'],
3308+
'internal',
3309+
['sibling', 'parent'],
3310+
'object',
3311+
'type',
3312+
],
3313+
'pathGroups': [
3314+
{
3315+
'pattern': 'react',
3316+
'group': 'builtin',
3317+
'position': 'before',
3318+
'patternOptions': {
3319+
'matchBase': true,
3320+
},
3321+
},
3322+
{
3323+
'pattern': '*.+(css|svg)',
3324+
'group': 'type',
3325+
'position': 'after',
3326+
'patternOptions': {
3327+
'matchBase': true,
3328+
},
3329+
},
3330+
],
3331+
'pathGroupsExcludedImportTypes': ['react'],
3332+
'alphabetize': {
3333+
'order': 'asc',
3334+
},
3335+
'newlines-between': 'always',
3336+
},
3337+
],
3338+
errors: [
3339+
{
3340+
message: '`path/path/path/helpers` import should occur before import of `path/path/path/src/Cfg`',
3341+
line: 4,
3342+
column: 9,
3343+
},
3344+
{
3345+
message: '`path/path/tip` import should occur before import of `path/src/l10n`',
3346+
line: 5,
3347+
column: 9,
3348+
},
3349+
{
3350+
message: '`../../../../path/path/path/component` import should occur before import of `../../../../path/path/path/controller`',
3351+
line: 8,
3352+
column: 9,
3353+
},
3354+
],
3355+
}),
32783356
],
32793357
});

0 commit comments

Comments
 (0)