eslint-plugin-lube 0.5.0 → 0.6.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/CHANGELOG.md +260 -0
- package/LICENSE +21 -0
- package/README.md +120 -9
- package/docs/ascii-order.md +81 -0
- package/docs/pretty-imports.md +70 -59
- package/docs/pretty-jsdoc-casting.md +31 -23
- package/docs/pretty-sequence.md +129 -117
- package/docs/pretty-ternary.md +55 -0
- package/docs/svelte-naming-convention.md +59 -46
- package/package.json +60 -36
- package/src/index.js +299 -0
- package/src/rules/ascii-order.js +940 -0
- package/src/rules/pretty-imports.js +176 -0
- package/src/rules/pretty-jsdoc-casting.js +278 -0
- package/src/rules/pretty-sequence.js +489 -0
- package/src/rules/pretty-ternary.js +227 -0
- package/src/rules/svelte-naming-convention.js +903 -0
- package/src/utils/fix_recorder.js +50 -0
- package/src/utils/keep_comments.js +99 -0
- package/src/utils/keep_line_breaks.js +56 -0
- package/src/utils/skip_hole_commas.js +32 -0
- package/src/utils/skip_optional_patterns.js +27 -0
- package/src/utils/skip_unchanged_fixes.js +35 -0
- package/src/utils/source_text.js +442 -0
- package/src/utils/split_declarations.js +75 -0
- package/src/utils/text_width.js +9 -0
- package/types/index.d.ts +29 -0
- package/types/index.d.ts.map +1 -0
- package/index.js +0 -125
- package/private.d.ts +0 -168
- package/rules/pretty-imports.js +0 -147
- package/rules/pretty-jsdoc-casting.js +0 -236
- package/rules/pretty-sequence.js +0 -441
- package/rules/svelte-naming-convention.js +0 -361
- package/test/pretty-imports/ExportNamedDeclaration.js +0 -123
- package/test/pretty-imports/ImportDeclaration.js +0 -125
- package/test/pretty-imports.js +0 -20
- package/test/pretty-jsdoc-casting/case_by_expression.js +0 -249
- package/test/pretty-jsdoc-casting/various_situations.js +0 -95
- package/test/pretty-jsdoc-casting.js +0 -22
- package/test/pretty-sequence/case_by_node_type.js +0 -340
- package/test/pretty-sequence/case_by_option.js +0 -142
- package/test/pretty-sequence/various_situations.js +0 -193
- package/test/pretty-sequence.js +0 -23
- package/test/svelte-naming-convention/basic_snake_case.js +0 -54
- package/test/svelte-naming-convention/case_by_identifier.js +0 -878
- package/test/svelte-naming-convention/snake_case_with_symbols.js +0 -46
- package/test/svelte-naming-convention.js +0 -25
- package/tsconfig.json +0 -16
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
# pretty-jsdoc-casting
|
|
2
|
-
Enforces
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var v = /** @type {A} */(
|
|
22
|
-
var v =
|
|
23
|
-
var v = { b:
|
|
1
|
+
# pretty-jsdoc-casting
|
|
2
|
+
Enforces an empty comment after a JSDoc type cast, `/** @type {T} */(value)/**/`, so the end of the cast is as visible as its start, and writes the cast on one line without white space inside its parentheses.
|
|
3
|
+
|
|
4
|
+
- TypeScript files, `.ts`, `.tsx`, `.mts` and `.cts`, are not checked, since TypeScript reads no type from a JSDoc cast there.
|
|
5
|
+
- A type comment is a `/**` comment with `@type {T}`. One holding only the type is written as `/** @type {T} */`; any other, such as one spanning lines, is kept as written.
|
|
6
|
+
- Nested castings that end together get one empty comment, after the outermost one.
|
|
7
|
+
- A casting of an inner expression is never moved out of its parentheses.
|
|
8
|
+
- The white space inside the parentheses it removes is dropped, unless a line comment ends there, so a casting written over several lines becomes one line.
|
|
9
|
+
- A casting after `return`, `throw` or `yield` is not checked when a line break stays between the keyword and the expression, such as one ending a line comment inside the parentheses.
|
|
10
|
+
- Parentheses holding the arguments of a call, `new` or `import()` are never read as a casting, even after a type comment: without a semicolon, `/** @type {T} */(a)` on a line of its own calls the expression above it.
|
|
11
|
+
- A casting is not checked when a comment other than a type comment sits between its opening parenthesis and the expression, such as the JSDoc of a function inside the cast, because the fix would move that comment in front of the type comment.
|
|
12
|
+
|
|
13
|
+
## options
|
|
14
|
+
None.
|
|
15
|
+
|
|
16
|
+
## Valid
|
|
17
|
+
```js
|
|
18
|
+
var v = func(
|
|
19
|
+
a
|
|
20
|
+
)
|
|
21
|
+
var v = /** @type {A} */(/** @type {B} */(/** @type {C} */(a)))/**/
|
|
22
|
+
var v = /** @type {A} */(a)/**/()
|
|
23
|
+
var v = { b: /** @type {A} */(a)/**/ }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Invalid
|
|
27
|
+
```js
|
|
28
|
+
var v = /** @type {A} */( /** @type {B} */(/** @type {C} */((a))))
|
|
29
|
+
var v = { b: /** @type {A} */(a) }
|
|
30
|
+
var v = { b: /**@type {A}*/(a)/**/ }
|
|
31
|
+
var v = /** @type {A} */(/** @type {B} */(a)/**/)/**/
|
|
24
32
|
```
|
package/docs/pretty-sequence.md
CHANGED
|
@@ -1,118 +1,130 @@
|
|
|
1
|
-
# pretty-sequence
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
# pretty-sequence
|
|
2
|
+
Formats arrays, objects, parameters and arguments: the items on one line when they fit, or one per line.
|
|
3
|
+
|
|
4
|
+
- Comments are never removed. A line comment after an item stays on the line of that item, and a sequence containing a multiline string, template literal or JSX attribute string that would have to be re-indented is not fixed.
|
|
5
|
+
- TypeScript type annotations and type arguments are supported, and parameters with decorators are not fixed.
|
|
6
|
+
- Items the rule moves to a line of their own are indented one level deeper than the line the sequence opens on, and the closing bracket returns to that line's indentation. Two cases follow `@stylistic/indent` instead: a sequence opening on the first line of a declaration whose last declarator starts on a later line gets one level more, and a line starting with `;`, as `@stylistic/semi-style: first` writes it, counts as indented like its statement.
|
|
7
|
+
- A sequence already written over several lines is left to `@stylistic/indent`, which owns the indentation of lines this rule did not write; `fixIndent` gives that back to this rule.
|
|
8
|
+
|
|
9
|
+
## options
|
|
10
|
+
```js
|
|
11
|
+
schema: [
|
|
12
|
+
{
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties: {
|
|
15
|
+
arrayBracketSpacing: { default: true, type: "boolean" },
|
|
16
|
+
checkArray: { default: true, type: "boolean" },
|
|
17
|
+
checkCall: { default: true, type: "boolean" },
|
|
18
|
+
checkObject: { default: true, type: "boolean" },
|
|
19
|
+
checkSequence: { default: true, type: "boolean" },
|
|
20
|
+
fixIndent: { default: false, type: "boolean" },
|
|
21
|
+
funcCallSpacing: { default: false, type: "boolean" },
|
|
22
|
+
ignoreTemplateLiteral: { default: true, type: "boolean" },
|
|
23
|
+
indent: { default: "\t", type: "string" },
|
|
24
|
+
maxLength: { default: 30, type: "number" },
|
|
25
|
+
objectCurlySpacing: { default: true, type: "boolean" }
|
|
26
|
+
},
|
|
27
|
+
type: "object"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
```
|
|
31
|
+
### arrayBracketSpacing
|
|
32
|
+
If it is `true`, it writes a space inside array brackets: `[ a, b ]`.
|
|
33
|
+
### checkArray
|
|
34
|
+
If it is `true`, it checks arrays and array patterns.
|
|
35
|
+
### checkCall
|
|
36
|
+
If it is `true`, it checks the arguments of calls and `new`, and the parameters of functions.
|
|
37
|
+
### checkObject
|
|
38
|
+
If it is `true`, it checks objects and object patterns.
|
|
39
|
+
### checkSequence
|
|
40
|
+
If it is `true`, it checks sequence expressions, `a, b`.
|
|
41
|
+
### fixIndent
|
|
42
|
+
If it is `true`, it also reports a sequence whose lines differ from this rule only in their indentation. Leave it off while `@stylistic/indent` is on, or the two rules keep rewriting each other's fixes.
|
|
43
|
+
### funcCallSpacing
|
|
44
|
+
If it is `true`, it writes a space inside the parentheses of arguments and parameters: `f( a, b )`.
|
|
45
|
+
### ignoreTemplateLiteral
|
|
46
|
+
If it is `true`, it ignores sequences inside template literals.
|
|
47
|
+
### indent
|
|
48
|
+
The string of one indentation level. Match it to `@stylistic/indent`, or the two rules keep rewriting each other's fixes.
|
|
49
|
+
### maxLength
|
|
50
|
+
The items are written one per line when they are longer than this together, commas and spaces not counted, and on one line when they fit. A character that takes two columns, such as a Korean, Chinese or Japanese one, counts as two, so the number is the width the items take on screen. The default of 30, which the strict config keeps, breaks most calls with more than a couple of arguments; the recommended config sets 80. For another length, set it in the config, and `eslint --fix` rewrites the sequences it now reports both ways:
|
|
51
|
+
```js
|
|
52
|
+
rules: { ...lube.configs.recommended.rules, "lube/pretty-sequence": ["error", { maxLength: 100 }] }
|
|
53
|
+
```
|
|
54
|
+
```js
|
|
55
|
+
// If maxLength is less than or equal to 20, an error occurs.
|
|
56
|
+
var value = { fff, ggg, hhh, iii, jjj, kkk, lll }
|
|
57
|
+
```
|
|
58
|
+
### objectCurlySpacing
|
|
59
|
+
If it is `true`, it writes a space inside object braces: `{ a, b }`.
|
|
60
|
+
|
|
61
|
+
## Valid
|
|
62
|
+
```js
|
|
63
|
+
var value = [ a, b, c ]
|
|
64
|
+
var value = [
|
|
65
|
+
aaaaaaaaaa,
|
|
66
|
+
bbbbbbbbbb,
|
|
67
|
+
cccccccccc,
|
|
68
|
+
dddddddddd
|
|
69
|
+
]
|
|
70
|
+
var value = { a, b, c, d, e }
|
|
71
|
+
var value = {
|
|
72
|
+
aaaaaaaaaa,
|
|
73
|
+
bbbbbbbbbb,
|
|
74
|
+
cccccccccc,
|
|
75
|
+
dddddddddd
|
|
76
|
+
}
|
|
77
|
+
function func(a, b, c) {
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
function func2(
|
|
81
|
+
aaaaaaaaaa,
|
|
82
|
+
bbbbbbbbbb,
|
|
83
|
+
cccccccccc,
|
|
84
|
+
dddddddddd
|
|
85
|
+
) {
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
var value = `${[a,b,c]}`
|
|
89
|
+
|
|
90
|
+
func(
|
|
91
|
+
aaaaaaaaaa_bbbbbbbbbb_cccccccccc
|
|
92
|
+
)
|
|
93
|
+
.a(
|
|
94
|
+
aaaaaaaaaa_bbbbbbbbbb_cccccccccc
|
|
95
|
+
)
|
|
96
|
+
.b(
|
|
97
|
+
aaaaaaaaaa_bbbbbbbbbb_cccccccccc
|
|
98
|
+
)
|
|
99
|
+
.c(
|
|
100
|
+
aaaaaaaaaa_bbbbbbbbbb_cccccccccc
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
var value = {
|
|
104
|
+
a: [ a, b, c ],
|
|
105
|
+
b: true,
|
|
106
|
+
c: {
|
|
107
|
+
aaaaaaaaaa: a,
|
|
108
|
+
bbbbbbbbbb: b,
|
|
109
|
+
c: [
|
|
110
|
+
aaaaaaaaaa,
|
|
111
|
+
bbbbbbbbbbb,
|
|
112
|
+
ccccccccccc
|
|
113
|
+
],
|
|
114
|
+
d: {
|
|
115
|
+
aaaaaaaaaa,
|
|
116
|
+
bbbbbbbbbbb,
|
|
117
|
+
ccccccccccc
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Invalid
|
|
124
|
+
```js
|
|
125
|
+
var value = [a,b,c]
|
|
126
|
+
var value = { aaaaaaaaaa, bbbbbbbbbb, cccccccccc, dddddddddd }
|
|
127
|
+
new Obj(
|
|
128
|
+
|
|
129
|
+
)
|
|
118
130
|
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# pretty-ternary
|
|
2
|
+
Breaks nested and long ternaries, `a ? b : c` and TypeScript conditional types, before `?` and `:`.
|
|
3
|
+
|
|
4
|
+
- A ternary is broken when a branch is another ternary, when it is longer than `maxLength`, or when it already spans lines.
|
|
5
|
+
- A missing line break before `?` or `:` is inserted one level deeper than the line the ternary starts on, and one level deeper again for a ternary in a branch. A ternary inside parentheses is checked on its own.
|
|
6
|
+
- The indentation of a `?` or `:` that already starts a line is left to `@stylistic/indent`, which indents it the same way.
|
|
7
|
+
- Only the spaces around `?` and `:` are fixed, so the operands keep their text and comments. A ternary with a line comment right after `?` or `:` is not fixed.
|
|
8
|
+
|
|
9
|
+
## options
|
|
10
|
+
```js
|
|
11
|
+
schema: [
|
|
12
|
+
{
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties: {
|
|
15
|
+
ignoreTemplateLiteral: { default: true, type: "boolean" },
|
|
16
|
+
indent: { default: "\t", type: "string" },
|
|
17
|
+
maxLength: { default: 80, type: "number" }
|
|
18
|
+
},
|
|
19
|
+
type: "object"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
```
|
|
23
|
+
### ignoreTemplateLiteral
|
|
24
|
+
If it is `true`, it ignores ternaries inside template literals.
|
|
25
|
+
### indent
|
|
26
|
+
The string of one indentation level. Match it to `@stylistic/indent`, or the two rules keep rewriting each other's fixes.
|
|
27
|
+
### maxLength
|
|
28
|
+
A ternary longer than this, counted as if written on one line, is broken over lines. A ternary with a ternary branch is broken at any length.
|
|
29
|
+
|
|
30
|
+
## Valid
|
|
31
|
+
```ts
|
|
32
|
+
var value = a ? b : c
|
|
33
|
+
var value = a
|
|
34
|
+
? b
|
|
35
|
+
: c
|
|
36
|
+
? d
|
|
37
|
+
: e
|
|
38
|
+
type MergeValue<A, B> = B extends NotPlain | Primitive
|
|
39
|
+
? B
|
|
40
|
+
: B extends WeakKey
|
|
41
|
+
? A extends NotPlain | Primitive
|
|
42
|
+
? B
|
|
43
|
+
: A extends WeakKey
|
|
44
|
+
? MergeObject<A, B>
|
|
45
|
+
: B
|
|
46
|
+
: B
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Invalid
|
|
50
|
+
```ts
|
|
51
|
+
var value = a ? b : c ? d : e
|
|
52
|
+
var value = a ? b
|
|
53
|
+
: c
|
|
54
|
+
type M<A> = A extends string ? 1 : A extends number ? 2 : 3
|
|
55
|
+
```
|
|
@@ -1,47 +1,60 @@
|
|
|
1
|
-
# svelte-naming-convention
|
|
2
|
-
Enforces snake_case
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
1
|
+
# svelte-naming-convention
|
|
2
|
+
Enforces snake_case declarations, following the [Svelte code conventions](https://github.com/sveltejs/svelte/blob/master/CONTRIBUTING.md#code-conventions).
|
|
3
|
+
The strict config turns it on and the recommended config leaves it off, since its fix renames identifiers.
|
|
4
|
+
|
|
5
|
+
- Declarations such as variables, parameters, catch clauses, array patterns and non-shorthand object patterns, `const { key: camelCase } = value`, are reported. A shorthand property, `const { camelCase } = value`, and a shorthand import, `import { camelCase } from "m"`, are not, because the name is the key or the export it reads; write `const { camelCase: camel_case } = value` or `import { camelCase as camel_case }` to rename it.
|
|
6
|
+
- The message names the expected name, `Rename 'camelCase' to 'camel_case'`, or, for a name without a snake_case form such as `NO_SNAKE__CASE`, asks for snake_case, UPPER_SNAKE_CASE or PascalCase.
|
|
7
|
+
- Usages such as assignments, function bodies, `extends` clauses, JSX and TypeScript expressions are only renamed along with their declaration; `fixSameNames` sets the order.
|
|
8
|
+
- Usages are matched to declarations by scope, so a global, an import or an exported camelCase function of the same name is left as it is.
|
|
9
|
+
- A declaration exported with `export { camelCase }` is renamed together with the export specifier, `export { camel_case as camelCase }`.
|
|
10
|
+
- The JSDoc of a renamed parameter follows it: `@param {T} [camelCase]`, `{camelCase is T}` and `{typeof camelCase}`.
|
|
11
|
+
- In a `.svelte` file, the store subscriptions of a renamed store are renamed with it, `$camelCase` into `$camel_case`, in the same fix, and so are the usages in the markup: mustache tags, attributes, directives and the expression of `{#if}`, `{#each}`, `{#await}` and `{#key}`. A shorthand attribute is written out, `{camelCase}` into `camelCase={camel_case}`, so the name of the property stays. Names the markup declares, the context of `{#each}`, the value of `{#await}` and a `let:` property, are not reported.
|
|
12
|
+
- A name is reported without a fix when it has no snake_case form, such as `NO_SNAKE__CASE`, when the snake_case name would shadow or capture another variable, when it is also declared where the rule does not rename, such as a TypeScript namespace merged with a function or `export var camelCase`, when a declaration of it is turned off with an `eslint-disable` comment, when it is used as a JSX or Svelte component tag, `<Camel_Case />`, which a lowercase name would turn into an HTML tag, when it also appears where the rule cannot tell a reference from a type or a property, such as `let a: camelCase` or markup of a Svelte parser, or when it is read as a store, `$camelCase`, outside a `.svelte` file, where `$camelCase` is a name of its own.
|
|
13
|
+
|
|
14
|
+
## options
|
|
15
|
+
```js
|
|
16
|
+
schema: [
|
|
17
|
+
{
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
properties: {
|
|
20
|
+
fixSameNames: { default: true, type: "boolean" }
|
|
21
|
+
},
|
|
22
|
+
type: "object"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
```
|
|
26
|
+
### fixSameNames
|
|
27
|
+
If it is `true`, every usage of a reported declaration is reported and fixed on its own, and the declaration is renamed in a later pass of `eslint --fix`, once no usage of the old name is left, so a fix another rule overrides in the same pass never leaves a usage behind.
|
|
28
|
+
Assignments to the variable and `export default` of it are renamed with the declaration, not on their own, so `prefer-const` never sees `let lastBid = 1` without its `lastBid += 1` and turns it into a `const`, and `ascii-order` never sees a default-exported function under another name and moves it.
|
|
29
|
+
The declaration and its usages are renamed in one fix instead when the snake_case name is already declared in the file or a variable of the same name is declared in a nested scope, so a half-renamed usage never resolves to another variable.
|
|
30
|
+
If it is `false`, only the declaration is reported, and its fix renames the declaration and every usage at once.
|
|
31
|
+
```js
|
|
32
|
+
myFunction() // Only in the case that fixSameNames is true, an error occurs.
|
|
33
|
+
|
|
34
|
+
// Rename 'myFunction' to 'my_function': declarations are snake_case, following the Svelte code conventions
|
|
35
|
+
function myFunction() {
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Valid
|
|
41
|
+
```js
|
|
42
|
+
var snake_case = 'Hello'
|
|
43
|
+
var snake1_2_3case_4 = 'Hello'
|
|
44
|
+
var SNAKE_CASE = 'Hello'
|
|
45
|
+
var SNAKE1_2_3CASE_4 = 'Hello'
|
|
46
|
+
var PascalCase = 'Hello'
|
|
47
|
+
var P1ascal2Case345 = 'Hello'
|
|
48
|
+
var __ = 'Hello'
|
|
49
|
+
var $$ = 'Hello'
|
|
50
|
+
var __snake_case$$ = 'Hello'
|
|
51
|
+
var $$snake_case$$ = 'Hello'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Invalid
|
|
55
|
+
```js
|
|
56
|
+
var camelCase = 'Hello'
|
|
57
|
+
var NO_SNAKE__CASE = 'Hello'
|
|
58
|
+
var NO_SNAKE_CASE_ = 'Hello'
|
|
59
|
+
var __camelCase$$ = 'Hello'
|
|
47
60
|
```
|
package/package.json
CHANGED
|
@@ -1,38 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
"author": "artxe",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/artxe/lube-series/issues"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@stylistic/eslint-plugin": "^5.10.0"
|
|
8
|
+
},
|
|
9
|
+
"description": "Fixable ESLint rules that format code without Prettier",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/estree": "^1.0.9",
|
|
12
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
13
|
+
"eslint": "^10.10.0"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/index.d.ts",
|
|
21
|
+
"default": "./src/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"docs",
|
|
27
|
+
"src",
|
|
28
|
+
"types/index.*"
|
|
29
|
+
],
|
|
30
|
+
"homepage": "https://github.com/artxe/lube-series/tree/master/packages/eslint-plugin-lube#readme",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"eslint",
|
|
33
|
+
"eslint-plugin",
|
|
34
|
+
"eslint-plugin-lube",
|
|
35
|
+
"eslintplugin",
|
|
36
|
+
"formatting",
|
|
37
|
+
"jsdoc",
|
|
38
|
+
"lube",
|
|
39
|
+
"prettier",
|
|
40
|
+
"sort",
|
|
41
|
+
"svelte"
|
|
42
|
+
],
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"main": "src/index.js",
|
|
45
|
+
"name": "eslint-plugin-lube",
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"eslint": ">=9.0.0"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"directory": "packages/eslint-plugin-lube",
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/artxe/lube-series"
|
|
53
|
+
},
|
|
54
|
+
"type": "module",
|
|
55
|
+
"types": "types/index.d.ts",
|
|
56
|
+
"version": "0.6.0",
|
|
57
|
+
"scripts": {
|
|
58
|
+
"dts": "node ../../scripts/tsc_with_clean.js eslint-plugin-lube",
|
|
59
|
+
"lint": "pnpm -w lint",
|
|
60
|
+
"test": "pnpm -w exec vitest run --coverage test/eslint-plugin-lube"
|
|
61
|
+
}
|
|
38
62
|
}
|