eslint-plugin-lube 0.4.3 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +126 -125
- package/package.json +39 -31
- package/rules/pretty-imports.js +15 -15
- package/rules/pretty-jsdoc-casting.js +37 -29
- package/rules/pretty-sequence.js +61 -52
- package/rules/svelte-naming-convention.js +19 -19
- package/test/pretty-imports/ExportNamedDeclaration.js +32 -24
- package/test/pretty-imports/ImportDeclaration.js +32 -24
- package/test/pretty-imports.js +3 -3
- package/test/pretty-jsdoc-casting/case_by_expression.js +73 -25
- package/test/pretty-jsdoc-casting/various_situations.js +31 -11
- package/test/pretty-jsdoc-casting.js +3 -3
- package/test/pretty-sequence/case_by_node_type.js +62 -30
- package/test/pretty-sequence/case_by_option.js +31 -15
- package/test/pretty-sequence/various_situations.js +34 -9
- package/test/pretty-sequence.js +3 -3
- package/test/svelte-naming-convention/basic_snake_case.js +21 -8
- package/test/svelte-naming-convention/case_by_identifier.js +761 -195
- package/test/svelte-naming-convention/snake_case_with_symbols.js +28 -7
- package/test/svelte-naming-convention.js +3 -3
- package/tsconfig.json +10 -2
- package/types/index.d.ts +15 -0
- package/types/index.d.ts.map +1 -0
- package/types/rules/pretty-imports.d.ts +3 -0
- package/types/rules/pretty-imports.d.ts.map +1 -0
- package/types/rules/pretty-jsdoc-casting.d.ts +3 -0
- package/types/rules/pretty-jsdoc-casting.d.ts.map +1 -0
- package/types/rules/pretty-sequence.d.ts +3 -0
- package/types/rules/pretty-sequence.d.ts.map +1 -0
- package/types/rules/svelte-naming-convention.d.ts +3 -0
- package/types/rules/svelte-naming-convention.d.ts.map +1 -0
- package/types/test/pretty-imports/ExportNamedDeclaration.d.ts +2 -0
- package/types/test/pretty-imports/ExportNamedDeclaration.d.ts.map +1 -0
- package/types/test/pretty-imports/ImportDeclaration.d.ts +2 -0
- package/types/test/pretty-imports/ImportDeclaration.d.ts.map +1 -0
- package/types/test/pretty-imports.d.ts +2 -0
- package/types/test/pretty-imports.d.ts.map +1 -0
- package/types/test/pretty-jsdoc-casting/case_by_expression.d.ts +2 -0
- package/types/test/pretty-jsdoc-casting/case_by_expression.d.ts.map +1 -0
- package/types/test/pretty-jsdoc-casting/various_situations.d.ts +2 -0
- package/types/test/pretty-jsdoc-casting/various_situations.d.ts.map +1 -0
- package/types/test/pretty-jsdoc-casting.d.ts +2 -0
- package/types/test/pretty-jsdoc-casting.d.ts.map +1 -0
- package/types/test/pretty-sequence/case_by_node_type.d.ts +2 -0
- package/types/test/pretty-sequence/case_by_node_type.d.ts.map +1 -0
- package/types/test/pretty-sequence/case_by_option.d.ts +2 -0
- package/types/test/pretty-sequence/case_by_option.d.ts.map +1 -0
- package/types/test/pretty-sequence/various_situations.d.ts +2 -0
- package/types/test/pretty-sequence/various_situations.d.ts.map +1 -0
- package/types/test/pretty-sequence.d.ts +2 -0
- package/types/test/pretty-sequence.d.ts.map +1 -0
- package/types/test/svelte-naming-convention/basic_snake_case.d.ts +2 -0
- package/types/test/svelte-naming-convention/basic_snake_case.d.ts.map +1 -0
- package/types/test/svelte-naming-convention/case_by_identifier.d.ts +2 -0
- package/types/test/svelte-naming-convention/case_by_identifier.d.ts.map +1 -0
- package/types/test/svelte-naming-convention/snake_case_with_symbols.d.ts +2 -0
- package/types/test/svelte-naming-convention/snake_case_with_symbols.d.ts.map +1 -0
- package/types/test/svelte-naming-convention.d.ts +2 -0
- package/types/test/svelte-naming-convention.d.ts.map +1 -0
package/rules/pretty-sequence.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const indent_regex = /[ \t]*(?=[^\n]*$)/
|
|
4
|
+
const left_space_regex = /\s+$/
|
|
5
|
+
const right_space_regex = /^\s+/
|
|
6
|
+
const __n_regex = /(?<=\n)/g
|
|
7
|
+
const _r_regex = /\r/g
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @param {number} length
|
|
11
11
|
* @returns {number[]}
|
|
12
12
|
*/
|
|
13
13
|
function get_indexed_array(length) {
|
|
14
|
-
|
|
14
|
+
const array = []
|
|
15
15
|
while (length) array[--length] = length
|
|
16
16
|
return array
|
|
17
17
|
}
|
|
@@ -49,33 +49,33 @@ module.exports = {
|
|
|
49
49
|
},
|
|
50
50
|
create(context) {
|
|
51
51
|
/** @type {import("../private").RuleOptions["pretty-sequence"]} */
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
const option = context.options[0]
|
|
53
|
+
const array_bracket_spacing = option?.arrayBracketSpacing ?? true
|
|
54
|
+
const check_array = option?.checkArray ?? true
|
|
55
|
+
const check_call = option?.checkCall ?? true
|
|
56
|
+
const check_object = option?.checkObject ?? true
|
|
57
|
+
const check_sequence = option?.checkSequence ?? true
|
|
58
|
+
const func_call_spacing = option?.funcCallSpacing ?? false
|
|
59
|
+
const ignore_template_literal = option?.ignoreTemplateLiteral ?? true
|
|
60
|
+
const indent = option?.indent ?? "\t"
|
|
61
|
+
const max_length = option?.maxLength ?? 30
|
|
62
|
+
const object_curly_spacing = option?.objectCurlySpacing ?? true
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const source_code = context.sourceCode
|
|
65
|
+
const origin_text = source_code.text
|
|
66
66
|
let fixed_text = origin_text
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const text_length = fixed_text.length + 1
|
|
68
|
+
const text_indexes = get_indexed_array(text_length)
|
|
69
69
|
/** @type {import("../private").Comment[]} */
|
|
70
|
-
|
|
71
|
-
for (
|
|
70
|
+
const comments = []
|
|
71
|
+
for (const comment of /** @type {import("../private").Comment[]} */(source_code.getAllComments())/**/) {
|
|
72
72
|
let [ start, end ] = comment.range
|
|
73
73
|
while (start < end) comments[start++] = comment
|
|
74
74
|
}
|
|
75
75
|
/** @type {true[]} */
|
|
76
|
-
|
|
76
|
+
const ignored_indexes = []
|
|
77
77
|
/** @type {import("../private").AstNode[] & import("estree").Expression[]} */
|
|
78
|
-
|
|
78
|
+
const nodes = []
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* @param {import("../private").AstNode} node
|
|
@@ -87,21 +87,23 @@ module.exports = {
|
|
|
87
87
|
function get_text(node, start, end, add_indentation) {
|
|
88
88
|
let open_paren = false
|
|
89
89
|
let [ left, right ] = node.range
|
|
90
|
+
let comment
|
|
90
91
|
W: while (left > start) {
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
comment = comments[left - 1]
|
|
93
|
+
if (comment) {
|
|
94
|
+
left = comment.range[0]
|
|
93
95
|
} else {
|
|
94
|
-
|
|
96
|
+
const left_space = left_space_regex.exec(origin_text.slice(0, left))?.[0].length
|
|
95
97
|
if (left_space) {
|
|
96
98
|
left -= left_space
|
|
97
99
|
} else if (origin_text[left - 1] == "(") {
|
|
98
100
|
open_paren = true
|
|
99
101
|
while (right < end) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
comment = comments[right]
|
|
103
|
+
if (comment) {
|
|
102
104
|
right = comment.range[1]
|
|
103
105
|
} else {
|
|
104
|
-
|
|
106
|
+
const right_space = right_space_regex.exec(origin_text.slice(right))?.[0].length
|
|
105
107
|
if (right_space) {
|
|
106
108
|
right += right_space
|
|
107
109
|
} else {
|
|
@@ -121,11 +123,11 @@ module.exports = {
|
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
while (right < end) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
comment = comments[right]
|
|
127
|
+
if (comment) {
|
|
126
128
|
right = comment.range[1]
|
|
127
129
|
} else {
|
|
128
|
-
|
|
130
|
+
const right_space = right_space_regex.exec(origin_text.slice(right))?.[0].length
|
|
129
131
|
if (right_space) {
|
|
130
132
|
right += right_space
|
|
131
133
|
} else {
|
|
@@ -133,7 +135,7 @@ module.exports = {
|
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
|
-
|
|
138
|
+
const substr = fixed_text.slice(
|
|
137
139
|
text_indexes[left],
|
|
138
140
|
text_indexes[right]
|
|
139
141
|
)
|
|
@@ -162,8 +164,11 @@ module.exports = {
|
|
|
162
164
|
* @returns {void}
|
|
163
165
|
*/
|
|
164
166
|
function report(node, start, end, corrected_text) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
const s = text_indexes[start]
|
|
168
|
+
const e = text_indexes[end]
|
|
169
|
+
if (s == null || e == null) return
|
|
170
|
+
fixed_text = fixed_text.slice(0, s) + corrected_text + fixed_text.slice(e)
|
|
171
|
+
const gap = corrected_text.length + s - e
|
|
167
172
|
if (gap) {
|
|
168
173
|
for (let i = end; i < text_length; i++) {
|
|
169
174
|
text_indexes[i] += gap
|
|
@@ -202,21 +207,21 @@ module.exports = {
|
|
|
202
207
|
let line_indent = get_indent(node.range[0])
|
|
203
208
|
switch (node.type) {
|
|
204
209
|
case "ArrayExpression":
|
|
205
|
-
case "ArrayPattern":
|
|
210
|
+
case "ArrayPattern": {
|
|
206
211
|
start = node.range[0] + 1
|
|
207
212
|
end = node.range[1] - 1
|
|
208
213
|
let null_anchor = start
|
|
209
|
-
|
|
214
|
+
const elements = node.elements.map(
|
|
210
215
|
v => {
|
|
211
|
-
|
|
216
|
+
const n = v ?? {
|
|
212
217
|
range: [ null_anchor, null_anchor ]
|
|
213
218
|
}
|
|
214
|
-
|
|
219
|
+
const text = get_text(n, start, end)
|
|
215
220
|
null_anchor += text.length + 1
|
|
216
221
|
return n
|
|
217
222
|
}
|
|
218
223
|
)
|
|
219
|
-
for (
|
|
224
|
+
for (const text of elements.map(v => get_text(v, start, end))) {
|
|
220
225
|
if (text.includes("\n")) {
|
|
221
226
|
length = max_length + 1
|
|
222
227
|
break
|
|
@@ -239,26 +244,30 @@ module.exports = {
|
|
|
239
244
|
elements.map(v => get_text(v, start, end)).join(", ")
|
|
240
245
|
}${length && array_bracket_spacing ? " " : ""}`
|
|
241
246
|
break
|
|
247
|
+
}
|
|
242
248
|
case "ArrowFunctionExpression":
|
|
243
249
|
case "FunctionDeclaration":
|
|
244
250
|
case "FunctionExpression":
|
|
245
251
|
if (node.type == "ArrowFunctionExpression") {
|
|
246
252
|
if (
|
|
247
|
-
node.params.length
|
|
253
|
+
node.params.length > 1
|
|
248
254
|
|| origin_text.slice(
|
|
249
255
|
node.range[0],
|
|
250
|
-
node.params[0]
|
|
256
|
+
node.params[0]?.range[0]
|
|
251
257
|
).includes("(")
|
|
252
258
|
) {
|
|
253
259
|
start = origin_text.indexOf("(", node.range[0]) + 1
|
|
254
260
|
end = origin_text.indexOf(
|
|
255
261
|
")",
|
|
256
262
|
node.params.length
|
|
257
|
-
? node.params[node.params.length - 1]
|
|
263
|
+
? node.params[node.params.length - 1]?.range[1]
|
|
258
264
|
: start
|
|
259
265
|
)
|
|
260
266
|
} else {
|
|
261
|
-
|
|
267
|
+
const range = node.params[0]?.range
|
|
268
|
+
if (range) {
|
|
269
|
+
[ start, end ] = range
|
|
270
|
+
}
|
|
262
271
|
}
|
|
263
272
|
} else {
|
|
264
273
|
start = node.id
|
|
@@ -267,11 +276,11 @@ module.exports = {
|
|
|
267
276
|
end = origin_text.indexOf(
|
|
268
277
|
")",
|
|
269
278
|
node.params.length
|
|
270
|
-
? node.params[node.params.length - 1]
|
|
279
|
+
? node.params[node.params.length - 1]?.range[1]
|
|
271
280
|
: start
|
|
272
281
|
)
|
|
273
282
|
}
|
|
274
|
-
for (
|
|
283
|
+
for (const text of node.params.map(v => get_text(v, start, end))) {
|
|
275
284
|
if (text.includes("\n")) {
|
|
276
285
|
length = max_length + 1
|
|
277
286
|
break
|
|
@@ -300,7 +309,7 @@ module.exports = {
|
|
|
300
309
|
line_indent = get_indent(node.callee.range[1])
|
|
301
310
|
start = origin_text.indexOf("(", node.callee.range[1]) + 1
|
|
302
311
|
end = node.range[1] - 1
|
|
303
|
-
for (
|
|
312
|
+
for (const text of node.arguments.map(v => get_text(v, start, end))) {
|
|
304
313
|
if (text.includes("\n")) {
|
|
305
314
|
length = max_length + 1
|
|
306
315
|
break
|
|
@@ -327,7 +336,7 @@ module.exports = {
|
|
|
327
336
|
case "ObjectPattern":
|
|
328
337
|
start = node.range[0] + 1
|
|
329
338
|
end = node.range[1] - 1
|
|
330
|
-
for (
|
|
339
|
+
for (const text of node.properties.map(v => get_text(v, start, end))) {
|
|
331
340
|
if (text.includes("\n")) {
|
|
332
341
|
length = max_length + 1
|
|
333
342
|
break
|
|
@@ -354,7 +363,7 @@ module.exports = {
|
|
|
354
363
|
case "SequenceExpression":
|
|
355
364
|
start = node.range[0]
|
|
356
365
|
end = node.range[1]
|
|
357
|
-
for (
|
|
366
|
+
for (const text of node.expressions.map(v => get_text(v, start, end))) {
|
|
358
367
|
if (text.includes("\n")) {
|
|
359
368
|
length = max_length + 1
|
|
360
369
|
break
|
|
@@ -384,7 +393,7 @@ module.exports = {
|
|
|
384
393
|
}
|
|
385
394
|
return /** @type {import("../private").RuleListener} */({
|
|
386
395
|
"Program:exit": () => {
|
|
387
|
-
for (
|
|
396
|
+
for (const node of nodes.reverse()) {
|
|
388
397
|
try {
|
|
389
398
|
verify_correct(node)
|
|
390
399
|
} catch (error) {
|
|
@@ -23,21 +23,21 @@ module.exports = {
|
|
|
23
23
|
},
|
|
24
24
|
create(context) {
|
|
25
25
|
/** @type {import("../private").RuleOptions["svelte-naming-convention"]} */
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const option = context.options[0]
|
|
27
|
+
const fix_same_names = option?.fixSameNames ?? true
|
|
28
28
|
|
|
29
29
|
// let name | let name | class name
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const allow_regex = /^[_$]?[_$]?(?:[\da-z]+(?:_[\da-z]+)*\$?\$?)?$|^[A-Z](?:_?[\dA-Z]+)*$|^(?:[\dA-Z][\da-z]*)+$/
|
|
31
|
+
const fixable_name_regex = /^[_$]?[_$]?(?:[\dA-Za-z]+(?:_[\dA-Za-z]+)*\$?\$?)?$/
|
|
32
|
+
const fix_regex = /([\da-z]?)([A-Z][\dA-Z]*)/g
|
|
33
|
+
const camel_case_regex = /^[\da-z]+([A-Z][\da-z]*)*$/
|
|
34
34
|
|
|
35
35
|
/** @type {Map<string, import("../private").AstNode[]>} */
|
|
36
|
-
|
|
36
|
+
const pending_usages = new Map()
|
|
37
37
|
/** @type {Set<string>} */
|
|
38
|
-
|
|
38
|
+
const reported_declarations = new Set()
|
|
39
39
|
/** @type {Set<import("../private").AstNode>} */
|
|
40
|
-
|
|
40
|
+
const shortand_properties = new Set()
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @param {import("../private").AstNode & import("estree").Identifier} node
|
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
|
45
45
|
*/
|
|
46
46
|
function defer(node) {
|
|
47
47
|
if (fix_same_names) {
|
|
48
|
-
|
|
48
|
+
const name = node.name
|
|
49
49
|
if (reported_declarations.has(name)) report(node)
|
|
50
50
|
else {
|
|
51
51
|
let usages = pending_usages.get(name)
|
|
@@ -71,7 +71,7 @@ module.exports = {
|
|
|
71
71
|
* @returns {void}
|
|
72
72
|
*/
|
|
73
73
|
function report(node) {
|
|
74
|
-
|
|
74
|
+
const name = node.name
|
|
75
75
|
context.report(
|
|
76
76
|
{
|
|
77
77
|
data: { name },
|
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
|
90
90
|
}
|
|
91
91
|
)
|
|
92
92
|
if (fix_same_names) {
|
|
93
|
-
|
|
93
|
+
const usages = pending_usages.get(name)
|
|
94
94
|
while (usages?.length) {
|
|
95
95
|
report(
|
|
96
96
|
/** @type {import("../private").AstNode & import("estree").Identifier} */(usages.pop())/**/
|
|
@@ -103,9 +103,9 @@ module.exports = {
|
|
|
103
103
|
return {
|
|
104
104
|
/** @param {import("../private").AstNode & import("estree").Identifier} node */
|
|
105
105
|
Identifier(node) {
|
|
106
|
-
|
|
106
|
+
const name = node.name
|
|
107
107
|
if (allow_regex.test(name)) return
|
|
108
|
-
|
|
108
|
+
const parent = node.parent
|
|
109
109
|
switch (parent.type) {
|
|
110
110
|
case "ArrayExpression":
|
|
111
111
|
// var value = [ camelCase ]
|
|
@@ -227,7 +227,7 @@ module.exports = {
|
|
|
227
227
|
break
|
|
228
228
|
case "ImportSpecifier":
|
|
229
229
|
// import { imported as local, local2 } from "module"
|
|
230
|
-
if (parent.local == node && parent.imported.name != parent.local.name) {
|
|
230
|
+
if (parent.local == node && parent.imported.type == "Identifier" && parent.imported.name != parent.local.name) {
|
|
231
231
|
// import { imported as camelCase } from "module"
|
|
232
232
|
report(node)
|
|
233
233
|
}
|
|
@@ -346,10 +346,10 @@ module.exports = {
|
|
|
346
346
|
// while (camelCase) {}
|
|
347
347
|
defer(node)
|
|
348
348
|
break
|
|
349
|
-
case "WithStatement":
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
349
|
+
// case "WithStatement":
|
|
350
|
+
// // with (camelCase) {}
|
|
351
|
+
// defer(node)
|
|
352
|
+
// break
|
|
353
353
|
case "YieldExpression":
|
|
354
354
|
// function* func() { yield camelCase }
|
|
355
355
|
defer(node)
|
|
@@ -11,9 +11,11 @@ exports.module = (valid, invalid) => {
|
|
|
11
11
|
export { fff, ggg, hhh, iii, jjj, kkk, lll } from 'module/2'
|
|
12
12
|
`,
|
|
13
13
|
options: [ { maxLength: 30 } ],
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parserOptions: {
|
|
16
|
+
ecmaVersion: "latest",
|
|
17
|
+
sourceType: "module"
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
},
|
|
19
21
|
{
|
|
@@ -22,9 +24,11 @@ exports.module = (valid, invalid) => {
|
|
|
22
24
|
export { a, b, c };
|
|
23
25
|
`,
|
|
24
26
|
options: [ { semicolon: true } ],
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
languageOptions: {
|
|
28
|
+
parserOptions: {
|
|
29
|
+
ecmaVersion: "latest",
|
|
30
|
+
sourceType: "module"
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
)
|
|
@@ -37,16 +41,16 @@ exports.module = (valid, invalid) => {
|
|
|
37
41
|
`,
|
|
38
42
|
errors: [
|
|
39
43
|
{
|
|
40
|
-
|
|
41
|
-
type: "ExportNamedDeclaration",
|
|
44
|
+
column: 4,
|
|
42
45
|
line: 3,
|
|
43
|
-
|
|
46
|
+
messageId: "exports",
|
|
47
|
+
type: "ExportNamedDeclaration"
|
|
44
48
|
},
|
|
45
49
|
{
|
|
46
|
-
|
|
47
|
-
type: "ExportNamedDeclaration",
|
|
50
|
+
column: 7,
|
|
48
51
|
line: 4,
|
|
49
|
-
|
|
52
|
+
messageId: "exports",
|
|
53
|
+
type: "ExportNamedDeclaration"
|
|
50
54
|
}
|
|
51
55
|
],
|
|
52
56
|
options: [
|
|
@@ -65,9 +69,11 @@ exports.module = (valid, invalid) => {
|
|
|
65
69
|
lll
|
|
66
70
|
} from 'module/2';
|
|
67
71
|
`,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
languageOptions: {
|
|
73
|
+
parserOptions: {
|
|
74
|
+
ecmaVersion: "latest",
|
|
75
|
+
sourceType: "module"
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
},
|
|
73
79
|
{
|
|
@@ -78,16 +84,16 @@ exports.module = (valid, invalid) => {
|
|
|
78
84
|
`,
|
|
79
85
|
errors: [
|
|
80
86
|
{
|
|
81
|
-
|
|
82
|
-
type: "ExportNamedDeclaration",
|
|
87
|
+
column: 4,
|
|
83
88
|
line: 3,
|
|
84
|
-
|
|
89
|
+
messageId: "exports",
|
|
90
|
+
type: "ExportNamedDeclaration"
|
|
85
91
|
},
|
|
86
92
|
{
|
|
87
|
-
|
|
88
|
-
type: "ExportNamedDeclaration",
|
|
93
|
+
column: 7,
|
|
89
94
|
line: 4,
|
|
90
|
-
|
|
95
|
+
messageId: "exports",
|
|
96
|
+
type: "ExportNamedDeclaration"
|
|
91
97
|
}
|
|
92
98
|
],
|
|
93
99
|
options: [
|
|
@@ -106,9 +112,11 @@ exports.module = (valid, invalid) => {
|
|
|
106
112
|
lll
|
|
107
113
|
} from 'module/2'
|
|
108
114
|
`,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
languageOptions: {
|
|
116
|
+
parserOptions: {
|
|
117
|
+
ecmaVersion: "latest",
|
|
118
|
+
sourceType: "module"
|
|
119
|
+
}
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
)
|
|
@@ -11,9 +11,11 @@ exports.module = (valid, invalid) => {
|
|
|
11
11
|
import { fff, ggg, hhh, iii, jjj, kkk, lll } from 'module/2'
|
|
12
12
|
`,
|
|
13
13
|
options: [ { maxLength: 30 } ],
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parserOptions: {
|
|
16
|
+
ecmaVersion: "latest",
|
|
17
|
+
sourceType: "module"
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
},
|
|
19
21
|
{
|
|
@@ -24,9 +26,11 @@ import {
|
|
|
24
26
|
aaaaa_ddddd
|
|
25
27
|
} from "module";`,
|
|
26
28
|
options: [ { semicolon: true } ],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
languageOptions: {
|
|
30
|
+
parserOptions: {
|
|
31
|
+
ecmaVersion: "latest",
|
|
32
|
+
sourceType: "module"
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
)
|
|
@@ -39,16 +43,16 @@ import {
|
|
|
39
43
|
`,
|
|
40
44
|
errors: [
|
|
41
45
|
{
|
|
42
|
-
|
|
43
|
-
type: "ImportDeclaration",
|
|
46
|
+
column: 4,
|
|
44
47
|
line: 3,
|
|
45
|
-
|
|
48
|
+
messageId: "imports",
|
|
49
|
+
type: "ImportDeclaration"
|
|
46
50
|
},
|
|
47
51
|
{
|
|
48
|
-
|
|
49
|
-
type: "ImportDeclaration",
|
|
52
|
+
column: 7,
|
|
50
53
|
line: 4,
|
|
51
|
-
|
|
54
|
+
messageId: "imports",
|
|
55
|
+
type: "ImportDeclaration"
|
|
52
56
|
}
|
|
53
57
|
],
|
|
54
58
|
options: [
|
|
@@ -67,9 +71,11 @@ import {
|
|
|
67
71
|
lll
|
|
68
72
|
} from 'module/2';
|
|
69
73
|
`,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
languageOptions: {
|
|
75
|
+
parserOptions: {
|
|
76
|
+
ecmaVersion: "latest",
|
|
77
|
+
sourceType: "module"
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
80
|
},
|
|
75
81
|
{
|
|
@@ -80,16 +86,16 @@ import {
|
|
|
80
86
|
`,
|
|
81
87
|
errors: [
|
|
82
88
|
{
|
|
83
|
-
|
|
84
|
-
type: "ImportDeclaration",
|
|
89
|
+
column: 4,
|
|
85
90
|
line: 3,
|
|
86
|
-
|
|
91
|
+
messageId: "imports",
|
|
92
|
+
type: "ImportDeclaration"
|
|
87
93
|
},
|
|
88
94
|
{
|
|
89
|
-
|
|
90
|
-
type: "ImportDeclaration",
|
|
95
|
+
column: 7,
|
|
91
96
|
line: 4,
|
|
92
|
-
|
|
97
|
+
messageId: "imports",
|
|
98
|
+
type: "ImportDeclaration"
|
|
93
99
|
}
|
|
94
100
|
],
|
|
95
101
|
options: [
|
|
@@ -108,9 +114,11 @@ import {
|
|
|
108
114
|
lll
|
|
109
115
|
} from 'module/2'
|
|
110
116
|
`,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
languageOptions: {
|
|
118
|
+
parserOptions: {
|
|
119
|
+
ecmaVersion: "latest",
|
|
120
|
+
sourceType: "module"
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
)
|
package/test/pretty-imports.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict"
|
|
2
|
-
|
|
2
|
+
const { RuleTester } = require("eslint")
|
|
3
3
|
|
|
4
4
|
/** @type {RuleTester.ValidTestCase[]} */
|
|
5
|
-
|
|
5
|
+
const valid = []
|
|
6
6
|
/** @type {RuleTester.InvalidTestCase[]} */
|
|
7
|
-
|
|
7
|
+
const invalid = []
|
|
8
8
|
|
|
9
9
|
require(
|
|
10
10
|
"./pretty-imports/ExportNamedDeclaration"
|