eslint-plugin-lube 0.4.3 → 0.5.0
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 +125 -125
- package/package.json +37 -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 +15 -15
- package/test/pretty-imports/ExportNamedDeclaration.js +20 -12
- package/test/pretty-imports/ImportDeclaration.js +20 -12
- package/test/pretty-imports.js +3 -3
- package/test/pretty-jsdoc-casting/case_by_expression.js +13 -5
- package/test/pretty-jsdoc-casting/various_situations.js +6 -2
- package/test/pretty-jsdoc-casting.js +3 -3
- package/test/pretty-sequence/case_by_node_type.js +18 -6
- package/test/pretty-sequence/case_by_option.js +24 -8
- package/test/pretty-sequence/various_situations.js +23 -9
- package/test/pretty-sequence.js +3 -3
- package/test/svelte-naming-convention/case_by_identifier.js +95 -45
- package/test/svelte-naming-convention.js +3 -3
- package/tsconfig.json +3 -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
|
}
|
|
@@ -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
|
)
|
|
@@ -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
|
{
|
|
@@ -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
|
)
|
|
@@ -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
|
{
|
|
@@ -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"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param {string} value
|
|
4
4
|
* @returns {import("eslint").RuleTester.InvalidTestCase}
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const test_case = (type, value) => ({
|
|
7
7
|
code: `
|
|
8
8
|
var value = /** @type {A} */(${value})
|
|
9
9
|
var value = /** @type {B} */(${value}) // comment...
|
|
@@ -29,7 +29,9 @@ let test_case = (type, value) => ({
|
|
|
29
29
|
var value = /** @type {D} */((${value}))/**/
|
|
30
30
|
var value = ((/** @type {E} */(${value})/**/))
|
|
31
31
|
`,
|
|
32
|
-
|
|
32
|
+
languageOptions: {
|
|
33
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
34
|
+
}
|
|
33
35
|
})
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -94,7 +96,9 @@ exports.module = (valid, invalid) => {
|
|
|
94
96
|
((/** @type {E} */(await b)/**/));
|
|
95
97
|
}
|
|
96
98
|
`,
|
|
97
|
-
|
|
99
|
+
languageOptions: {
|
|
100
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
101
|
+
}
|
|
98
102
|
},
|
|
99
103
|
test_case("BinaryExpression", "a / b"),
|
|
100
104
|
test_case("CallExpression", "a(b, c)"),
|
|
@@ -169,7 +173,9 @@ exports.module = (valid, invalid) => {
|
|
|
169
173
|
((/** @type {E} */(new.target)/**/));
|
|
170
174
|
}
|
|
171
175
|
`,
|
|
172
|
-
|
|
176
|
+
languageOptions: {
|
|
177
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
178
|
+
}
|
|
173
179
|
},
|
|
174
180
|
test_case("NewExpression", "new a(b, c)"),
|
|
175
181
|
test_case(
|
|
@@ -235,7 +241,9 @@ exports.module = (valid, invalid) => {
|
|
|
235
241
|
((/** @type {E} */(yield b)/**/));
|
|
236
242
|
}
|
|
237
243
|
`,
|
|
238
|
-
|
|
244
|
+
languageOptions: {
|
|
245
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
246
|
+
}
|
|
239
247
|
}
|
|
240
248
|
)
|
|
241
249
|
}
|
|
@@ -37,7 +37,9 @@ exports.module = (valid, invalid) => {
|
|
|
37
37
|
.../** @type {X} */(x)/**/
|
|
38
38
|
})/**/;
|
|
39
39
|
/** @type {Y} */(y, /** @type {Z} */(z[/** @type {123} */(123)/**/])/**/)/**/`,
|
|
40
|
-
|
|
40
|
+
languageOptions: {
|
|
41
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
)
|
|
43
45
|
invalid.push(
|
|
@@ -85,7 +87,9 @@ exports.module = (valid, invalid) => {
|
|
|
85
87
|
.../** @type {X} */(x)/**/
|
|
86
88
|
})/**/;
|
|
87
89
|
/** @type {Y} */(y, /** @type {Z} */(z[/** @type {123} */(123)/**/])/**/)/**/`,
|
|
88
|
-
|
|
90
|
+
languageOptions: {
|
|
91
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
94
|
)
|
|
91
95
|
}
|
|
@@ -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-jsdoc-casting/case_by_expression"
|
|
@@ -59,7 +59,9 @@ exports.module = (valid, invalid) => {
|
|
|
59
59
|
] = value
|
|
60
60
|
var [] = value
|
|
61
61
|
`,
|
|
62
|
-
|
|
62
|
+
languageOptions: {
|
|
63
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
64
|
+
}
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
67
|
code: `
|
|
@@ -102,7 +104,9 @@ exports.module = (valid, invalid) => {
|
|
|
102
104
|
var value = async a => b
|
|
103
105
|
var value = async (a, b, c) => {}
|
|
104
106
|
`,
|
|
105
|
-
|
|
107
|
+
languageOptions: {
|
|
108
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
109
|
+
}
|
|
106
110
|
},
|
|
107
111
|
{
|
|
108
112
|
code: `
|
|
@@ -141,7 +145,9 @@ exports.module = (valid, invalid) => {
|
|
|
141
145
|
function func() {}
|
|
142
146
|
async function func() {}
|
|
143
147
|
`,
|
|
144
|
-
|
|
148
|
+
languageOptions: {
|
|
149
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
150
|
+
}
|
|
145
151
|
},
|
|
146
152
|
{
|
|
147
153
|
code: `
|
|
@@ -180,7 +186,9 @@ exports.module = (valid, invalid) => {
|
|
|
180
186
|
var value = function () {}
|
|
181
187
|
var value = async function () {}
|
|
182
188
|
`,
|
|
183
|
-
|
|
189
|
+
languageOptions: {
|
|
190
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
191
|
+
}
|
|
184
192
|
},
|
|
185
193
|
{
|
|
186
194
|
code: `
|
|
@@ -265,7 +273,9 @@ exports.module = (valid, invalid) => {
|
|
|
265
273
|
}
|
|
266
274
|
var value = {}
|
|
267
275
|
`,
|
|
268
|
-
|
|
276
|
+
languageOptions: {
|
|
277
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
278
|
+
}
|
|
269
279
|
},
|
|
270
280
|
{
|
|
271
281
|
code: `
|
|
@@ -294,7 +304,9 @@ exports.module = (valid, invalid) => {
|
|
|
294
304
|
} = value
|
|
295
305
|
var {} = value
|
|
296
306
|
`,
|
|
297
|
-
|
|
307
|
+
languageOptions: {
|
|
308
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
309
|
+
}
|
|
298
310
|
},
|
|
299
311
|
{
|
|
300
312
|
code: `
|