eslint-plugin-lube 0.3.3 → 0.3.5
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/README.md +3 -2
- package/docs/pretty-jsdoc-casting.md +2 -2
- package/index.js +113 -22
- package/package.json +1 -1
- package/rules/pretty-imports.js +30 -28
- package/rules/pretty-jsdoc-casting.js +6 -6
- package/rules/svelte-naming-convention.js +13 -12
- package/test/pretty-imports/ExportNamedDeclaration.js +13 -9
- package/test/pretty-imports/ImportDeclaration.js +13 -9
- package/test/pretty-imports.js +1 -1
- package/test/pretty-jsdoc-casting/case_by_expression.js +3 -3
- package/test/pretty-jsdoc-casting/nested_casting.js +25 -17
- package/test/pretty-jsdoc-casting.js +1 -1
- package/test/svelte-naming-convention/basic_snake_case.js +21 -15
- package/test/svelte-naming-convention/case_by_identifier.js +57 -41
- package/test/svelte-naming-convention/snake_case_with_symbols.js +27 -19
- package/test/svelte-naming-convention.js +1 -1
package/README.md
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
| Rule | Docs | Code | Test |
|
|
4
4
|
|---|---|---|---|
|
|
5
|
-
|
|
|
6
|
-
| pretty-
|
|
5
|
+
| pretty-imports | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/pretty-imports.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/pretty-imports.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/pretty-imports) |
|
|
6
|
+
| pretty-jsdoc-casting | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/pretty-jsdoc-casting.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/pretty-jsdoc-casting.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/pretty-jsdoc-casting) |
|
|
7
|
+
| svelte-naming-convention | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/svelte-naming-convention.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/svelte-naming-convention.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/svelte-naming-convention) |
|
package/index.js
CHANGED
|
@@ -9,41 +9,132 @@ module.exports = {
|
|
|
9
9
|
extends: ["eslint:recommended"],
|
|
10
10
|
plugins: ["lube"],
|
|
11
11
|
rules: {
|
|
12
|
-
"
|
|
13
|
-
|
|
12
|
+
"array-bracket-newline": [
|
|
13
|
+
"error", {
|
|
14
|
+
"multiline": true
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"array-element-newline": ["error", "consistent"],
|
|
18
|
+
"arrow-parens": ["error", "as-needed"],
|
|
19
|
+
"arrow-spacing": [
|
|
20
|
+
"error", {
|
|
21
|
+
"before": true,
|
|
22
|
+
"after": true
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"block-spacing": ["error", "always"],
|
|
26
|
+
"brace-style": ["error", "1tbs"],
|
|
27
|
+
"comma-dangle": ["error", "never"],
|
|
28
|
+
"comma-spacing": [
|
|
29
|
+
"error", {
|
|
30
|
+
"before": false,
|
|
31
|
+
"after": true
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"comma-style": ["error", "last"],
|
|
35
|
+
"computed-property-spacing": ["error", "never"],
|
|
14
36
|
"dot-location": ["error", "property"],
|
|
15
|
-
"
|
|
16
|
-
"
|
|
37
|
+
"eol-last": ["error", "never"],
|
|
38
|
+
"func-call-spacing": ["error", "never"],
|
|
39
|
+
"function-call-argument-newline": ["error", "consistent"],
|
|
40
|
+
"generator-star-spacing": ["error", "after"],
|
|
17
41
|
"indent": ["error", "tab"],
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
42
|
+
"jsx-quotes": ["error", "prefer-double"],
|
|
43
|
+
"key-spacing": [
|
|
44
|
+
"error", {
|
|
45
|
+
"afterColon": true,
|
|
46
|
+
"beforeColon": false
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"keyword-spacing": [
|
|
50
|
+
"error", {
|
|
51
|
+
"after": true,
|
|
52
|
+
"before": true
|
|
53
|
+
}
|
|
54
|
+
],
|
|
22
55
|
"max-len": ["warn", 120],
|
|
23
56
|
"max-nested-callbacks": ["error", 3],
|
|
57
|
+
"max-statements-per-line": [
|
|
58
|
+
"error", {
|
|
59
|
+
"max": 1
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"multiline-ternary": ["error", "always-multiline"],
|
|
63
|
+
"newline-per-chained-call": [
|
|
64
|
+
"error", {
|
|
65
|
+
"ignoreChainWithDepth": 2
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"no-await-in-loop": "warn",
|
|
24
69
|
"no-console": "warn",
|
|
25
70
|
"no-duplicate-imports": "error",
|
|
26
|
-
"no-
|
|
71
|
+
"no-lonely-if": "error",
|
|
27
72
|
"no-multi-spaces": "error",
|
|
73
|
+
"no-new-native-nonconstructor": "error",
|
|
74
|
+
"no-self-compare": "error",
|
|
75
|
+
"no-shadow": "error",
|
|
76
|
+
"no-shadow-restricted-names": "error",
|
|
77
|
+
"no-trailing-spaces": [
|
|
78
|
+
"error", {
|
|
79
|
+
"ignoreComments": false,
|
|
80
|
+
"skipBlankLines": false
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"object-curly-newline": [
|
|
84
|
+
"error", {
|
|
85
|
+
"consistent": true
|
|
86
|
+
}
|
|
87
|
+
],
|
|
28
88
|
"object-curly-spacing": ["error", "always"],
|
|
29
|
-
"
|
|
89
|
+
"operator-linebreak": ["error", "before"],
|
|
90
|
+
"prefer-const": [
|
|
91
|
+
"warn", {
|
|
92
|
+
"destructuring": "all",
|
|
93
|
+
"ignoreReadBeforeAssign": false
|
|
94
|
+
}
|
|
95
|
+
],
|
|
30
96
|
"quotes": ["error", "double"],
|
|
97
|
+
"rest-spread-spacing": ["error", "never"],
|
|
31
98
|
"semi": ["error", "never"],
|
|
32
|
-
"semi-spacing": [
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
99
|
+
"semi-spacing": [
|
|
100
|
+
"error", {
|
|
101
|
+
"after": true,
|
|
102
|
+
"before": false
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"semi-style": ["error", "first"],
|
|
106
|
+
"space-before-blocks": ["error", "always"],
|
|
107
|
+
"space-before-function-paren": [
|
|
108
|
+
"error", {
|
|
109
|
+
"anonymous": "never",
|
|
110
|
+
"asyncArrow": "always",
|
|
111
|
+
"named": "never"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
41
114
|
"space-in-parens": ["error", "never"],
|
|
42
|
-
"space-infix-ops":
|
|
43
|
-
|
|
115
|
+
"space-infix-ops": [
|
|
116
|
+
"error", {
|
|
117
|
+
"int32Hint": true
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"space-unary-ops": [
|
|
121
|
+
"error", {
|
|
122
|
+
"words": true,
|
|
123
|
+
"nonwords": false
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"switch-colon-spacing": [
|
|
127
|
+
"error", {
|
|
128
|
+
"after": true,
|
|
129
|
+
"before": false
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"template-curly-spacing": ["error", "never"],
|
|
133
|
+
"template-tag-spacing": ["error", "never"],
|
|
134
|
+
"yield-star-spacing": ["error", "after"],
|
|
44
135
|
"lube/pretty-imports": "error",
|
|
45
136
|
"lube/pretty-jsdoc-casting": "error",
|
|
46
|
-
"lube/svelte-naming-convention": "error"
|
|
137
|
+
"lube/svelte-naming-convention": "error"
|
|
47
138
|
}
|
|
48
139
|
}
|
|
49
140
|
},
|
package/package.json
CHANGED
package/rules/pretty-imports.js
CHANGED
|
@@ -12,31 +12,33 @@ module.exports = {
|
|
|
12
12
|
exports: "This exports is not pretty",
|
|
13
13
|
imports: "This imports is not pretty"
|
|
14
14
|
},
|
|
15
|
-
schema: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
schema: [
|
|
16
|
+
{
|
|
17
|
+
properties: {
|
|
18
|
+
checkExports: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: true
|
|
21
|
+
},
|
|
22
|
+
checkImports: {
|
|
23
|
+
type: "boolean",
|
|
24
|
+
default: true
|
|
25
|
+
},
|
|
26
|
+
indent: {
|
|
27
|
+
type: "string",
|
|
28
|
+
default: "\t"
|
|
29
|
+
},
|
|
30
|
+
maxLength: {
|
|
31
|
+
type: "number",
|
|
32
|
+
default: 30
|
|
33
|
+
},
|
|
34
|
+
semicolon: {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
default: false
|
|
37
|
+
}
|
|
32
38
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
type: "object"
|
|
39
|
-
}],
|
|
39
|
+
type: "object"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
40
42
|
type: "layout"
|
|
41
43
|
},
|
|
42
44
|
create(context) {
|
|
@@ -110,12 +112,12 @@ module.exports = {
|
|
|
110
112
|
}
|
|
111
113
|
let corrected_text = length > max_length
|
|
112
114
|
? `export {\n${line_indent + indent}${
|
|
113
|
-
|
|
115
|
+
|
|
114
116
|
/** @type {import("../private").AstNode[]} */(node.specifiers)/**/.map(get_text)
|
|
115
117
|
.join(",\n" + line_indent + indent)
|
|
116
118
|
}\n${line_indent}}`
|
|
117
119
|
: `export { ${
|
|
118
|
-
|
|
120
|
+
|
|
119
121
|
/** @type {import("../private").AstNode[]} */(node.specifiers)/**/.map(get_text).join(", ")
|
|
120
122
|
} }`
|
|
121
123
|
if (node.source) {
|
|
@@ -140,12 +142,12 @@ module.exports = {
|
|
|
140
142
|
}
|
|
141
143
|
let corrected_text = length > max_length
|
|
142
144
|
? `import {\n${line_indent + indent}${
|
|
143
|
-
|
|
145
|
+
|
|
144
146
|
/** @type {import("../private").AstNode[]} */(node.specifiers)/**/.map(get_text)
|
|
145
147
|
.join(",\n" + line_indent + indent)
|
|
146
148
|
}\n${line_indent}} from ${node.source.raw}`
|
|
147
149
|
: `import { ${
|
|
148
|
-
|
|
150
|
+
|
|
149
151
|
/** @type {import("../private").AstNode[]} */(node.specifiers)/**/.map(get_text).join(", ")
|
|
150
152
|
} } from ${node.source.raw}`
|
|
151
153
|
if (semicolon) {
|
|
@@ -88,18 +88,18 @@ module.exports = {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
} else {
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
left -=
|
|
91
|
+
const left_space = left_space_regex.exec(origin_text.slice(0, left))?.[0].length
|
|
92
|
+
if (left_space) {
|
|
93
|
+
left -= left_space
|
|
94
94
|
} else if (origin_text[left - 1] == "(") {
|
|
95
95
|
while (right < text_length) {
|
|
96
96
|
if (comments[right]) {
|
|
97
97
|
const comment = comments[right]
|
|
98
98
|
right = comment.range[1]
|
|
99
99
|
} else {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
right +=
|
|
100
|
+
const right_space = right_space_regex.exec(origin_text.slice(right))?.[0].length
|
|
101
|
+
if (right_space) {
|
|
102
|
+
right += right_space
|
|
103
103
|
} else {
|
|
104
104
|
if (origin_text[right] == ")") {
|
|
105
105
|
prev_open = left--
|
|
@@ -11,15 +11,17 @@ module.exports = {
|
|
|
11
11
|
messages: {
|
|
12
12
|
not_match: "Identifier '{{name}}' does not match for svelte's naming conventions."
|
|
13
13
|
},
|
|
14
|
-
schema: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
schema: [
|
|
15
|
+
{
|
|
16
|
+
properties: {
|
|
17
|
+
fixSameNames: {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
default: true
|
|
20
|
+
}
|
|
19
21
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
type: "object"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
23
25
|
type: "layout"
|
|
24
26
|
},
|
|
25
27
|
create(context) {
|
|
@@ -199,7 +201,7 @@ module.exports = {
|
|
|
199
201
|
break
|
|
200
202
|
case "FunctionDeclaration":
|
|
201
203
|
// function camelCase() {}
|
|
202
|
-
if (
|
|
204
|
+
if (
|
|
203
205
|
parent.parent?.type != "ExportNamedDeclaration"
|
|
204
206
|
|| !camel_case_regex.test(name)
|
|
205
207
|
) {
|
|
@@ -240,8 +242,7 @@ module.exports = {
|
|
|
240
242
|
// object.property
|
|
241
243
|
if (parent.object == node) {
|
|
242
244
|
defer(node)
|
|
243
|
-
}
|
|
244
|
-
else if (parent.computed) {
|
|
245
|
+
} else if (parent.computed) {
|
|
245
246
|
// object[camelCase]
|
|
246
247
|
// camelCase[key]
|
|
247
248
|
defer(node)
|
|
@@ -327,7 +328,7 @@ module.exports = {
|
|
|
327
328
|
case "VariableDeclarator":
|
|
328
329
|
// var id = init
|
|
329
330
|
if (parent.id == node) {
|
|
330
|
-
if (
|
|
331
|
+
if (
|
|
331
332
|
parent.parent?.parent?.type != "ExportNamedDeclaration"
|
|
332
333
|
|| !camel_case_regex.test(name)
|
|
333
334
|
) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
2
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
3
3
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
4
4
|
*/
|
|
5
5
|
exports.module = (valid, invalid) => {
|
|
@@ -49,10 +49,12 @@ exports.module = (valid, invalid) => {
|
|
|
49
49
|
column: 7
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
|
-
options: [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
options: [
|
|
53
|
+
{
|
|
54
|
+
maxLength: 10,
|
|
55
|
+
semicolon: true
|
|
56
|
+
}
|
|
57
|
+
],
|
|
56
58
|
output: `
|
|
57
59
|
|
|
58
60
|
export { a, b as c, d } from 'module';
|
|
@@ -91,10 +93,12 @@ exports.module = (valid, invalid) => {
|
|
|
91
93
|
column: 7
|
|
92
94
|
}
|
|
93
95
|
],
|
|
94
|
-
options: [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
options: [
|
|
97
|
+
{
|
|
98
|
+
indent: " ",
|
|
99
|
+
maxLength: 10
|
|
100
|
+
}
|
|
101
|
+
],
|
|
98
102
|
output: `
|
|
99
103
|
|
|
100
104
|
export { a, b as c, d } from 'module'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
2
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
3
3
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
4
4
|
*/
|
|
5
5
|
exports.module = (valid, invalid) => {
|
|
@@ -51,10 +51,12 @@ import {
|
|
|
51
51
|
column: 7
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
|
-
options: [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
options: [
|
|
55
|
+
{
|
|
56
|
+
maxLength: 10,
|
|
57
|
+
semicolon: true
|
|
58
|
+
}
|
|
59
|
+
],
|
|
58
60
|
output: `
|
|
59
61
|
|
|
60
62
|
import { a, b as c, d } from 'module';
|
|
@@ -93,10 +95,12 @@ import {
|
|
|
93
95
|
column: 7
|
|
94
96
|
}
|
|
95
97
|
],
|
|
96
|
-
options: [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
options: [
|
|
99
|
+
{
|
|
100
|
+
indent: " ",
|
|
101
|
+
maxLength: 10
|
|
102
|
+
}
|
|
103
|
+
],
|
|
100
104
|
output: `
|
|
101
105
|
|
|
102
106
|
import { a, b as c, d } from 'module'
|
package/test/pretty-imports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {keyof import("estree").ExpressionMap} type
|
|
3
|
-
* @param {string} value
|
|
2
|
+
* @param {keyof import("estree").ExpressionMap} type
|
|
3
|
+
* @param {string} value
|
|
4
4
|
* @returns {import("eslint").RuleTester.InvalidTestCase}
|
|
5
5
|
*/
|
|
6
6
|
const test_case = (type, value) => ({
|
|
@@ -53,7 +53,7 @@ const test_case = (type, value) => ({
|
|
|
53
53
|
})
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
56
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
57
57
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
58
58
|
*/
|
|
59
59
|
exports.module = (valid, invalid) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
2
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
3
3
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
4
4
|
*/
|
|
5
5
|
exports.module = (valid, invalid) => {
|
|
@@ -45,34 +45,42 @@ exports.module = (valid, invalid) => {
|
|
|
45
45
|
invalid.push(
|
|
46
46
|
{
|
|
47
47
|
code: "var v = /**@type {A}*/(a)/**/",
|
|
48
|
-
errors: [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
errors: [
|
|
49
|
+
{
|
|
50
|
+
column: 8,
|
|
51
|
+
line: 1
|
|
52
|
+
}
|
|
53
|
+
],
|
|
52
54
|
output: "var v = /** @type {A} */(a)/**/"
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
code: "var v = /** @type {A} */( /** @type {B} */(/** @type {C} */((a) /* block... */))) // line...",
|
|
56
|
-
errors: [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
errors: [
|
|
59
|
+
{
|
|
60
|
+
column: 8,
|
|
61
|
+
line: 1
|
|
62
|
+
}
|
|
63
|
+
],
|
|
60
64
|
output: "var v = /** @type {A} */(/** @type {B} */(/** @type {C} */((a))/**/)/**/)/**/ /* block... */ // line..."
|
|
61
65
|
},
|
|
62
66
|
{
|
|
63
67
|
code: "var v = { b: /** @type {A} */(a) }",
|
|
64
|
-
errors: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
errors: [
|
|
69
|
+
{
|
|
70
|
+
column: 13,
|
|
71
|
+
line: 1
|
|
72
|
+
}
|
|
73
|
+
],
|
|
68
74
|
output: "var v = { b: /** @type {A} */(a)/**/ }"
|
|
69
75
|
},
|
|
70
76
|
{
|
|
71
77
|
code: "var v = { b: /** @type {A} */(a) }",
|
|
72
|
-
errors: [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
errors: [
|
|
79
|
+
{
|
|
80
|
+
column: 13,
|
|
81
|
+
line: 1
|
|
82
|
+
}
|
|
83
|
+
],
|
|
76
84
|
output: "var v = { b: /** @type {A} */(a)/**/ }"
|
|
77
85
|
},
|
|
78
86
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
2
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
3
3
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
4
4
|
*/
|
|
5
5
|
exports.module = (valid, invalid) => {
|
|
@@ -14,32 +14,38 @@ exports.module = (valid, invalid) => {
|
|
|
14
14
|
{ code: "camelCase = 'Hello'" },
|
|
15
15
|
{ code: "var snake_case = camelCase" },
|
|
16
16
|
{ code: "var PascalCase = 'Hello'" },
|
|
17
|
-
{ code: "var P1ascal2Case345 = 'Hello'" }
|
|
17
|
+
{ code: "var P1ascal2Case345 = 'Hello'" }
|
|
18
18
|
)
|
|
19
19
|
invalid.push(
|
|
20
20
|
{
|
|
21
21
|
code: "var camelCase = 'Hello'",
|
|
22
|
-
errors: [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
errors: [
|
|
23
|
+
{
|
|
24
|
+
line: 1,
|
|
25
|
+
column: 5
|
|
26
|
+
}
|
|
27
|
+
],
|
|
26
28
|
output: "var camel_case = 'Hello'"
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
code: "var NO_SNAKE__CASE = 'Hello'",
|
|
30
|
-
errors: [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
errors: [
|
|
33
|
+
{
|
|
34
|
+
line: 1,
|
|
35
|
+
column: 5
|
|
36
|
+
}
|
|
37
|
+
],
|
|
34
38
|
output: "var NO_SNAKE__CASE = 'Hello'"
|
|
35
39
|
},
|
|
36
40
|
{
|
|
37
41
|
code: "var NO_SNAKE_CASE_ = 'Hello'",
|
|
38
|
-
errors: [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
errors: [
|
|
43
|
+
{
|
|
44
|
+
line: 1,
|
|
45
|
+
column: 5
|
|
46
|
+
}
|
|
47
|
+
],
|
|
42
48
|
output: "var NO_SNAKE_CASE_ = 'Hello'"
|
|
43
|
-
}
|
|
49
|
+
}
|
|
44
50
|
)
|
|
45
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
2
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
3
3
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
4
4
|
*/
|
|
5
5
|
exports.module = (valid, invalid) => {
|
|
@@ -36,20 +36,24 @@ exports.module = (valid, invalid) => {
|
|
|
36
36
|
// ArrayPattern
|
|
37
37
|
{
|
|
38
38
|
code: "var [ camelCase ] = value",
|
|
39
|
-
errors: [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
errors: [
|
|
40
|
+
{
|
|
41
|
+
line: 1,
|
|
42
|
+
column: 7
|
|
43
|
+
}
|
|
44
|
+
],
|
|
43
45
|
output: "var [ camel_case ] = value",
|
|
44
46
|
parserOptions: { ecmaVersion: "latest" }
|
|
45
47
|
},
|
|
46
48
|
// ArrowFunctionExpression
|
|
47
49
|
{
|
|
48
50
|
code: "(camelCase) => {}",
|
|
49
|
-
errors: [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
errors: [
|
|
52
|
+
{
|
|
53
|
+
line: 1,
|
|
54
|
+
column: 2
|
|
55
|
+
}
|
|
56
|
+
],
|
|
53
57
|
output: "(camel_case) => {}",
|
|
54
58
|
parserOptions: { ecmaVersion: "latest" }
|
|
55
59
|
},
|
|
@@ -237,10 +241,12 @@ exports.module = (valid, invalid) => {
|
|
|
237
241
|
// ClassDeclaration
|
|
238
242
|
{
|
|
239
243
|
code: "class camelCase {}",
|
|
240
|
-
errors: [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
errors: [
|
|
245
|
+
{
|
|
246
|
+
line: 1,
|
|
247
|
+
column: 7
|
|
248
|
+
}
|
|
249
|
+
],
|
|
244
250
|
output: "class camel_case {}",
|
|
245
251
|
parserOptions: { ecmaVersion: "latest" }
|
|
246
252
|
},
|
|
@@ -291,10 +297,12 @@ exports.module = (valid, invalid) => {
|
|
|
291
297
|
export * as camelCase from "module"
|
|
292
298
|
var camelCase
|
|
293
299
|
`,
|
|
294
|
-
errors: [
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
errors: [
|
|
301
|
+
{
|
|
302
|
+
line: 3,
|
|
303
|
+
column: 8
|
|
304
|
+
}
|
|
305
|
+
],
|
|
298
306
|
output: `
|
|
299
307
|
export * as camelCase from "module"
|
|
300
308
|
var camel_case
|
|
@@ -310,10 +318,12 @@ exports.module = (valid, invalid) => {
|
|
|
310
318
|
export default camelCase
|
|
311
319
|
var camelCase
|
|
312
320
|
`,
|
|
313
|
-
errors: [
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
321
|
+
errors: [
|
|
322
|
+
{
|
|
323
|
+
line: 3,
|
|
324
|
+
column: 8
|
|
325
|
+
}
|
|
326
|
+
],
|
|
317
327
|
options: [{ fixSameNames: false }],
|
|
318
328
|
output: `
|
|
319
329
|
export default camelCase
|
|
@@ -337,7 +347,7 @@ exports.module = (valid, invalid) => {
|
|
|
337
347
|
{
|
|
338
348
|
line: 3,
|
|
339
349
|
column: 8
|
|
340
|
-
}
|
|
350
|
+
}
|
|
341
351
|
],
|
|
342
352
|
output: `
|
|
343
353
|
export default camel_case
|
|
@@ -362,7 +372,7 @@ exports.module = (valid, invalid) => {
|
|
|
362
372
|
{
|
|
363
373
|
line: 3,
|
|
364
374
|
column: 19
|
|
365
|
-
}
|
|
375
|
+
}
|
|
366
376
|
],
|
|
367
377
|
output: `
|
|
368
378
|
export { default as camelCase, camelCase2 } from 'module'
|
|
@@ -549,10 +559,12 @@ exports.module = (valid, invalid) => {
|
|
|
549
559
|
// ImportDefaultSpecifier
|
|
550
560
|
{
|
|
551
561
|
code: "import camelCase from 'module'",
|
|
552
|
-
errors: [
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
562
|
+
errors: [
|
|
563
|
+
{
|
|
564
|
+
line: 1,
|
|
565
|
+
column: 8
|
|
566
|
+
}
|
|
567
|
+
],
|
|
556
568
|
output: "import camel_case from 'module'",
|
|
557
569
|
parserOptions: {
|
|
558
570
|
ecmaVersion: "latest",
|
|
@@ -562,10 +574,12 @@ exports.module = (valid, invalid) => {
|
|
|
562
574
|
// ImportNamespaceSpecifier
|
|
563
575
|
{
|
|
564
576
|
code: "import * as camelCase from 'module'",
|
|
565
|
-
errors: [
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
577
|
+
errors: [
|
|
578
|
+
{
|
|
579
|
+
line: 1,
|
|
580
|
+
column: 13
|
|
581
|
+
}
|
|
582
|
+
],
|
|
569
583
|
output: "import * as camel_case from 'module'",
|
|
570
584
|
parserOptions: {
|
|
571
585
|
ecmaVersion: "latest",
|
|
@@ -696,10 +710,12 @@ exports.module = (valid, invalid) => {
|
|
|
696
710
|
class ObjectB { camelCase() {} }
|
|
697
711
|
var camelCase
|
|
698
712
|
`,
|
|
699
|
-
errors: [
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
713
|
+
errors: [
|
|
714
|
+
{
|
|
715
|
+
line: 3,
|
|
716
|
+
column: 8
|
|
717
|
+
}
|
|
718
|
+
],
|
|
703
719
|
output: `
|
|
704
720
|
class ObjectB { camelCase() {} }
|
|
705
721
|
var camel_case
|
|
@@ -721,7 +737,7 @@ exports.module = (valid, invalid) => {
|
|
|
721
737
|
},
|
|
722
738
|
{
|
|
723
739
|
line: 4,
|
|
724
|
-
column:8
|
|
740
|
+
column: 8
|
|
725
741
|
},
|
|
726
742
|
{
|
|
727
743
|
line: 5,
|
|
@@ -751,7 +767,7 @@ exports.module = (valid, invalid) => {
|
|
|
751
767
|
},
|
|
752
768
|
{
|
|
753
769
|
line: 4,
|
|
754
|
-
column:8
|
|
770
|
+
column: 8
|
|
755
771
|
},
|
|
756
772
|
{
|
|
757
773
|
line: 5,
|
|
@@ -930,7 +946,7 @@ exports.module = (valid, invalid) => {
|
|
|
930
946
|
},
|
|
931
947
|
{
|
|
932
948
|
line: 4,
|
|
933
|
-
column:8
|
|
949
|
+
column: 8
|
|
934
950
|
},
|
|
935
951
|
{
|
|
936
952
|
line: 5,
|
|
@@ -959,7 +975,7 @@ exports.module = (valid, invalid) => {
|
|
|
959
975
|
},
|
|
960
976
|
{
|
|
961
977
|
line: 4,
|
|
962
|
-
column:8
|
|
978
|
+
column: 8
|
|
963
979
|
},
|
|
964
980
|
{
|
|
965
981
|
line: 5,
|
|
@@ -988,7 +1004,7 @@ exports.module = (valid, invalid) => {
|
|
|
988
1004
|
},
|
|
989
1005
|
{
|
|
990
1006
|
line: 4,
|
|
991
|
-
column:8
|
|
1007
|
+
column: 8
|
|
992
1008
|
},
|
|
993
1009
|
{
|
|
994
1010
|
line: 5,
|
|
@@ -1222,6 +1238,6 @@ exports.module = (valid, invalid) => {
|
|
|
1222
1238
|
function* func_c() { yield pending_a }
|
|
1223
1239
|
`,
|
|
1224
1240
|
parserOptions: { ecmaVersion: "latest" }
|
|
1225
|
-
}
|
|
1241
|
+
}
|
|
1226
1242
|
)
|
|
1227
1243
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
2
|
+
* @param {import("eslint").RuleTester.ValidTestCase[]} valid
|
|
3
3
|
* @param {import("eslint").RuleTester.InvalidTestCase[]} invalid
|
|
4
4
|
*/
|
|
5
5
|
exports.module = (valid, invalid) => {
|
|
@@ -11,40 +11,48 @@ exports.module = (valid, invalid) => {
|
|
|
11
11
|
{ code: "var $$ = 'Hello'" },
|
|
12
12
|
{ code: "var $snake_case$ = 'Hello'" },
|
|
13
13
|
{ code: "var __snake_case$$ = 'Hello'" },
|
|
14
|
-
{ code: "var $$snake_case$$ = 'Hello'" }
|
|
14
|
+
{ code: "var $$snake_case$$ = 'Hello'" }
|
|
15
15
|
)
|
|
16
16
|
invalid.push(
|
|
17
17
|
{
|
|
18
18
|
code: "var __camelCase$$ = 'Hello'",
|
|
19
|
-
errors: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
errors: [
|
|
20
|
+
{
|
|
21
|
+
line: 1,
|
|
22
|
+
column: 5
|
|
23
|
+
}
|
|
24
|
+
],
|
|
23
25
|
output: "var __camel_case$$ = 'Hello'"
|
|
24
26
|
},
|
|
25
27
|
{
|
|
26
28
|
code: "var ___ = 'Hello'",
|
|
27
|
-
errors: [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
errors: [
|
|
30
|
+
{
|
|
31
|
+
line: 1,
|
|
32
|
+
column: 5
|
|
33
|
+
}
|
|
34
|
+
],
|
|
31
35
|
output: "var ___ = 'Hello'"
|
|
32
36
|
},
|
|
33
37
|
{
|
|
34
38
|
code: "var $$$ = 'Hello'",
|
|
35
|
-
errors: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
errors: [
|
|
40
|
+
{
|
|
41
|
+
line: 1,
|
|
42
|
+
column: 5
|
|
43
|
+
}
|
|
44
|
+
],
|
|
39
45
|
output: "var $$$ = 'Hello'"
|
|
40
46
|
},
|
|
41
47
|
{
|
|
42
48
|
code: "var $snake$case$ = 'Hello'",
|
|
43
|
-
errors: [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
errors: [
|
|
50
|
+
{
|
|
51
|
+
line: 1,
|
|
52
|
+
column: 5
|
|
53
|
+
}
|
|
54
|
+
],
|
|
47
55
|
output: "var $snake$case$ = 'Hello'"
|
|
48
|
-
}
|
|
56
|
+
}
|
|
49
57
|
)
|
|
50
58
|
}
|