@@ -7,60 +7,71 @@ const rule = require('rules/first');
7
7
8
8
ruleTester . run ( 'first' , rule , {
9
9
valid : [
10
- test ( { code : "import { x } from './foo'; import { y } from './bar';\
11
- export { x, y }" } ) ,
10
+ test ( {
11
+ code : "import { x } from './foo'; import { y } from './bar';\
12
+ export { x, y }" ,
13
+ } ) ,
12
14
test ( { code : "import { x } from 'foo'; import { y } from './bar'" } ) ,
13
15
test ( { code : "import { x } from './foo'; import { y } from 'bar'" } ) ,
14
- test ( { code : "import { x } from './foo'; import { y } from 'bar'" ,
16
+ test ( {
17
+ code : "import { x } from './foo'; import { y } from 'bar'" ,
15
18
options : [ 'disable-absolute-first' ] ,
16
19
} ) ,
17
- test ( { code : "'use directive';\
18
- import { x } from 'foo';" } ) ,
20
+ test ( {
21
+ code : "'use directive';\
22
+ import { x } from 'foo';" ,
23
+ } ) ,
19
24
] ,
20
25
invalid : [
21
- test ( { code : "import { x } from './foo';\
22
- export { x };\
23
- import { y } from './bar';" ,
24
- errors : 1 ,
25
- output : "import { x } from './foo';\
26
- import { y } from './bar';\
27
- export { x };" ,
26
+ test ( {
27
+ code : "import { x } from './foo';\
28
+ export { x };\
29
+ import { y } from './bar';" ,
30
+ errors : 1 ,
31
+ output : "import { x } from './foo';\
32
+ import { y } from './bar';\
33
+ export { x };" ,
28
34
} ) ,
29
- test ( { code : "import { x } from './foo';\
30
- export { x };\
31
- import { y } from './bar';\
32
- import { z } from './baz';" ,
33
- errors : 2 ,
34
- output : "import { x } from './foo';\
35
- import { y } from './bar';\
36
- import { z } from './baz';\
37
- export { x };" ,
35
+ test ( {
36
+ code : "import { x } from './foo';\
37
+ export { x };\
38
+ import { y } from './bar';\
39
+ import { z } from './baz';" ,
40
+ errors : 2 ,
41
+ output : "import { x } from './foo';\
42
+ import { y } from './bar';\
43
+ import { z } from './baz';\
44
+ export { x };" ,
38
45
} ) ,
39
- test ( { code : "import { x } from './foo'; import { y } from 'bar'" ,
46
+ test ( {
47
+ code : "import { x } from './foo'; import { y } from 'bar'" ,
40
48
options : [ 'absolute-first' ] ,
41
49
errors : 1 ,
42
50
} ) ,
43
- test ( { code : "import { x } from 'foo';\
44
- 'use directive';\
45
- import { y } from 'bar';" ,
46
- errors : 1 ,
47
- output : "import { x } from 'foo';\
48
- import { y } from 'bar';\
49
- 'use directive';" ,
51
+ test ( {
52
+ code : "import { x } from 'foo';\
53
+ 'use directive';\
54
+ import { y } from 'bar';" ,
55
+ errors : 1 ,
56
+ output : "import { x } from 'foo';\
57
+ import { y } from 'bar';\
58
+ 'use directive';" ,
50
59
} ) ,
51
- test ( { code : "var a = 1;\
52
- import { y } from './bar';\
53
- if (true) { x() };\
54
- import { x } from './foo';\
55
- import { z } from './baz';" ,
56
- errors : 3 ,
57
- output : "import { y } from './bar';\
58
- var a = 1;\
59
- if (true) { x() };\
60
- import { x } from './foo';\
61
- import { z } from './baz';" ,
60
+ test ( {
61
+ code : "var a = 1;\
62
+ import { y } from './bar';\
63
+ if (true) { x() };\
64
+ import { x } from './foo';\
65
+ import { z } from './baz';" ,
66
+ errors : 3 ,
67
+ output : "import { y } from './bar';\
68
+ var a = 1;\
69
+ if (true) { x() };\
70
+ import { x } from './foo';\
71
+ import { z } from './baz';" ,
62
72
} ) ,
63
- test ( { code : "if (true) { console.log(1) }import a from 'b'" ,
73
+ test ( {
74
+ code : "if (true) { console.log(1) }import a from 'b'" ,
64
75
errors : 1 ,
65
76
output : "import a from 'b'\nif (true) { console.log(1) }" ,
66
77
} ) ,
@@ -72,7 +83,7 @@ context('TypeScript', function () {
72
83
. filter ( ( parser ) => parser !== require . resolve ( 'typescript-eslint-parser' ) )
73
84
. forEach ( ( parser ) => {
74
85
const parserConfig = {
75
- parser : parser ,
86
+ parser,
76
87
settings : {
77
88
'import/parsers' : { [ parser ] : [ '.ts' ] } ,
78
89
'import/resolver' : { 'eslint-import-resolver-typescript' : true } ,
@@ -81,35 +92,29 @@ context('TypeScript', function () {
81
92
82
93
ruleTester . run ( 'order' , rule , {
83
94
valid : [
84
- test (
85
- {
86
- code : `
87
- import y = require('bar');
88
- import { x } from 'foo';
89
- import z = require('baz');
90
- ` ,
91
- parser,
92
- } ,
93
- parserConfig ,
94
- ) ,
95
+ test ( {
96
+ code : `
97
+ import y = require('bar');
98
+ import { x } from 'foo';
99
+ import z = require('baz');
100
+ ` ,
101
+ ...parserConfig ,
102
+ } ) ,
95
103
] ,
96
104
invalid : [
97
- test (
98
- {
99
- code : `
100
- import { x } from './foo';
101
- import y = require('bar');
102
- ` ,
103
- options : [ 'absolute-first' ] ,
104
- parser,
105
- errors : [
106
- {
107
- message : 'Absolute imports should come before relative imports.' ,
108
- } ,
109
- ] ,
110
- } ,
111
- parserConfig ,
112
- ) ,
105
+ test ( {
106
+ code : `
107
+ import { x } from './foo';
108
+ import y = require('bar');
109
+ ` ,
110
+ options : [ 'absolute-first' ] ,
111
+ ...parserConfig ,
112
+ errors : [
113
+ {
114
+ message : 'Absolute imports should come before relative imports.' ,
115
+ } ,
116
+ ] ,
117
+ } ) ,
113
118
] ,
114
119
} ) ;
115
120
} ) ;
0 commit comments