Skip to content

Commit 2df9be6

Browse files
committed
address review
1 parent ac4960c commit 2df9be6

File tree

2 files changed

+87
-13
lines changed

2 files changed

+87
-13
lines changed

Diff for: src/rules/consistent-type-specifier-style.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import docsUrl from '../docsUrl';
22

3+
function isComma(token) {
4+
return token.type === 'Punctuator' && token.value === ',';
5+
}
6+
37
module.exports = {
48
meta: {
59
type: 'suggestion',
@@ -24,6 +28,7 @@ module.exports = {
2428
return {
2529
ImportDeclaration(node) {
2630
if (node.importKind === 'value' || node.importKind == null) {
31+
// top-level value / unknown is valid
2732
return;
2833
}
2934

@@ -220,8 +225,3 @@ module.exports = {
220225
};
221226
},
222227
};
223-
224-
function isComma(token) {
225-
return token.type === 'Punctuator' && token.value === ',';
226-
}
227-

Diff for: tests/src/rules/consistent-type-specifier-style.js

+82-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,88 @@ const COMMON_TESTS = {
88
//
99
// always valid
1010
//
11-
test({ code: "import Foo from 'Foo';" }),
12-
test({ code: "import type Foo from 'Foo';" }),
13-
test({ code: "import { Foo } from 'Foo';" }),
14-
test({ code: "import { Foo as Bar } from 'Foo';" }),
15-
test({ code: "import * as Foo from 'Foo';" }),
16-
test({ code: "import 'Foo';" }),
17-
test({ code: "import {} from 'Foo';" }),
18-
test({ code: "import type {} from 'Foo';" }),
11+
// prefer-inline
12+
test({
13+
code: "import Foo from 'Foo';",
14+
options: ['prefer-inline'],
15+
}),
16+
test({
17+
code: "import type Foo from 'Foo';",
18+
options: ['prefer-inline'],
19+
}),
20+
test({
21+
code: "import { Foo } from 'Foo';",
22+
options: ['prefer-inline'],
23+
}),
24+
test({
25+
code: "import { Foo as Bar } from 'Foo';",
26+
options: ['prefer-inline'],
27+
}),
28+
test({
29+
code: "import * as Foo from 'Foo';",
30+
options: ['prefer-inline'],
31+
}),
32+
test({
33+
code: "import 'Foo';",
34+
options: ['prefer-inline'],
35+
}),
36+
test({
37+
code: "import {} from 'Foo';",
38+
options: ['prefer-inline'],
39+
}),
40+
test({
41+
code: "import type {} from 'Foo';",
42+
options: ['prefer-inline'],
43+
}),
44+
// prefer-top-level
45+
test({
46+
code: "import Foo from 'Foo';",
47+
options: ['prefer-top-level'],
48+
}),
49+
test({
50+
code: "import type Foo from 'Foo';",
51+
options: ['prefer-top-level'],
52+
}),
53+
test({
54+
code: "import { Foo } from 'Foo';",
55+
options: ['prefer-top-level'],
56+
}),
57+
test({
58+
code: "import { Foo as Bar } from 'Foo';",
59+
options: ['prefer-top-level'],
60+
}),
61+
test({
62+
code: "import * as Foo from 'Foo';",
63+
options: ['prefer-top-level'],
64+
}),
65+
test({
66+
code: "import 'Foo';",
67+
options: ['prefer-top-level'],
68+
}),
69+
test({
70+
code: "import {} from 'Foo';",
71+
options: ['prefer-top-level'],
72+
}),
73+
test({
74+
code: "import type {} from 'Foo';",
75+
options: ['prefer-top-level'],
76+
}),
77+
78+
//
79+
// prefer-inline
80+
//
81+
{
82+
code: "import { type Foo } from 'Foo';",
83+
options: ['prefer-inline'],
84+
},
85+
{
86+
code: "import { type Foo as Bar } from 'Foo';",
87+
options: ['prefer-inline'],
88+
},
89+
{
90+
code: "import { type Foo, type Bar, Baz, Bam } from 'Foo';",
91+
options: ['prefer-inline'],
92+
},
1993

2094
//
2195
// prefer-top-level

0 commit comments

Comments
 (0)