@viclafouch/eslint-config-viclafouch 4.22.1-beta.4 → 4.22.1-beta.6
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/.claude/settings.local.json +6 -1
- package/CLAUDE.md +47 -48
- package/README.md +107 -185
- package/bin/init.js +77 -0
- package/eslint.config.mjs +2 -2
- package/index.d.ts +0 -10
- package/index.mjs +0 -2
- package/package.json +4 -1
- package/rules/react.mjs +33 -1
- package/rules/typescript.mjs +983 -102
- package/templates/nextjs.js +17 -0
- package/templates/react.js +24 -0
- package/templates/typescript.js +15 -0
- package/base.mjs +0 -36
- package/better-tailwindcss.mjs +0 -32
- package/rules/best-practices.mjs +0 -517
- package/rules/errors.mjs +0 -46
- package/rules/es6.mjs +0 -218
- package/rules/node.mjs +0 -24
- package/rules/style.mjs +0 -43
- package/rules/variables.mjs +0 -81
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
importsConfig,
|
|
3
|
+
nextConfig,
|
|
4
|
+
prettierConfig,
|
|
5
|
+
typescriptConfig
|
|
6
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("eslint").Linter.Config}
|
|
10
|
+
*/
|
|
11
|
+
export default [
|
|
12
|
+
{ ignores: ['**/node_modules/**', '**/.next/**', '**/dist/**'] },
|
|
13
|
+
...typescriptConfig,
|
|
14
|
+
...nextConfig,
|
|
15
|
+
...importsConfig,
|
|
16
|
+
...prettierConfig
|
|
17
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
importsConfig,
|
|
3
|
+
prettierConfig,
|
|
4
|
+
reactConfig,
|
|
5
|
+
typescriptConfig
|
|
6
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("eslint").Linter.Config}
|
|
10
|
+
*/
|
|
11
|
+
export default [
|
|
12
|
+
{
|
|
13
|
+
ignores: [
|
|
14
|
+
'**/node_modules/**',
|
|
15
|
+
'**/.output/**',
|
|
16
|
+
'**/.tanstack/**',
|
|
17
|
+
'**/dist/**'
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
...typescriptConfig,
|
|
21
|
+
...reactConfig,
|
|
22
|
+
...importsConfig,
|
|
23
|
+
...prettierConfig
|
|
24
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
importsConfig,
|
|
3
|
+
prettierConfig,
|
|
4
|
+
typescriptConfig
|
|
5
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {import("eslint").Linter.Config}
|
|
9
|
+
*/
|
|
10
|
+
export default [
|
|
11
|
+
{ ignores: ['**/node_modules/**', '**/dist/**'] },
|
|
12
|
+
...typescriptConfig,
|
|
13
|
+
...importsConfig,
|
|
14
|
+
...prettierConfig
|
|
15
|
+
]
|
package/base.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
|
2
|
-
import globals from 'globals'
|
|
3
|
-
import bestPracticesConfig from './rules/best-practices.mjs'
|
|
4
|
-
import errorConfig from './rules/errors.mjs'
|
|
5
|
-
import es6Config from './rules/es6.mjs'
|
|
6
|
-
import importsConfig from './rules/imports.mjs'
|
|
7
|
-
import nodeConfig from './rules/node.mjs'
|
|
8
|
-
import styleConfig from './rules/style.mjs'
|
|
9
|
-
import variablesConfig from './rules/variables.mjs'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @type {import("eslint").Linter.Config}
|
|
13
|
-
*/
|
|
14
|
-
export default [
|
|
15
|
-
{
|
|
16
|
-
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
|
|
17
|
-
linterOptions: {
|
|
18
|
-
reportUnusedDisableDirectives: 'error'
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
languageOptions: {
|
|
23
|
-
globals: globals.builtin
|
|
24
|
-
},
|
|
25
|
-
plugins: {
|
|
26
|
-
unicorn: eslintPluginUnicorn
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
bestPracticesConfig,
|
|
30
|
-
nodeConfig,
|
|
31
|
-
errorConfig,
|
|
32
|
-
importsConfig,
|
|
33
|
-
styleConfig,
|
|
34
|
-
variablesConfig,
|
|
35
|
-
es6Config
|
|
36
|
-
]
|
package/better-tailwindcss.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import betterTailwindcss from 'eslint-plugin-better-tailwindcss'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Object} BetterTailwindcssOptions
|
|
5
|
-
* @property {string} entryPoint - Path to the CSS entry file (Tailwind v4)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates ESLint flat config for eslint-plugin-better-tailwindcss (Tailwind v4)
|
|
10
|
-
* @param {BetterTailwindcssOptions} options
|
|
11
|
-
* @returns {import("eslint").Linter.Config[]}
|
|
12
|
-
*/
|
|
13
|
-
export default function betterTailwindcssConfig({ entryPoint }) {
|
|
14
|
-
const recommendedRules = betterTailwindcss.configs?.recommended?.rules ?? {}
|
|
15
|
-
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
19
|
-
plugins: {
|
|
20
|
-
'better-tailwindcss': betterTailwindcss
|
|
21
|
-
},
|
|
22
|
-
settings: {
|
|
23
|
-
'better-tailwindcss': {
|
|
24
|
-
entryPoint
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
rules: {
|
|
28
|
-
...recommendedRules
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
package/rules/best-practices.mjs
DELETED
|
@@ -1,517 +0,0 @@
|
|
|
1
|
-
import globals from 'globals'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @type {import("eslint").Linter.Config}
|
|
5
|
-
*/
|
|
6
|
-
export default {
|
|
7
|
-
name: 'best-practices',
|
|
8
|
-
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
|
|
9
|
-
languageOptions: {
|
|
10
|
-
globals: {
|
|
11
|
-
...globals.browser
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
rules: {
|
|
15
|
-
// Enforces getter/setter pairs in objects
|
|
16
|
-
// https://eslint.org/docs/rules/accessor-pairs
|
|
17
|
-
'accessor-pairs': 'off',
|
|
18
|
-
|
|
19
|
-
// Force curly everytime
|
|
20
|
-
// https://eslint.org/docs/rules/curly
|
|
21
|
-
curly: ['error', 'all'],
|
|
22
|
-
|
|
23
|
-
// Enforces return statements in callbacks of array's methods
|
|
24
|
-
// https://eslint.org/docs/rules/array-callback-return
|
|
25
|
-
'array-callback-return': [
|
|
26
|
-
'error',
|
|
27
|
-
{ allowImplicit: true, checkForEach: true }
|
|
28
|
-
],
|
|
29
|
-
|
|
30
|
-
// Enforce for loop update clause moving the counter in the right direction
|
|
31
|
-
// https://eslint.org/docs/latest/rules/for-direction
|
|
32
|
-
'for-direction': 'error',
|
|
33
|
-
|
|
34
|
-
// Enforce return statements in getters
|
|
35
|
-
// https://eslint.org/docs/latest/rules/getter-return
|
|
36
|
-
'getter-return': 'error',
|
|
37
|
-
|
|
38
|
-
// Disallow returning values from setters
|
|
39
|
-
// https://eslint.org/docs/latest/rules/no-setter-return
|
|
40
|
-
'no-setter-return': 'error',
|
|
41
|
-
|
|
42
|
-
// Rreat var statements as if they were block scoped
|
|
43
|
-
// https://eslint.org/docs/rules/block-scoped-var
|
|
44
|
-
'block-scoped-var': 'error',
|
|
45
|
-
|
|
46
|
-
// Specify the maximum cyclomatic complexity allowed in a program
|
|
47
|
-
// https://eslint.org/docs/rules/complexity
|
|
48
|
-
complexity: ['error', 20],
|
|
49
|
-
|
|
50
|
-
// Enforce that class methods use "this"
|
|
51
|
-
// https://eslint.org/docs/rules/class-methods-use-this
|
|
52
|
-
'class-methods-use-this': [
|
|
53
|
-
'error',
|
|
54
|
-
{
|
|
55
|
-
exceptMethods: []
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
|
|
59
|
-
// Require return statements to either always or never specify values
|
|
60
|
-
// https://eslint.org/docs/rules/consistent-return
|
|
61
|
-
'consistent-return': ['error', { treatUndefinedAsUnspecified: true }],
|
|
62
|
-
|
|
63
|
-
// Disallow comparing against -0
|
|
64
|
-
// https://eslint.org/docs/latest/rules/no-compare-neg-zero
|
|
65
|
-
'no-compare-neg-zero': 'error',
|
|
66
|
-
|
|
67
|
-
// Disallow sparse arrays
|
|
68
|
-
// https://eslint.org/docs/latest/rules/no-sparse-arrays
|
|
69
|
-
'no-sparse-arrays': 'error',
|
|
70
|
-
|
|
71
|
-
// Disallow expressions where the operation doesn't affect the value
|
|
72
|
-
// https://eslint.org/docs/latest/rules/no-constant-binary-expression
|
|
73
|
-
'no-constant-binary-expression': 'error',
|
|
74
|
-
|
|
75
|
-
// Require default case in switch statements
|
|
76
|
-
// https://eslint.org/docs/rules/default-case
|
|
77
|
-
'default-case': ['error'],
|
|
78
|
-
|
|
79
|
-
// Enforce default clauses in switch statements to be last
|
|
80
|
-
// https://eslint.org/docs/rules/default-case-last
|
|
81
|
-
'default-case-last': 'error',
|
|
82
|
-
|
|
83
|
-
// https://eslint.org/docs/rules/default-param-last
|
|
84
|
-
'default-param-last': 'error',
|
|
85
|
-
|
|
86
|
-
// Encourages use of dot notation whenever possible
|
|
87
|
-
// https://eslint.org/docs/rules/dot-notation
|
|
88
|
-
'dot-notation': ['error', { allowKeywords: true }],
|
|
89
|
-
|
|
90
|
-
// Require the use of === and !==
|
|
91
|
-
// https://eslint.org/docs/latest/rules/eqeqeq
|
|
92
|
-
eqeqeq: ['error', 'always'],
|
|
93
|
-
|
|
94
|
-
// Enforces consistent newlines before or after dots
|
|
95
|
-
// https://eslint.org/docs/rules/dot-location
|
|
96
|
-
'dot-location': ['error', 'property'],
|
|
97
|
-
|
|
98
|
-
// Make sure for-in loops have an if statement
|
|
99
|
-
// https://eslint.org/docs/rules/guard-for-in
|
|
100
|
-
'guard-for-in': 'error',
|
|
101
|
-
|
|
102
|
-
// Disallow the use of alert, confirm, and prompt
|
|
103
|
-
// https://eslint.org/docs/rules/no-alert
|
|
104
|
-
'no-alert': 'error',
|
|
105
|
-
|
|
106
|
-
// Disallow lexical declarations in case/default clauses
|
|
107
|
-
// https://eslint.org/docs/rules/no-case-declarations
|
|
108
|
-
'no-case-declarations': 'error',
|
|
109
|
-
|
|
110
|
-
// Disallow returning value in constructor
|
|
111
|
-
// https://eslint.org/docs/rules/no-constructor-return
|
|
112
|
-
'no-constructor-return': 'error',
|
|
113
|
-
|
|
114
|
-
// Disallow else after a return in an if
|
|
115
|
-
// https://eslint.org/docs/rules/no-else-return
|
|
116
|
-
'no-else-return': ['error', { allowElseIf: false }],
|
|
117
|
-
|
|
118
|
-
// Disallow empty functions, except for standalone funcs/arrows
|
|
119
|
-
// https://eslint.org/docs/rules/no-empty-function
|
|
120
|
-
'no-empty-function': [
|
|
121
|
-
'error',
|
|
122
|
-
{
|
|
123
|
-
allow: ['arrowFunctions', 'functions', 'methods']
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
|
-
|
|
127
|
-
// Disallow empty destructuring patterns
|
|
128
|
-
// https://eslint.org/docs/rules/no-empty-pattern
|
|
129
|
-
'no-empty-pattern': 'error',
|
|
130
|
-
|
|
131
|
-
// Disallow comparisons to null without a type-checking operator
|
|
132
|
-
// https://eslint.org/docs/rules/no-eq-null
|
|
133
|
-
'no-eq-null': 'off',
|
|
134
|
-
|
|
135
|
-
// Disallow adding to native types
|
|
136
|
-
// https://eslint.org/docs/rules/no-extend-native
|
|
137
|
-
'no-extend-native': 'error',
|
|
138
|
-
|
|
139
|
-
// Disallow Unnecessary Labels
|
|
140
|
-
// https://eslint.org/docs/rules/no-extra-label
|
|
141
|
-
'no-extra-label': 'error',
|
|
142
|
-
|
|
143
|
-
// Disallow fallthrough of case statements
|
|
144
|
-
// https://eslint.org/docs/rules/no-fallthrough
|
|
145
|
-
'no-fallthrough': 'error',
|
|
146
|
-
|
|
147
|
-
// Disallow the use of leading or trailing decimal points in numeric literals
|
|
148
|
-
// https://eslint.org/docs/rules/no-floating-decimal
|
|
149
|
-
'no-floating-decimal': 'error',
|
|
150
|
-
|
|
151
|
-
// Disallow reassignments of native objects or read-only globals
|
|
152
|
-
// https://eslint.org/docs/rules/no-global-assign
|
|
153
|
-
'no-global-assign': ['error', { exceptions: [] }],
|
|
154
|
-
|
|
155
|
-
// Deprecated in favor of no-global-assign
|
|
156
|
-
// https://eslint.org/docs/rules/no-native-reassign
|
|
157
|
-
'no-native-reassign': 'off',
|
|
158
|
-
|
|
159
|
-
// Disallow implicit type conversions
|
|
160
|
-
// https://eslint.org/docs/rules/no-implicit-coercion
|
|
161
|
-
'no-implicit-coercion': 'error',
|
|
162
|
-
|
|
163
|
-
// Disallow reassigning function declarations
|
|
164
|
-
// https://eslint.org/docs/latest/rules/no-func-assign
|
|
165
|
-
'no-func-assign': 'error',
|
|
166
|
-
|
|
167
|
-
// Disallow assigning to imported bindings
|
|
168
|
-
// https://eslint.org/docs/latest/rules/no-import-assign
|
|
169
|
-
'no-import-assign': 'error',
|
|
170
|
-
|
|
171
|
-
// Disallow var and named functions in global scope
|
|
172
|
-
// https://eslint.org/docs/rules/no-implicit-globals
|
|
173
|
-
'no-implicit-globals': 'off',
|
|
174
|
-
|
|
175
|
-
// Disallow this keywords outside of classes or class-like objects
|
|
176
|
-
// https://eslint.org/docs/rules/no-invalid-this
|
|
177
|
-
'no-invalid-this': 'off',
|
|
178
|
-
|
|
179
|
-
// Disallow variable or function declarations in nested blocks
|
|
180
|
-
// https://eslint.org/docs/latest/rules/no-inner-declarations
|
|
181
|
-
'no-inner-declarations': ['error', 'both'],
|
|
182
|
-
|
|
183
|
-
// Disallow usage of __iterator__ property
|
|
184
|
-
// https://eslint.org/docs/rules/no-iterator
|
|
185
|
-
'no-iterator': 'error',
|
|
186
|
-
|
|
187
|
-
// Disallow use of labels for anything other than loops and switches
|
|
188
|
-
// https://eslint.org/docs/rules/no-labels
|
|
189
|
-
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
|
190
|
-
|
|
191
|
-
// Disallow unnecessary nested blocks
|
|
192
|
-
// https://eslint.org/docs/rules/no-lone-blocks
|
|
193
|
-
'no-lone-blocks': 'error',
|
|
194
|
-
|
|
195
|
-
// Disallow use of multiple spaces
|
|
196
|
-
// https://eslint.org/docs/rules/no-multi-spaces
|
|
197
|
-
'no-multi-spaces': [
|
|
198
|
-
'error',
|
|
199
|
-
{
|
|
200
|
-
ignoreEOLComments: false
|
|
201
|
-
}
|
|
202
|
-
],
|
|
203
|
-
|
|
204
|
-
// Disallow use of multiline strings
|
|
205
|
-
// https://eslint.org/docs/rules/no-multi-str
|
|
206
|
-
'no-multi-str': 'error',
|
|
207
|
-
|
|
208
|
-
// Disallow use of new operator when not part of the assignment or comparison
|
|
209
|
-
// https://eslint.org/docs/rules/no-new
|
|
210
|
-
'no-new': 'error',
|
|
211
|
-
|
|
212
|
-
// Disallows creating new instances of String, Number, and Boolean
|
|
213
|
-
// https://eslint.org/docs/rules/no-new-wrappers
|
|
214
|
-
'no-new-wrappers': 'error',
|
|
215
|
-
|
|
216
|
-
// Disallow use of (old style) octal literals
|
|
217
|
-
// https://eslint.org/docs/rules/no-octal
|
|
218
|
-
'no-octal': 'error',
|
|
219
|
-
|
|
220
|
-
// Disallow use of octal escape sequences in string literals, such as
|
|
221
|
-
// Var foo = 'Copyright \251';
|
|
222
|
-
// https://eslint.org/docs/rules/no-octal-escape
|
|
223
|
-
'no-octal-escape': 'error',
|
|
224
|
-
|
|
225
|
-
// Disallow reassignment of function parameters
|
|
226
|
-
// Disallow parameter object manipulation except for specific exclusions
|
|
227
|
-
// Rule: https://eslint.org/docs/rules/no-param-reassign.html
|
|
228
|
-
'no-param-reassign': [
|
|
229
|
-
'error',
|
|
230
|
-
{
|
|
231
|
-
ignorePropertyModificationsForRegex: [
|
|
232
|
-
'draft',
|
|
233
|
-
'context2D',
|
|
234
|
-
'canvasElement'
|
|
235
|
-
]
|
|
236
|
-
}
|
|
237
|
-
],
|
|
238
|
-
|
|
239
|
-
// Disallow declaring the same variable more than once
|
|
240
|
-
// https://eslint.org/docs/rules/no-redeclare
|
|
241
|
-
'no-redeclare': 'error',
|
|
242
|
-
|
|
243
|
-
// Disallow certain object properties
|
|
244
|
-
// https://eslint.org/docs/rules/no-restricted-properties
|
|
245
|
-
'no-restricted-properties': [
|
|
246
|
-
'error',
|
|
247
|
-
{
|
|
248
|
-
object: 'arguments',
|
|
249
|
-
property: 'callee',
|
|
250
|
-
message: 'arguments.callee is deprecated'
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
object: 'global',
|
|
254
|
-
property: 'isFinite',
|
|
255
|
-
message: 'Please use Number.isFinite instead'
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
object: 'self',
|
|
259
|
-
property: 'isFinite',
|
|
260
|
-
message: 'Please use Number.isFinite instead'
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
object: 'window',
|
|
264
|
-
property: 'isFinite',
|
|
265
|
-
message: 'Please use Number.isFinite instead'
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
object: 'global',
|
|
269
|
-
property: 'isNaN',
|
|
270
|
-
message: 'Please use Number.isNaN instead'
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
object: 'self',
|
|
274
|
-
property: 'isNaN',
|
|
275
|
-
message: 'Please use Number.isNaN instead'
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
object: 'window',
|
|
279
|
-
property: 'isNaN',
|
|
280
|
-
message: 'Please use Number.isNaN instead'
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
object: 'Math',
|
|
284
|
-
property: 'pow',
|
|
285
|
-
message: 'Use the exponentiation operator (**) instead.'
|
|
286
|
-
}
|
|
287
|
-
],
|
|
288
|
-
|
|
289
|
-
// Disallow use of assignment in return statement
|
|
290
|
-
// https://eslint.org/docs/rules/no-return-assign
|
|
291
|
-
'no-return-assign': ['error', 'always'],
|
|
292
|
-
|
|
293
|
-
// Disallow ternary operators when simpler alternatives exist
|
|
294
|
-
// https://eslint.org/docs/rules/no-unneeded-ternary
|
|
295
|
-
'no-unneeded-ternary': 'error',
|
|
296
|
-
|
|
297
|
-
// Disallow assignments where both sides are exactly the same
|
|
298
|
-
// https://eslint.org/docs/rules/no-self-assign
|
|
299
|
-
'no-self-assign': [
|
|
300
|
-
'error',
|
|
301
|
-
{
|
|
302
|
-
props: true
|
|
303
|
-
}
|
|
304
|
-
],
|
|
305
|
-
|
|
306
|
-
// Disallow comparisons where both sides are exactly the same
|
|
307
|
-
// https://eslint.org/docs/rules/no-self-compare
|
|
308
|
-
'no-self-compare': 'error',
|
|
309
|
-
|
|
310
|
-
// Restrict what can be thrown as an exception
|
|
311
|
-
// https://eslint.org/docs/rules/no-throw-literal
|
|
312
|
-
'no-throw-literal': 'error',
|
|
313
|
-
|
|
314
|
-
// Disallow unmodified conditions of loops
|
|
315
|
-
// https://eslint.org/docs/rules/no-unmodified-loop-condition
|
|
316
|
-
'no-unmodified-loop-condition': 'error',
|
|
317
|
-
|
|
318
|
-
// Disallow negating the left operand of relational operators
|
|
319
|
-
// https://eslint.org/docs/latest/rules/no-unsafe-negation
|
|
320
|
-
'no-unsafe-negation': 'error',
|
|
321
|
-
|
|
322
|
-
// Enforce comparing typeof expressions against valid strings
|
|
323
|
-
// https://eslint.org/docs/latest/rules/valid-typeof
|
|
324
|
-
'valid-typeof': 'error',
|
|
325
|
-
|
|
326
|
-
// Require calls to isNaN() when checking for NaN
|
|
327
|
-
// https://eslint.org/docs/latest/rules/use-isnan
|
|
328
|
-
'use-isnan': 'error',
|
|
329
|
-
|
|
330
|
-
// Disallow unreachable code after return, throw, continue, and break statements
|
|
331
|
-
// https://eslint.org/docs/latest/rules/no-unreachable
|
|
332
|
-
'no-unreachable': 'error',
|
|
333
|
-
|
|
334
|
-
// Disallow usage of expressions in statement position
|
|
335
|
-
// https://eslint.org/docs/rules/no-unused-expressions
|
|
336
|
-
'no-unused-expressions': [
|
|
337
|
-
'error',
|
|
338
|
-
{
|
|
339
|
-
allowShortCircuit: false,
|
|
340
|
-
allowTernary: false,
|
|
341
|
-
allowTaggedTemplates: false
|
|
342
|
-
}
|
|
343
|
-
],
|
|
344
|
-
|
|
345
|
-
// Disallow unused labels
|
|
346
|
-
// https://eslint.org/docs/rules/no-unused-labels
|
|
347
|
-
'no-unused-labels': 'error',
|
|
348
|
-
|
|
349
|
-
// Disallow unnecessary .call() and .apply()
|
|
350
|
-
// https://eslint.org/docs/rules/no-useless-call
|
|
351
|
-
'no-useless-call': 'off',
|
|
352
|
-
|
|
353
|
-
// Disallow unnecessary catch clauses
|
|
354
|
-
// https://eslint.org/docs/rules/no-useless-catch
|
|
355
|
-
'no-useless-catch': 'error',
|
|
356
|
-
|
|
357
|
-
// Disallow useless string concatenation
|
|
358
|
-
// https://eslint.org/docs/rules/no-useless-concat
|
|
359
|
-
'no-useless-concat': 'error',
|
|
360
|
-
|
|
361
|
-
// Disallow unnecessary string escaping
|
|
362
|
-
// https://eslint.org/docs/rules/no-useless-escape
|
|
363
|
-
'no-useless-escape': 'error',
|
|
364
|
-
|
|
365
|
-
// Disallow redundant return; keywords
|
|
366
|
-
// https://eslint.org/docs/rules/no-useless-return
|
|
367
|
-
'no-useless-return': 'error',
|
|
368
|
-
|
|
369
|
-
// Require using Error objects as Promise rejection reasons
|
|
370
|
-
// https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
371
|
-
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
|
|
372
|
-
|
|
373
|
-
// Suggest using named capture group in regular expression
|
|
374
|
-
// https://eslint.org/docs/rules/prefer-named-capture-group
|
|
375
|
-
'prefer-named-capture-group': 'off',
|
|
376
|
-
|
|
377
|
-
// https://eslint.org/docs/rules/prefer-regex-literals
|
|
378
|
-
'prefer-regex-literals': [
|
|
379
|
-
'error',
|
|
380
|
-
{
|
|
381
|
-
disallowRedundantWrapping: true
|
|
382
|
-
}
|
|
383
|
-
],
|
|
384
|
-
|
|
385
|
-
// Require use of the second argument for parseInt()
|
|
386
|
-
// https://eslint.org/docs/rules/radix
|
|
387
|
-
radix: 'error',
|
|
388
|
-
|
|
389
|
-
// Enforce the use of u flag on RegExp
|
|
390
|
-
// https://eslint.org/docs/rules/require-unicode-regexp
|
|
391
|
-
'require-unicode-regexp': 'off',
|
|
392
|
-
|
|
393
|
-
// Disallow creating a variable and immediately mutating it
|
|
394
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-immediate-mutation.md
|
|
395
|
-
'unicorn/no-immediate-mutation': 'error',
|
|
396
|
-
|
|
397
|
-
// Disallow useless arguments when constructing Set, Map, WeakSet, WeakMap
|
|
398
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-collection-argument.md
|
|
399
|
-
'unicorn/no-useless-collection-argument': 'error',
|
|
400
|
-
|
|
401
|
-
// Prefer class fields over constructor assignments
|
|
402
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-class-fields.md
|
|
403
|
-
'unicorn/prefer-class-fields': 'error',
|
|
404
|
-
|
|
405
|
-
// Prefer Array#toReversed() over Array#reverse() to avoid mutation
|
|
406
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reverse.md
|
|
407
|
-
'unicorn/no-array-reverse': 'error',
|
|
408
|
-
|
|
409
|
-
// Require using new when throwing an error
|
|
410
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md
|
|
411
|
-
'unicorn/throw-new-error': 'error',
|
|
412
|
-
|
|
413
|
-
// Prefer includes() over indexOf() when checking for existence
|
|
414
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md
|
|
415
|
-
'unicorn/prefer-includes': 'error',
|
|
416
|
-
|
|
417
|
-
// Prefer find() over filter()[0] when searching for a single element
|
|
418
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-find.md
|
|
419
|
-
'unicorn/prefer-array-find': 'error',
|
|
420
|
-
|
|
421
|
-
// Prefer startsWith() and endsWith() over regex or slice comparisons
|
|
422
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md
|
|
423
|
-
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
424
|
-
|
|
425
|
-
// Prefer .at() for accessing elements by negative index
|
|
426
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-at.md
|
|
427
|
-
'unicorn/prefer-at': 'error',
|
|
428
|
-
|
|
429
|
-
// Prefer Number static properties over global ones
|
|
430
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-number-properties.md
|
|
431
|
-
'unicorn/prefer-number-properties': 'error',
|
|
432
|
-
|
|
433
|
-
// Prefer for...of over Array#forEach
|
|
434
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
|
|
435
|
-
'unicorn/no-array-for-each': 'error',
|
|
436
|
-
|
|
437
|
-
// Prefer Array#flat() over legacy techniques to flatten arrays
|
|
438
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
|
|
439
|
-
'unicorn/prefer-array-flat': 'error',
|
|
440
|
-
|
|
441
|
-
// Prefer flatMap() over map().flat()
|
|
442
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
|
|
443
|
-
'unicorn/prefer-array-flat-map': 'error',
|
|
444
|
-
|
|
445
|
-
// Disallow useless undefined
|
|
446
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md
|
|
447
|
-
'unicorn/no-useless-undefined': 'error',
|
|
448
|
-
|
|
449
|
-
// Prefer String#replaceAll() over regex with global flag
|
|
450
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
|
|
451
|
-
'unicorn/prefer-string-replace-all': 'error',
|
|
452
|
-
|
|
453
|
-
// Prefer String#trimStart() / String#trimEnd() over trimLeft() / trimRight()
|
|
454
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-trim-start-end.md
|
|
455
|
-
'unicorn/prefer-string-trim-start-end': 'error',
|
|
456
|
-
|
|
457
|
-
// Disallow if statements as the only statement in else blocks
|
|
458
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-lonely-if.md
|
|
459
|
-
'unicorn/no-lonely-if': 'error',
|
|
460
|
-
|
|
461
|
-
// Prefer RegExp#test() over String#match() for boolean checks
|
|
462
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-regexp-test.md
|
|
463
|
-
'unicorn/prefer-regexp-test': 'error',
|
|
464
|
-
|
|
465
|
-
// Prefer modern DOM APIs
|
|
466
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-dom-apis.md
|
|
467
|
-
'unicorn/prefer-modern-dom-apis': 'error',
|
|
468
|
-
|
|
469
|
-
// Prefer [...iterable] over Array.from(iterable)
|
|
470
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-spread.md
|
|
471
|
-
'unicorn/prefer-spread': 'off',
|
|
472
|
-
|
|
473
|
-
// Prefer omitting catch binding when unused
|
|
474
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md
|
|
475
|
-
'unicorn/prefer-optional-catch-binding': 'off',
|
|
476
|
-
|
|
477
|
-
// Disallow negated conditions when alternative exists
|
|
478
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-condition.md
|
|
479
|
-
'unicorn/no-negated-condition': 'off',
|
|
480
|
-
|
|
481
|
-
// Prefer TypeError for type-related errors
|
|
482
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-error.md
|
|
483
|
-
'unicorn/prefer-type-error': 'off',
|
|
484
|
-
|
|
485
|
-
// Prefer Date.now() over new Date().getTime()
|
|
486
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-date-now.md
|
|
487
|
-
'unicorn/prefer-date-now': 'error',
|
|
488
|
-
|
|
489
|
-
// Prefer === undefined over typeof === 'undefined'
|
|
490
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-typeof-undefined.md
|
|
491
|
-
'unicorn/no-typeof-undefined': 'error',
|
|
492
|
-
|
|
493
|
-
// Prefer Object.fromEntries() over reduce to create objects
|
|
494
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-object-from-entries.md
|
|
495
|
-
'unicorn/prefer-object-from-entries': 'error',
|
|
496
|
-
|
|
497
|
-
// Prefer Set#has() over Array#includes() for frequent checks
|
|
498
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-set-has.md
|
|
499
|
-
'unicorn/prefer-set-has': 'off',
|
|
500
|
-
|
|
501
|
-
// Prefer some() over find() !== undefined for boolean checks
|
|
502
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md
|
|
503
|
-
'unicorn/prefer-array-some': 'error',
|
|
504
|
-
|
|
505
|
-
// Disallow new Array() and prefer Array.from({length: n})
|
|
506
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md
|
|
507
|
-
'unicorn/no-new-array': 'error',
|
|
508
|
-
|
|
509
|
-
// Prefer default parameters over reassignment
|
|
510
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-default-parameters.md
|
|
511
|
-
'unicorn/prefer-default-parameters': 'error',
|
|
512
|
-
|
|
513
|
-
// Prefer negative index over length minus index
|
|
514
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-negative-index.md
|
|
515
|
-
'unicorn/prefer-negative-index': 'error'
|
|
516
|
-
}
|
|
517
|
-
}
|