@haltcase/style 1.0.0-canary.1 → 1.0.0-canary.2
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/eslint/_base.js +25 -1
- package/eslint/constants.js +9 -2
- package/eslint/next.js +12 -1
- package/eslint/rules/best-practice.js +6 -0
- package/eslint/rules/typescript/index.js +8 -1
- package/eslint/rules/unicorn.js +117 -116
- package/package.json +1 -1
package/eslint/_base.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
configFiles,
|
|
5
|
+
ecmaVersion,
|
|
6
|
+
javascriptFiles,
|
|
7
|
+
levels: { off },
|
|
8
|
+
scriptFiles
|
|
9
|
+
} = require("./constants");
|
|
4
10
|
|
|
5
11
|
// see https://github.com/eslint/eslint/issues/3458
|
|
6
12
|
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
@@ -47,6 +53,24 @@ module.exports = {
|
|
|
47
53
|
parserOptions: {
|
|
48
54
|
requireConfigFile: false
|
|
49
55
|
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// config files for third-party tools likely require default exports
|
|
59
|
+
// (e.g., next.config.mjs)
|
|
60
|
+
{
|
|
61
|
+
files: configFiles,
|
|
62
|
+
rules: {
|
|
63
|
+
"import/no-default-export": off
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// development-only helper scripts & prisma database scripts
|
|
68
|
+
{
|
|
69
|
+
files: scriptFiles,
|
|
70
|
+
rules: {
|
|
71
|
+
"no-console": "off",
|
|
72
|
+
"unicorn/no-process-exit": "off"
|
|
73
|
+
}
|
|
50
74
|
}
|
|
51
75
|
]
|
|
52
76
|
};
|
package/eslint/constants.js
CHANGED
|
@@ -7,7 +7,14 @@ module.exports = {
|
|
|
7
7
|
error: "error"
|
|
8
8
|
},
|
|
9
9
|
ecmaVersion: 2021,
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
commonJsFiles: ["*.?(c)js"],
|
|
12
|
-
|
|
12
|
+
javascriptFiles: ["*.js?(x)", "*.mjs"],
|
|
13
|
+
typescriptFiles: ["*.ts?(x)"],
|
|
14
|
+
|
|
15
|
+
configFiles: ["**/*.config.{m,}{js,ts}"],
|
|
16
|
+
scriptFiles: [["**/scripts/*", "**/prisma/*"]],
|
|
17
|
+
|
|
18
|
+
nextJsPageFiles: ["**/{pages,app}/**/*.{m,}{js,ts}x"],
|
|
19
|
+
nextJsApiRoutes: ["**/{pages,app}/api/**/*.{m,}{js,ts}"]
|
|
13
20
|
};
|
package/eslint/next.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
javascriptFiles,
|
|
5
|
+
levels: { off },
|
|
6
|
+
nextJsPageFiles,
|
|
7
|
+
nextJsApiRoutes
|
|
8
|
+
} = require("./constants");
|
|
4
9
|
const checkForPackage = require("./utils/require-package");
|
|
5
10
|
|
|
6
11
|
checkForPackage("next", "@next/eslint-plugin-next");
|
|
@@ -22,6 +27,12 @@ module.exports = {
|
|
|
22
27
|
{
|
|
23
28
|
files: javascriptFiles,
|
|
24
29
|
parserOptions: { babelOptions }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
files: [...nextJsPageFiles, ...nextJsApiRoutes],
|
|
33
|
+
rules: {
|
|
34
|
+
"import/no-default-export": off
|
|
35
|
+
}
|
|
25
36
|
}
|
|
26
37
|
]
|
|
27
38
|
};
|
|
@@ -4,8 +4,14 @@ const {
|
|
|
4
4
|
levels: { warn, error }
|
|
5
5
|
} = require("../constants");
|
|
6
6
|
|
|
7
|
+
const commentsRules = {
|
|
8
|
+
"eslint-comments/disable-enable-pair": [error, { allowWholeFile: true }]
|
|
9
|
+
};
|
|
10
|
+
|
|
7
11
|
module.exports = {
|
|
8
12
|
rules: {
|
|
13
|
+
...commentsRules,
|
|
14
|
+
|
|
9
15
|
/**
|
|
10
16
|
* Require return statements in array methods callbacks.
|
|
11
17
|
*
|
|
@@ -26,7 +26,14 @@ module.exports = {
|
|
|
26
26
|
*
|
|
27
27
|
* 🚫 Not fixable - https://typescript-eslint.io/rules/explicit-function-return-type/
|
|
28
28
|
*/
|
|
29
|
-
"@typescript-eslint/explicit-function-return-type":
|
|
29
|
+
"@typescript-eslint/explicit-function-return-type": [
|
|
30
|
+
warn,
|
|
31
|
+
{
|
|
32
|
+
allowExpressions: true,
|
|
33
|
+
allowFunctionsWithoutTypeParameters: true,
|
|
34
|
+
allowTypedFunctionExpressions: true
|
|
35
|
+
}
|
|
36
|
+
],
|
|
30
37
|
/**
|
|
31
38
|
* Require using function property types in method signatures.
|
|
32
39
|
*
|
package/eslint/rules/unicorn.js
CHANGED
|
@@ -8,61 +8,61 @@ module.exports = {
|
|
|
8
8
|
plugins: ["unicorn"],
|
|
9
9
|
rules: {
|
|
10
10
|
/**
|
|
11
|
-
* Improve regexes by making them shorter, consistent, and safer.
|
|
11
|
+
* Improve regexes by making them shorter, consistent, and safer.
|
|
12
12
|
*
|
|
13
13
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md
|
|
14
14
|
*/
|
|
15
15
|
"unicorn/better-regex": error,
|
|
16
16
|
/**
|
|
17
|
-
* Enforce a specific parameter name in catch clauses.
|
|
17
|
+
* Enforce a specific parameter name in catch clauses.
|
|
18
18
|
*
|
|
19
19
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/catch-error-name.md
|
|
20
20
|
*/
|
|
21
21
|
"unicorn/catch-error-name": error,
|
|
22
22
|
/**
|
|
23
|
-
* Use destructured variables over properties.
|
|
23
|
+
* Use destructured variables over properties.
|
|
24
24
|
*
|
|
25
25
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/consistent-destructuring.md
|
|
26
26
|
*/
|
|
27
27
|
"unicorn/consistent-destructuring": error,
|
|
28
28
|
/**
|
|
29
|
-
* Move function definitions to the highest possible scope.
|
|
29
|
+
* Move function definitions to the highest possible scope.
|
|
30
30
|
*
|
|
31
31
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/consistent-function-scoping.md
|
|
32
32
|
*/
|
|
33
33
|
"unicorn/consistent-function-scoping": error,
|
|
34
34
|
/**
|
|
35
|
-
* Enforce correct `Error` subclassing.
|
|
35
|
+
* Enforce correct `Error` subclassing.
|
|
36
36
|
*
|
|
37
37
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/custom-error-definition.md
|
|
38
38
|
*/
|
|
39
39
|
"unicorn/custom-error-definition": error,
|
|
40
40
|
/**
|
|
41
|
-
* Enforce no spaces between braces.
|
|
41
|
+
* Enforce no spaces between braces.
|
|
42
42
|
*
|
|
43
43
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/empty-brace-spaces.md
|
|
44
44
|
*/
|
|
45
45
|
"unicorn/empty-brace-spaces": error,
|
|
46
46
|
/**
|
|
47
|
-
* Enforce passing a `message` value when creating a built-in error.
|
|
47
|
+
* Enforce passing a `message` value when creating a built-in error.
|
|
48
48
|
*
|
|
49
49
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/error-message.md
|
|
50
50
|
*/
|
|
51
51
|
"unicorn/error-message": error,
|
|
52
52
|
/**
|
|
53
|
-
* Require escape sequences to use uppercase values.
|
|
53
|
+
* Require escape sequences to use uppercase values.
|
|
54
54
|
*
|
|
55
55
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/escape-case.md
|
|
56
56
|
*/
|
|
57
57
|
"unicorn/escape-case": error,
|
|
58
58
|
/**
|
|
59
|
-
* Add expiration conditions to TODO comments.
|
|
59
|
+
* Add expiration conditions to TODO comments.
|
|
60
60
|
*
|
|
61
61
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/expiring-todo-comments.md
|
|
62
62
|
*/
|
|
63
63
|
"unicorn/expiring-todo-comments": error,
|
|
64
64
|
/**
|
|
65
|
-
* Enforce explicitly comparing the `length` or `size` property of a value.
|
|
65
|
+
* Enforce explicitly comparing the `length` or `size` property of a value.
|
|
66
66
|
*
|
|
67
67
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/explicit-length-check.md
|
|
68
68
|
*/
|
|
@@ -70,52 +70,49 @@ module.exports = {
|
|
|
70
70
|
/**
|
|
71
71
|
* Require consistent filename case for all linted files.
|
|
72
72
|
*
|
|
73
|
+
* Disabled because too many variations are currently needed for React and Next.js projects.
|
|
74
|
+
*
|
|
73
75
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
|
74
76
|
*/
|
|
75
|
-
"unicorn/filename-case":
|
|
76
|
-
error,
|
|
77
|
-
{
|
|
78
|
-
case: "kebabCase"
|
|
79
|
-
}
|
|
80
|
-
],
|
|
77
|
+
"unicorn/filename-case": off,
|
|
81
78
|
/**
|
|
82
|
-
* Enforce specific import styles per module.
|
|
79
|
+
* Enforce specific import styles per module.
|
|
83
80
|
*
|
|
84
81
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/import-style.md
|
|
85
82
|
*/
|
|
86
83
|
"unicorn/import-style": error,
|
|
87
84
|
/**
|
|
88
|
-
* Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`.
|
|
85
|
+
* Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`.
|
|
89
86
|
*
|
|
90
87
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/new-for-builtins.md
|
|
91
88
|
*/
|
|
92
89
|
"unicorn/new-for-builtins": error,
|
|
93
90
|
/**
|
|
94
|
-
* Enforce specifying rules to disable in `eslint-disable` comments.
|
|
91
|
+
* Enforce specifying rules to disable in `eslint-disable` comments.
|
|
95
92
|
*
|
|
96
93
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-abusive-eslint-disable.md
|
|
97
94
|
*/
|
|
98
95
|
"unicorn/no-abusive-eslint-disable": error,
|
|
99
96
|
/**
|
|
100
|
-
* Prevent passing a function reference directly to iterator methods.
|
|
97
|
+
* Prevent passing a function reference directly to iterator methods.
|
|
101
98
|
*
|
|
102
99
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-callback-reference.md
|
|
103
100
|
*/
|
|
104
101
|
"unicorn/no-array-callback-reference": error,
|
|
105
102
|
/**
|
|
106
|
-
* Prefer `for…of` over the `forEach` method.
|
|
103
|
+
* Prefer `for…of` over the `forEach` method.
|
|
107
104
|
*
|
|
108
105
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
|
|
109
106
|
*/
|
|
110
107
|
"unicorn/no-array-for-each": error,
|
|
111
108
|
/**
|
|
112
|
-
* Disallow using the `this` argument in array methods.
|
|
109
|
+
* Disallow using the `this` argument in array methods.
|
|
113
110
|
*
|
|
114
111
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-method-this-argument.md
|
|
115
112
|
*/
|
|
116
113
|
"unicorn/no-array-method-this-argument": error,
|
|
117
114
|
/**
|
|
118
|
-
* Enforce combining multiple `Array#push()` into one call.
|
|
115
|
+
* Enforce combining multiple `Array#push()` into one call.
|
|
119
116
|
*
|
|
120
117
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-push-push.md
|
|
121
118
|
*/
|
|
@@ -123,385 +120,389 @@ module.exports = {
|
|
|
123
120
|
/**
|
|
124
121
|
* Disallow `Array#reduce()` and `Array#reduceRight()`.
|
|
125
122
|
*
|
|
126
|
-
* Disabled because `reduce` is useful for functional programming patterns.
|
|
123
|
+
* Disabled because `reduce` is useful for functional programming patterns.
|
|
127
124
|
*
|
|
128
125
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reduce.md
|
|
129
126
|
*/
|
|
130
127
|
"unicorn/no-array-reduce": off,
|
|
131
128
|
/**
|
|
132
|
-
* Disallow member access from await expression.
|
|
129
|
+
* Disallow member access from await expression.
|
|
133
130
|
*
|
|
134
131
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-expression-member.md
|
|
135
132
|
*/
|
|
136
133
|
"unicorn/no-await-expression-member": error,
|
|
137
134
|
/**
|
|
138
|
-
* Do not use leading/trailing space between `console.log` parameters.
|
|
135
|
+
* Do not use leading/trailing space between `console.log` parameters.
|
|
139
136
|
*
|
|
140
137
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-console-spaces.md
|
|
141
138
|
*/
|
|
142
139
|
"unicorn/no-console-spaces": error,
|
|
143
140
|
/**
|
|
144
|
-
* Do not use `document.cookie` directly.
|
|
141
|
+
* Do not use `document.cookie` directly.
|
|
145
142
|
*
|
|
146
143
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-document-cookie.md
|
|
147
144
|
*/
|
|
148
145
|
"unicorn/no-document-cookie": error,
|
|
149
146
|
/**
|
|
150
|
-
* Disallow empty files.
|
|
147
|
+
* Disallow empty files.
|
|
151
148
|
*
|
|
152
149
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-empty-file.md
|
|
153
150
|
*/
|
|
154
151
|
"unicorn/no-empty-file": error,
|
|
155
152
|
/**
|
|
156
|
-
* Do not use a `for` loop that can be replaced with a `for-of` loop.
|
|
153
|
+
* Do not use a `for` loop that can be replaced with a `for-of` loop.
|
|
157
154
|
*
|
|
158
155
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-for-loop.md
|
|
159
156
|
*/
|
|
160
157
|
"unicorn/no-for-loop": error,
|
|
161
158
|
/**
|
|
162
|
-
* Enforce the use of Unicode escapes instead of hexadecimal escapes.
|
|
159
|
+
* Enforce the use of Unicode escapes instead of hexadecimal escapes.
|
|
163
160
|
*
|
|
164
161
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-hex-escape.md
|
|
165
162
|
*/
|
|
166
163
|
"unicorn/no-hex-escape": error,
|
|
167
164
|
/**
|
|
168
|
-
* Require `Array.isArray()` instead of `instanceof Array`.
|
|
165
|
+
* Require `Array.isArray()` instead of `instanceof Array`.
|
|
169
166
|
*
|
|
170
167
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-instanceof-array.md
|
|
171
168
|
*/
|
|
172
169
|
"unicorn/no-instanceof-array": error,
|
|
173
170
|
/**
|
|
174
|
-
* Prevent calling `EventTarget#removeEventListener()` with the result of an expression.
|
|
171
|
+
* Prevent calling `EventTarget#removeEventListener()` with the result of an expression.
|
|
175
172
|
*
|
|
176
173
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-invalid-remove-event-listener.md
|
|
177
174
|
*/
|
|
178
175
|
"unicorn/no-invalid-remove-event-listener": error,
|
|
179
176
|
/**
|
|
180
|
-
* Disallow identifiers starting with `new` or `class`.
|
|
177
|
+
* Disallow identifiers starting with `new` or `class`.
|
|
178
|
+
*
|
|
179
|
+
* Disabled because it isn't that impactful, and is annoying in React projects.
|
|
181
180
|
*
|
|
182
181
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-keyword-prefix.md
|
|
183
182
|
*/
|
|
184
|
-
"unicorn/no-keyword-prefix":
|
|
183
|
+
"unicorn/no-keyword-prefix": off,
|
|
185
184
|
/**
|
|
186
|
-
* Disallow `if` statements as the only statement in `if` blocks without `else`.
|
|
185
|
+
* Disallow `if` statements as the only statement in `if` blocks without `else`.
|
|
187
186
|
*
|
|
188
187
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-lonely-if.md
|
|
189
188
|
*/
|
|
190
189
|
"unicorn/no-lonely-if": error,
|
|
191
190
|
/**
|
|
192
|
-
* Disallow negated conditions.
|
|
191
|
+
* Disallow negated conditions.
|
|
193
192
|
*
|
|
194
193
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-condition.md
|
|
195
194
|
*/
|
|
196
195
|
"unicorn/no-negated-condition": error,
|
|
197
196
|
/**
|
|
198
|
-
* Disallow nested ternary expressions.
|
|
197
|
+
* Disallow nested ternary expressions.
|
|
199
198
|
*
|
|
200
199
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-nested-ternary.md
|
|
201
200
|
*/
|
|
202
201
|
"unicorn/no-nested-ternary": error,
|
|
203
202
|
/**
|
|
204
|
-
* Disallow `new Array()`.
|
|
203
|
+
* Disallow `new Array()`.
|
|
205
204
|
*
|
|
206
205
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md
|
|
207
206
|
*/
|
|
208
207
|
"unicorn/no-new-array": error,
|
|
209
208
|
/**
|
|
210
|
-
* Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`.
|
|
209
|
+
* Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`.
|
|
211
210
|
*
|
|
212
211
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-buffer.md
|
|
213
212
|
*/
|
|
214
213
|
"unicorn/no-new-buffer": error,
|
|
215
214
|
/**
|
|
216
|
-
* Disallow the use of the `null` literal.
|
|
215
|
+
* Disallow the use of the `null` literal.
|
|
216
|
+
*
|
|
217
|
+
* Disabled because I run into `null` too much to pretend it doesn't exist... ship has sailed.
|
|
217
218
|
*
|
|
218
219
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-null.md
|
|
219
220
|
*/
|
|
220
|
-
"unicorn/no-null":
|
|
221
|
+
"unicorn/no-null": off,
|
|
221
222
|
/**
|
|
222
|
-
* Disallow the use of objects as default parameters.
|
|
223
|
+
* Disallow the use of objects as default parameters.
|
|
223
224
|
*
|
|
224
225
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-object-as-default-parameter.md
|
|
225
226
|
*/
|
|
226
227
|
"unicorn/no-object-as-default-parameter": error,
|
|
227
228
|
/**
|
|
228
|
-
* Disallow `process.exit()`.
|
|
229
|
+
* Disallow `process.exit()`.
|
|
229
230
|
*
|
|
230
231
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-process-exit.md
|
|
231
232
|
*/
|
|
232
233
|
"unicorn/no-process-exit": error,
|
|
233
234
|
/**
|
|
234
|
-
* Disallow classes that only have static members.
|
|
235
|
+
* Disallow classes that only have static members.
|
|
235
236
|
*
|
|
236
237
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-static-only-class.md
|
|
237
238
|
*/
|
|
238
239
|
"unicorn/no-static-only-class": error,
|
|
239
240
|
/**
|
|
240
|
-
* Disallow `then` property.
|
|
241
|
+
* Disallow `then` property.
|
|
241
242
|
*
|
|
242
243
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-thenable.md
|
|
243
244
|
*/
|
|
244
245
|
"unicorn/no-thenable": error,
|
|
245
246
|
/**
|
|
246
|
-
* Disallow assigning `this` to a variable.
|
|
247
|
+
* Disallow assigning `this` to a variable.
|
|
247
248
|
*
|
|
248
249
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-this-assignment.md
|
|
249
250
|
*/
|
|
250
251
|
"unicorn/no-this-assignment": error,
|
|
251
252
|
/**
|
|
252
|
-
* Disallow comparing `undefined` using `typeof`.
|
|
253
|
+
* Disallow comparing `undefined` using `typeof`.
|
|
253
254
|
*
|
|
254
255
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-typeof-undefined.md
|
|
255
256
|
*/
|
|
256
257
|
"unicorn/no-typeof-undefined": error,
|
|
257
258
|
/**
|
|
258
|
-
* Disallow awaiting non-promise values.
|
|
259
|
+
* Disallow awaiting non-promise values.
|
|
259
260
|
*
|
|
260
261
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-await.md
|
|
261
262
|
*/
|
|
262
263
|
"unicorn/no-unnecessary-await": error,
|
|
263
264
|
/**
|
|
264
|
-
* Disallow unreadable array destructuring.
|
|
265
|
+
* Disallow unreadable array destructuring.
|
|
265
266
|
*
|
|
266
267
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-array-destructuring.md
|
|
267
268
|
*/
|
|
268
269
|
"unicorn/no-unreadable-array-destructuring": error,
|
|
269
270
|
/**
|
|
270
|
-
* Disallow unreadable IIFEs.
|
|
271
|
+
* Disallow unreadable IIFEs.
|
|
271
272
|
*
|
|
272
273
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md
|
|
273
274
|
*/
|
|
274
275
|
"unicorn/no-unreadable-iife": error,
|
|
275
276
|
/**
|
|
276
|
-
* Disallow unused object properties.
|
|
277
|
+
* Disallow unused object properties.
|
|
277
278
|
*
|
|
278
279
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unused-properties.md
|
|
279
280
|
*/
|
|
280
281
|
"unicorn/no-unused-properties": error,
|
|
281
282
|
/**
|
|
282
|
-
* Disallow useless fallback when spreading in object literals.
|
|
283
|
+
* Disallow useless fallback when spreading in object literals.
|
|
283
284
|
*
|
|
284
285
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-fallback-in-spread.md
|
|
285
286
|
*/
|
|
286
287
|
"unicorn/no-useless-fallback-in-spread": error,
|
|
287
288
|
/**
|
|
288
|
-
* Disallow useless array length check.
|
|
289
|
+
* Disallow useless array length check.
|
|
289
290
|
*
|
|
290
291
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-length-check.md
|
|
291
292
|
*/
|
|
292
293
|
"unicorn/no-useless-length-check": error,
|
|
293
294
|
/**
|
|
294
|
-
* Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks
|
|
295
|
+
* Disallow returning/yielding `Promise.resolve/reject()` in async functions or promise callbacks
|
|
295
296
|
*
|
|
296
297
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md
|
|
297
298
|
*/
|
|
298
299
|
"unicorn/no-useless-promise-resolve-reject": error,
|
|
299
300
|
/**
|
|
300
|
-
* Disallow unnecessary spread.
|
|
301
|
+
* Disallow unnecessary spread.
|
|
301
302
|
*
|
|
302
303
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-spread.md
|
|
303
304
|
*/
|
|
304
305
|
"unicorn/no-useless-spread": error,
|
|
305
306
|
/**
|
|
306
|
-
* Disallow useless case in switch statements.
|
|
307
|
+
* Disallow useless case in switch statements.
|
|
307
308
|
*
|
|
308
309
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md
|
|
309
310
|
*/
|
|
310
311
|
"unicorn/no-useless-switch-case": error,
|
|
311
312
|
/**
|
|
312
|
-
* Disallow useless `undefined`.
|
|
313
|
+
* Disallow useless `undefined`.
|
|
313
314
|
*
|
|
314
315
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md
|
|
315
316
|
*/
|
|
316
317
|
"unicorn/no-useless-undefined": error,
|
|
317
318
|
/**
|
|
318
|
-
* Disallow number literals with zero fractions or dangling dots.
|
|
319
|
+
* Disallow number literals with zero fractions or dangling dots.
|
|
319
320
|
*
|
|
320
321
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-zero-fractions.md
|
|
321
322
|
*/
|
|
322
323
|
"unicorn/no-zero-fractions": error,
|
|
323
324
|
/**
|
|
324
|
-
* Enforce proper case for numeric literals.
|
|
325
|
+
* Enforce proper case for numeric literals.
|
|
325
326
|
*
|
|
326
327
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md
|
|
327
328
|
*/
|
|
328
329
|
"unicorn/number-literal-case": error,
|
|
329
330
|
/**
|
|
330
|
-
* Enforce the style of numeric separators by correctly grouping digits.
|
|
331
|
+
* Enforce the style of numeric separators by correctly grouping digits.
|
|
331
332
|
*
|
|
332
333
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/numeric-separators-style.md
|
|
333
334
|
*/
|
|
334
335
|
"unicorn/numeric-separators-style": error,
|
|
335
336
|
/**
|
|
336
|
-
* Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions.
|
|
337
|
+
* Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions.
|
|
337
338
|
*
|
|
338
339
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-add-event-listener.md
|
|
339
340
|
*/
|
|
340
341
|
"unicorn/prefer-add-event-listener": error,
|
|
341
342
|
/**
|
|
342
|
-
* Prefer `.find(…)` and `.findLast(…)` over the first or last element from `.filter(…)`.
|
|
343
|
+
* Prefer `.find(…)` and `.findLast(…)` over the first or last element from `.filter(…)`.
|
|
343
344
|
*
|
|
344
345
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-find.md
|
|
345
346
|
*/
|
|
346
347
|
"unicorn/prefer-array-find": error,
|
|
347
348
|
/**
|
|
348
|
-
* Prefer `Array#flat()` over legacy techniques to flatten arrays.
|
|
349
|
+
* Prefer `Array#flat()` over legacy techniques to flatten arrays.
|
|
349
350
|
*
|
|
350
351
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
|
|
351
352
|
*/
|
|
352
353
|
"unicorn/prefer-array-flat": error,
|
|
353
354
|
/**
|
|
354
|
-
* Prefer `.flatMap(…)` over `.map(…).flat()`.
|
|
355
|
+
* Prefer `.flatMap(…)` over `.map(…).flat()`.
|
|
355
356
|
*
|
|
356
357
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
|
|
357
358
|
*/
|
|
358
359
|
"unicorn/prefer-array-flat-map": error,
|
|
359
360
|
/**
|
|
360
|
-
* Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item.
|
|
361
|
+
* Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item.
|
|
361
362
|
*
|
|
362
363
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-index-of.md
|
|
363
364
|
*/
|
|
364
365
|
"unicorn/prefer-array-index-of": error,
|
|
365
366
|
/**
|
|
366
|
-
* Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast}(…)`.
|
|
367
|
+
* Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast}(…)`.
|
|
367
368
|
*
|
|
368
369
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md
|
|
369
370
|
*/
|
|
370
371
|
"unicorn/prefer-array-some": error,
|
|
371
372
|
/**
|
|
372
|
-
* Prefer `.at()` method for index access and `String#charAt()`.
|
|
373
|
+
* Prefer `.at()` method for index access and `String#charAt()`.
|
|
373
374
|
*
|
|
374
375
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-at.md
|
|
375
376
|
*/
|
|
376
377
|
"unicorn/prefer-at": error,
|
|
377
378
|
/**
|
|
378
|
-
* Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(…)` and `Blob#text()` over `FileReader#readAsText(…)`.
|
|
379
|
+
* Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(…)` and `Blob#text()` over `FileReader#readAsText(…)`.
|
|
379
380
|
*
|
|
380
381
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-blob-reading-methods.md
|
|
381
382
|
*/
|
|
382
383
|
"unicorn/prefer-blob-reading-methods": error,
|
|
383
384
|
/**
|
|
384
|
-
* Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`.
|
|
385
|
+
* Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`.
|
|
385
386
|
*
|
|
386
387
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-code-point.md
|
|
387
388
|
*/
|
|
388
389
|
"unicorn/prefer-code-point": error,
|
|
389
390
|
/**
|
|
390
|
-
* Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch.
|
|
391
|
+
* Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch.
|
|
391
392
|
*
|
|
392
393
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-date-now.md
|
|
393
394
|
*/
|
|
394
395
|
"unicorn/prefer-date-now": error,
|
|
395
396
|
/**
|
|
396
|
-
* Prefer default parameters over reassignment.
|
|
397
|
+
* Prefer default parameters over reassignment.
|
|
397
398
|
*
|
|
398
399
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-default-parameters.md
|
|
399
400
|
*/
|
|
400
401
|
"unicorn/prefer-default-parameters": error,
|
|
401
402
|
/**
|
|
402
|
-
* Prefer `Node#append()` over `Node#appendChild()`.
|
|
403
|
+
* Prefer `Node#append()` over `Node#appendChild()`.
|
|
403
404
|
*
|
|
404
405
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-append.md
|
|
405
406
|
*/
|
|
406
407
|
"unicorn/prefer-dom-node-append": error,
|
|
407
408
|
/**
|
|
408
|
-
* Prefer using `.dataset` on DOM elements over calling attribute methods.
|
|
409
|
+
* Prefer using `.dataset` on DOM elements over calling attribute methods.
|
|
409
410
|
*
|
|
410
411
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-dataset.md
|
|
411
412
|
*/
|
|
412
413
|
"unicorn/prefer-dom-node-dataset": error,
|
|
413
414
|
/**
|
|
414
|
-
* Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`.
|
|
415
|
+
* Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`.
|
|
415
416
|
*
|
|
416
417
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-remove.md
|
|
417
418
|
*/
|
|
418
419
|
"unicorn/prefer-dom-node-remove": error,
|
|
419
420
|
/**
|
|
420
|
-
* Prefer `.textContent` over `.innerText`.
|
|
421
|
+
* Prefer `.textContent` over `.innerText`.
|
|
421
422
|
*
|
|
422
423
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-text-content.md
|
|
423
424
|
*/
|
|
424
425
|
"unicorn/prefer-dom-node-text-content": error,
|
|
425
426
|
/**
|
|
426
|
-
* Prefer `EventTarget` over `EventEmitter`.
|
|
427
|
+
* Prefer `EventTarget` over `EventEmitter`.
|
|
427
428
|
*
|
|
428
429
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-event-target.md
|
|
429
430
|
*/
|
|
430
431
|
"unicorn/prefer-event-target": error,
|
|
431
432
|
/**
|
|
432
|
-
* Prefer `export…from` when re-exporting.
|
|
433
|
+
* Prefer `export…from` when re-exporting.
|
|
433
434
|
*
|
|
434
435
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-export-from.md
|
|
435
436
|
*/
|
|
436
437
|
"unicorn/prefer-export-from": error,
|
|
437
438
|
/**
|
|
438
|
-
* Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence.
|
|
439
|
+
* Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence.
|
|
439
440
|
*
|
|
440
441
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md
|
|
441
442
|
*/
|
|
442
443
|
"unicorn/prefer-includes": error,
|
|
443
444
|
/**
|
|
444
|
-
* Prefer reading a JSON file as a buffer.
|
|
445
|
+
* Prefer reading a JSON file as a buffer.
|
|
445
446
|
*
|
|
446
447
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-json-parse-buffer.md
|
|
447
448
|
*/
|
|
448
449
|
"unicorn/prefer-json-parse-buffer": error,
|
|
449
450
|
/**
|
|
450
|
-
* Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`.
|
|
451
|
+
* Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`.
|
|
451
452
|
*
|
|
452
453
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-keyboard-event-key.md
|
|
453
454
|
*/
|
|
454
455
|
"unicorn/prefer-keyboard-event-key": error,
|
|
455
456
|
/**
|
|
456
|
-
* Prefer using a logical operator over a ternary.
|
|
457
|
+
* Prefer using a logical operator over a ternary.
|
|
457
458
|
*
|
|
458
459
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-logical-operator-over-ternary.md
|
|
459
460
|
*/
|
|
460
461
|
"unicorn/prefer-logical-operator-over-ternary": error,
|
|
461
462
|
/**
|
|
462
|
-
* Enforce the use of `Math.trunc` instead of bitwise operators.
|
|
463
|
+
* Enforce the use of `Math.trunc` instead of bitwise operators.
|
|
463
464
|
*
|
|
464
465
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-math-trunc.md
|
|
465
466
|
*/
|
|
466
467
|
"unicorn/prefer-math-trunc": error,
|
|
467
468
|
/**
|
|
468
|
-
* Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`.
|
|
469
|
+
* Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`.
|
|
469
470
|
*
|
|
470
471
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-dom-apis.md
|
|
471
472
|
*/
|
|
472
473
|
"unicorn/prefer-modern-dom-apis": error,
|
|
473
474
|
/**
|
|
474
|
-
* Prefer modern `Math` APIs over legacy patterns.
|
|
475
|
+
* Prefer modern `Math` APIs over legacy patterns.
|
|
475
476
|
*
|
|
476
477
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md
|
|
477
478
|
*/
|
|
478
479
|
"unicorn/prefer-modern-math-apis": error,
|
|
479
480
|
/**
|
|
480
|
-
* Prefer JavaScript modules (ESM) over CommonJS.
|
|
481
|
+
* Prefer JavaScript modules (ESM) over CommonJS.
|
|
481
482
|
*
|
|
482
483
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-module.md
|
|
483
484
|
*/
|
|
484
485
|
"unicorn/prefer-module": error,
|
|
485
486
|
/**
|
|
486
|
-
* Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly.
|
|
487
|
+
* Prefer using `String`, `Number`, `BigInt`, `Boolean`, and `Symbol` directly.
|
|
487
488
|
*
|
|
488
489
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-native-coercion-functions.md
|
|
489
490
|
*/
|
|
490
491
|
"unicorn/prefer-native-coercion-functions": error,
|
|
491
492
|
/**
|
|
492
|
-
* Prefer negative index over `.length - index` when possible.
|
|
493
|
+
* Prefer negative index over `.length - index` when possible.
|
|
493
494
|
*
|
|
494
495
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-negative-index.md
|
|
495
496
|
*/
|
|
496
497
|
"unicorn/prefer-negative-index": error,
|
|
497
498
|
/**
|
|
498
|
-
* Prefer using the `node:` protocol when importing Node.js builtin modules.
|
|
499
|
+
* Prefer using the `node:` protocol when importing Node.js builtin modules.
|
|
499
500
|
*
|
|
500
501
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
|
|
501
502
|
*/
|
|
502
503
|
"unicorn/prefer-node-protocol": error,
|
|
503
504
|
/**
|
|
504
|
-
* Prefer `Number` static properties over global ones.
|
|
505
|
+
* Prefer `Number` static properties over global ones.
|
|
505
506
|
*
|
|
506
507
|
* Require using the `node:` protocol when importing Node.js built-in modules.
|
|
507
508
|
*
|
|
@@ -509,133 +510,133 @@ module.exports = {
|
|
|
509
510
|
*/
|
|
510
511
|
"unicorn/prefer-number-properties": error,
|
|
511
512
|
/**
|
|
512
|
-
* Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object.
|
|
513
|
+
* Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object.
|
|
513
514
|
*
|
|
514
515
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-object-from-entries.md
|
|
515
516
|
*/
|
|
516
517
|
"unicorn/prefer-object-from-entries": error,
|
|
517
518
|
/**
|
|
518
|
-
* Prefer omitting the `catch` binding parameter.
|
|
519
|
+
* Prefer omitting the `catch` binding parameter.
|
|
519
520
|
*
|
|
520
521
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md
|
|
521
522
|
*/
|
|
522
523
|
"unicorn/prefer-optional-catch-binding": error,
|
|
523
524
|
/**
|
|
524
|
-
* Prefer borrowing methods from the prototype instead of the instance.
|
|
525
|
+
* Prefer borrowing methods from the prototype instead of the instance.
|
|
525
526
|
*
|
|
526
527
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-prototype-methods.md
|
|
527
528
|
*/
|
|
528
529
|
"unicorn/prefer-prototype-methods": error,
|
|
529
530
|
/**
|
|
530
|
-
* Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`.
|
|
531
|
+
* Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`.
|
|
531
532
|
*
|
|
532
533
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-query-selector.md
|
|
533
534
|
*/
|
|
534
535
|
"unicorn/prefer-query-selector": error,
|
|
535
536
|
/**
|
|
536
|
-
* Prefer `Reflect.apply()` over `Function#apply()`.
|
|
537
|
+
* Prefer `Reflect.apply()` over `Function#apply()`.
|
|
537
538
|
*
|
|
538
539
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-reflect-apply.md
|
|
539
540
|
*/
|
|
540
541
|
"unicorn/prefer-reflect-apply": error,
|
|
541
542
|
/**
|
|
542
|
-
* Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`.
|
|
543
|
+
* Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`.
|
|
543
544
|
*
|
|
544
545
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-regexp-test.md
|
|
545
546
|
*/
|
|
546
547
|
"unicorn/prefer-regexp-test": error,
|
|
547
548
|
/**
|
|
548
|
-
* Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence.
|
|
549
|
+
* Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence.
|
|
549
550
|
*
|
|
550
551
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-set-has.md
|
|
551
552
|
*/
|
|
552
553
|
"unicorn/prefer-set-has": error,
|
|
553
554
|
/**
|
|
554
|
-
* Prefer using `Set#size` instead of `Array#length`.
|
|
555
|
+
* Prefer using `Set#size` instead of `Array#length`.
|
|
555
556
|
*
|
|
556
557
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-set-size.md
|
|
557
558
|
*/
|
|
558
559
|
"unicorn/prefer-set-size": error,
|
|
559
560
|
/**
|
|
560
|
-
* Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()` and `String#split('')`.
|
|
561
|
+
* Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()` and `String#split('')`.
|
|
561
562
|
*
|
|
562
563
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-spread.md
|
|
563
564
|
*/
|
|
564
565
|
"unicorn/prefer-spread": error,
|
|
565
566
|
/**
|
|
566
|
-
* Prefer `String#replaceAll()` over regex searches with the global flag.
|
|
567
|
+
* Prefer `String#replaceAll()` over regex searches with the global flag.
|
|
567
568
|
*
|
|
568
569
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
|
|
569
570
|
*/
|
|
570
571
|
"unicorn/prefer-string-replace-all": error,
|
|
571
572
|
/**
|
|
572
|
-
* Prefer `String#slice()` over `String#substr()` and `String#substring()`.
|
|
573
|
+
* Prefer `String#slice()` over `String#substr()` and `String#substring()`.
|
|
573
574
|
*
|
|
574
575
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-slice.md
|
|
575
576
|
*/
|
|
576
577
|
"unicorn/prefer-string-slice": error,
|
|
577
578
|
/**
|
|
578
|
-
* Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`.
|
|
579
|
+
* Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`.
|
|
579
580
|
*
|
|
580
581
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md
|
|
581
582
|
*/
|
|
582
583
|
"unicorn/prefer-string-starts-ends-with": error,
|
|
583
584
|
/**
|
|
584
|
-
* Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`.
|
|
585
|
+
* Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`.
|
|
585
586
|
*
|
|
586
587
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-trim-start-end.md
|
|
587
588
|
*/
|
|
588
589
|
"unicorn/prefer-string-trim-start-end": error,
|
|
589
590
|
/**
|
|
590
|
-
* Prefer `switch` over multiple `else-if`.
|
|
591
|
+
* Prefer `switch` over multiple `else-if`.
|
|
591
592
|
*
|
|
592
593
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-switch.md
|
|
593
594
|
*/
|
|
594
595
|
"unicorn/prefer-switch": error,
|
|
595
596
|
/**
|
|
596
|
-
* Prefer ternary expressions over simple `if-else` statements.
|
|
597
|
+
* Prefer ternary expressions over simple `if-else` statements.
|
|
597
598
|
*
|
|
598
599
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-ternary.md
|
|
599
600
|
*/
|
|
600
601
|
"unicorn/prefer-ternary": error,
|
|
601
602
|
/**
|
|
602
|
-
* Prefer top-level await over top-level promises and async function calls.
|
|
603
|
+
* Prefer top-level await over top-level promises and async function calls.
|
|
603
604
|
*
|
|
604
605
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-top-level-await.md
|
|
605
606
|
*/
|
|
606
607
|
"unicorn/prefer-top-level-await": error,
|
|
607
608
|
/**
|
|
608
|
-
* Enforce throwing `TypeError` in type checking conditions.
|
|
609
|
+
* Enforce throwing `TypeError` in type checking conditions.
|
|
609
610
|
*
|
|
610
611
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-error.md
|
|
611
612
|
*/
|
|
612
613
|
"unicorn/prefer-type-error": error,
|
|
613
614
|
/**
|
|
614
|
-
* Prevent abbreviations.
|
|
615
|
+
* Prevent abbreviations.
|
|
615
616
|
*
|
|
616
617
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prevent-abbreviations.md
|
|
617
618
|
*/
|
|
618
619
|
"unicorn/prevent-abbreviations": error,
|
|
619
620
|
/**
|
|
620
|
-
* Enforce consistent relative URL style.
|
|
621
|
+
* Enforce consistent relative URL style.
|
|
621
622
|
*
|
|
622
623
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/relative-url-style.md
|
|
623
624
|
*/
|
|
624
625
|
"unicorn/relative-url-style": error,
|
|
625
626
|
/**
|
|
626
|
-
* Enforce using the separator argument with `Array#join()`.
|
|
627
|
+
* Enforce using the separator argument with `Array#join()`.
|
|
627
628
|
*
|
|
628
629
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-array-join-separator.md
|
|
629
630
|
*/
|
|
630
631
|
"unicorn/require-array-join-separator": error,
|
|
631
632
|
/**
|
|
632
|
-
* Enforce using the digits argument with `Number#toFixed()`.
|
|
633
|
+
* Enforce using the digits argument with `Number#toFixed()`.
|
|
633
634
|
*
|
|
634
635
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-number-to-fixed-digits-argument.md
|
|
635
636
|
*/
|
|
636
637
|
"unicorn/require-number-to-fixed-digits-argument": error,
|
|
637
638
|
/**
|
|
638
|
-
* Enforce using the `targetOrigin` argument with `window.postMessage()`.
|
|
639
|
+
* Enforce using the `targetOrigin` argument with `window.postMessage()`.
|
|
639
640
|
*
|
|
640
641
|
* Disabled upstream: can't distinguish `window.postMessage` and `{Worker,MessagePort,Client,BroadcastChannel}#postMessage()`
|
|
641
642
|
* See https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1396
|
|
@@ -644,31 +645,31 @@ module.exports = {
|
|
|
644
645
|
*/
|
|
645
646
|
"unicorn/require-post-message-target-origin": off,
|
|
646
647
|
/**
|
|
647
|
-
* Enforce better string content.
|
|
648
|
+
* Enforce better string content.
|
|
648
649
|
*
|
|
649
650
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/string-content.md
|
|
650
651
|
*/
|
|
651
652
|
"unicorn/string-content": error,
|
|
652
653
|
/**
|
|
653
|
-
* Enforce consistent brace style for `case` clauses.
|
|
654
|
+
* Enforce consistent brace style for `case` clauses.
|
|
654
655
|
*
|
|
655
656
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/switch-case-braces.md
|
|
656
657
|
*/
|
|
657
658
|
"unicorn/switch-case-braces": error,
|
|
658
659
|
/**
|
|
659
|
-
* Fix whitespace-insensitive template indentation.
|
|
660
|
+
* Fix whitespace-insensitive template indentation.
|
|
660
661
|
*
|
|
661
662
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/template-indent.md
|
|
662
663
|
*/
|
|
663
664
|
"unicorn/template-indent": error,
|
|
664
665
|
/**
|
|
665
|
-
* Enforce consistent case for text encoding identifiers.
|
|
666
|
+
* Enforce consistent case for text encoding identifiers.
|
|
666
667
|
*
|
|
667
668
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/text-encoding-identifier-case.md
|
|
668
669
|
*/
|
|
669
670
|
"unicorn/text-encoding-identifier-case": error,
|
|
670
671
|
/**
|
|
671
|
-
* Require `new` when throwing an error.
|
|
672
|
+
* Require `new` when throwing an error.
|
|
672
673
|
*
|
|
673
674
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md
|
|
674
675
|
*/
|