@will-stone/eslint-config 0.0.1
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 +7 -0
- package/eslint-config.js +151 -0
- package/package.json +44 -0
- package/rules/built-in.js +663 -0
- package/rules/import.js +63 -0
- package/rules/jest-ts.js +3 -0
- package/rules/jest.js +91 -0
- package/rules/jsx-a11y.js +149 -0
- package/rules/node.js +58 -0
- package/rules/prettier.js +3 -0
- package/rules/react.js +161 -0
- package/rules/switch-case.js +10 -0
- package/rules/typescript.js +299 -0
- package/rules/unicorn.js +281 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
/**
|
|
3
|
+
* Recommended to turn off these eslint built-in rules
|
|
4
|
+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/eslint-recommended.ts
|
|
5
|
+
*/
|
|
6
|
+
// ts(2335) & ts(2377)
|
|
7
|
+
'constructor-super': 'off',
|
|
8
|
+
// ts(2378)
|
|
9
|
+
'getter-return': 'off',
|
|
10
|
+
// ts(2588)
|
|
11
|
+
'no-const-assign': 'off',
|
|
12
|
+
// ts(2300)
|
|
13
|
+
'no-dupe-args': 'off',
|
|
14
|
+
// ts(2393) & ts(2300)
|
|
15
|
+
'no-dupe-class-members': 'off',
|
|
16
|
+
// ts(1117)
|
|
17
|
+
'no-dupe-keys': 'off',
|
|
18
|
+
// ts(2539)
|
|
19
|
+
'no-func-assign': 'off',
|
|
20
|
+
// ts(2539) & ts(2540)
|
|
21
|
+
'no-import-assign': 'off',
|
|
22
|
+
// ts(2588)
|
|
23
|
+
'no-new-symbol': 'off',
|
|
24
|
+
// ts(2349)
|
|
25
|
+
'no-obj-calls': 'off',
|
|
26
|
+
// ts(2408)
|
|
27
|
+
'no-setter-return': 'off',
|
|
28
|
+
// ts(2376)
|
|
29
|
+
'no-this-before-super': 'off',
|
|
30
|
+
// ts(2304)
|
|
31
|
+
'no-undef': 'off',
|
|
32
|
+
// ts(7027)
|
|
33
|
+
'no-unreachable': 'off',
|
|
34
|
+
// ts(2365) & ts(2360) & ts(2358)
|
|
35
|
+
'no-unsafe-negation': 'off',
|
|
36
|
+
// ts transpiles let/const to var, so no need for vars any more
|
|
37
|
+
'no-var': 'error',
|
|
38
|
+
// ts provides better types with const
|
|
39
|
+
'prefer-const': 'warn',
|
|
40
|
+
// ts provides better types with rest args over arguments
|
|
41
|
+
'prefer-rest-params': 'error',
|
|
42
|
+
// ts transpiles spread to apply, so no need for manual apply
|
|
43
|
+
'prefer-spread': 'error',
|
|
44
|
+
// ts(2367)
|
|
45
|
+
'valid-typeof': 'off',
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* TS Recommended
|
|
49
|
+
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.ts
|
|
50
|
+
*/
|
|
51
|
+
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
52
|
+
'@typescript-eslint/ban-ts-comment': 'error',
|
|
53
|
+
'@typescript-eslint/ban-types': 'error',
|
|
54
|
+
'@typescript-eslint/explicit-module-boundary-types': 'warn',
|
|
55
|
+
'@typescript-eslint/no-array-constructor': 'error',
|
|
56
|
+
'@typescript-eslint/no-empty-function': 'error',
|
|
57
|
+
'@typescript-eslint/no-empty-interface': 'error',
|
|
58
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
59
|
+
'@typescript-eslint/no-inferrable-types': 'error',
|
|
60
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
61
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
62
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
63
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
64
|
+
'@typescript-eslint/no-this-alias': 'error',
|
|
65
|
+
'@typescript-eslint/no-var-requires': 'error',
|
|
66
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
67
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
68
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
69
|
+
'no-array-constructor': 'off',
|
|
70
|
+
'no-empty-function': 'off',
|
|
71
|
+
'no-extra-semi': 'off',
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* These are for type checking which I don't use eslint for
|
|
75
|
+
*/
|
|
76
|
+
'@typescript-eslint/await-thenable': 'off',
|
|
77
|
+
'@typescript-eslint/consistent-type-exports': 'off',
|
|
78
|
+
'@typescript-eslint/dot-notation': 'off',
|
|
79
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
80
|
+
'@typescript-eslint/no-base-to-string': 'off',
|
|
81
|
+
'@typescript-eslint/no-confusing-void-expression': 'off',
|
|
82
|
+
'@typescript-eslint/no-duplicate-type-constituents': 'off',
|
|
83
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
84
|
+
'@typescript-eslint/no-for-in-array': 'off',
|
|
85
|
+
'@typescript-eslint/no-implied-eval': 'off',
|
|
86
|
+
'@typescript-eslint/no-meaningless-void-operator': 'off',
|
|
87
|
+
'@typescript-eslint/no-misused-promises': 'off',
|
|
88
|
+
'@typescript-eslint/no-mixed-enums': 'off',
|
|
89
|
+
'@typescript-eslint/no-redundant-type-constituents': 'off',
|
|
90
|
+
'@typescript-eslint/no-throw-literal': 'off',
|
|
91
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
|
|
92
|
+
'@typescript-eslint/no-unnecessary-condition': 'off',
|
|
93
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'off',
|
|
94
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
|
|
95
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
|
96
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
97
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
98
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
99
|
+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
|
|
100
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
101
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
102
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
|
103
|
+
'@typescript-eslint/prefer-includes': 'off',
|
|
104
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
|
|
105
|
+
'@typescript-eslint/prefer-optional-chain': 'off',
|
|
106
|
+
'@typescript-eslint/prefer-readonly': 'off',
|
|
107
|
+
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
|
|
108
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
|
|
109
|
+
'@typescript-eslint/prefer-regexp-exec': 'off',
|
|
110
|
+
'@typescript-eslint/prefer-return-this-type': 'off',
|
|
111
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
|
|
112
|
+
'@typescript-eslint/promise-function-async': 'off',
|
|
113
|
+
'@typescript-eslint/require-array-sort-compare': 'off',
|
|
114
|
+
'@typescript-eslint/require-await': 'off',
|
|
115
|
+
'@typescript-eslint/restrict-plus-operands': 'off',
|
|
116
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
117
|
+
'@typescript-eslint/return-await': 'off',
|
|
118
|
+
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
119
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'off',
|
|
120
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Off for Prettier
|
|
124
|
+
* https://github.com/prettier/eslint-config-prettier/blob/main/index.js
|
|
125
|
+
*/
|
|
126
|
+
'@typescript-eslint/block-spacing': 'off',
|
|
127
|
+
'@typescript-eslint/brace-style': 'off',
|
|
128
|
+
'@typescript-eslint/comma-dangle': 'off',
|
|
129
|
+
'@typescript-eslint/comma-spacing': 'off',
|
|
130
|
+
'@typescript-eslint/func-call-spacing': 'off',
|
|
131
|
+
'@typescript-eslint/indent': 'off',
|
|
132
|
+
'@typescript-eslint/key-spacing': 'off',
|
|
133
|
+
'@typescript-eslint/keyword-spacing': 'off',
|
|
134
|
+
'@typescript-eslint/lines-around-comment': 'off',
|
|
135
|
+
'@typescript-eslint/member-delimiter-style': 'off',
|
|
136
|
+
'@typescript-eslint/no-extra-parens': 'off',
|
|
137
|
+
'@typescript-eslint/no-extra-semi': 'off',
|
|
138
|
+
'@typescript-eslint/object-curly-spacing': 'off',
|
|
139
|
+
'@typescript-eslint/quotes': 'off',
|
|
140
|
+
'@typescript-eslint/semi': 'off',
|
|
141
|
+
'@typescript-eslint/space-before-blocks': 'off',
|
|
142
|
+
'@typescript-eslint/space-before-function-paren': 'off',
|
|
143
|
+
'@typescript-eslint/space-infix-ops': 'off',
|
|
144
|
+
'@typescript-eslint/type-annotation-spacing': 'off',
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Superseded by TS rules below
|
|
148
|
+
*/
|
|
149
|
+
'default-param-last': 'off',
|
|
150
|
+
'lines-between-class-members': 'off',
|
|
151
|
+
'no-duplicate-imports': 'off',
|
|
152
|
+
'no-invalid-this': 'off',
|
|
153
|
+
'no-loop-func': 'off',
|
|
154
|
+
'no-loss-of-precision': 'off',
|
|
155
|
+
'no-redeclare': 'off',
|
|
156
|
+
'no-restricted-imports': 'off',
|
|
157
|
+
'no-shadow': 'off',
|
|
158
|
+
'no-unused-expressions': 'off',
|
|
159
|
+
'no-unused-vars': 'off',
|
|
160
|
+
'no-use-before-define': 'off',
|
|
161
|
+
'no-useless-constructor': 'off',
|
|
162
|
+
'padding-line-between-statements': 'off',
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The rest
|
|
166
|
+
*/
|
|
167
|
+
// Requires using T[] over Array<T> for arrays
|
|
168
|
+
'@typescript-eslint/array-type': ['warn', { default: 'array' }],
|
|
169
|
+
// Bans // tslint:<rule-flag> comments from being used
|
|
170
|
+
'@typescript-eslint/ban-tslint-comment': 'warn',
|
|
171
|
+
// Ensures that literals on classes are exposed in a consistent style
|
|
172
|
+
'@typescript-eslint/class-literal-property-style': 'warn',
|
|
173
|
+
// https://typescript-eslint.io/rules/consistent-generic-constructors/
|
|
174
|
+
'@typescript-eslint/consistent-generic-constructors': 'warn',
|
|
175
|
+
// Enforce the use of the record type
|
|
176
|
+
'@typescript-eslint/consistent-indexed-object-style': 'warn',
|
|
177
|
+
// Enforces consistent usage of type assertions
|
|
178
|
+
'@typescript-eslint/consistent-type-assertions': 'error',
|
|
179
|
+
// Enforce using types for object type definitions
|
|
180
|
+
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
|
|
181
|
+
// Enforces consistent usage of type imports
|
|
182
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
183
|
+
'warn',
|
|
184
|
+
{
|
|
185
|
+
fixStyle: 'separate-type-imports',
|
|
186
|
+
prefer: 'type-imports',
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
// Enforce default parameters to be last
|
|
190
|
+
'@typescript-eslint/default-param-last': ['error'],
|
|
191
|
+
// Don't mind if functions do not have return types.
|
|
192
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
193
|
+
// Require explicit accessibility modifiers ("public") on class properties and methods
|
|
194
|
+
'@typescript-eslint/explicit-member-accessibility': 'warn',
|
|
195
|
+
// Initialise vairables however you like
|
|
196
|
+
'@typescript-eslint/init-declarations': 'off',
|
|
197
|
+
'@typescript-eslint/lines-between-class-members': [
|
|
198
|
+
'warn',
|
|
199
|
+
'always',
|
|
200
|
+
{ exceptAfterOverload: true },
|
|
201
|
+
],
|
|
202
|
+
// Require a consistent member declaration order
|
|
203
|
+
'@typescript-eslint/member-ordering': 'error',
|
|
204
|
+
// ❌
|
|
205
|
+
// interface T1 {
|
|
206
|
+
// func(arg: string): number;
|
|
207
|
+
// }
|
|
208
|
+
// ✅
|
|
209
|
+
// interface T1 {
|
|
210
|
+
// func: (arg: string) => number;
|
|
211
|
+
// }
|
|
212
|
+
'@typescript-eslint/method-signature-style': 'warn',
|
|
213
|
+
// Disallow non-null assertion in locations that may be confusing
|
|
214
|
+
'@typescript-eslint/no-confusing-non-null-assertion': 'warn',
|
|
215
|
+
// Disallow duplicate class members
|
|
216
|
+
'@typescript-eslint/no-dupe-class-members': 'error',
|
|
217
|
+
// ❌
|
|
218
|
+
// enum E {
|
|
219
|
+
// A = 0,
|
|
220
|
+
// B = 0,
|
|
221
|
+
// }
|
|
222
|
+
// ✅
|
|
223
|
+
// enum E {
|
|
224
|
+
// A = 0,
|
|
225
|
+
// B = 1,
|
|
226
|
+
// }
|
|
227
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
228
|
+
// Deleting missing key/value is safe
|
|
229
|
+
'@typescript-eslint/no-dynamic-delete': 'off',
|
|
230
|
+
// ❌ const bar = foo!!!.bar
|
|
231
|
+
// ✅ const bar = foo!.bar
|
|
232
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'warn',
|
|
233
|
+
// Warns when a class is accidentally used as a namespace
|
|
234
|
+
'@typescript-eslint/no-extraneous-class': 'error',
|
|
235
|
+
'@typescript-eslint/no-import-type-side-effects': 'warn',
|
|
236
|
+
// Disallow this keywords outside of classes or class-like objects
|
|
237
|
+
'@typescript-eslint/no-invalid-this': 'error',
|
|
238
|
+
// Disallows usage of void type outside of generic or return types
|
|
239
|
+
'@typescript-eslint/no-invalid-void-type': 'error',
|
|
240
|
+
// Disallow function declarations that contain unsafe references inside loop statements
|
|
241
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
242
|
+
// Disallow literal numbers that lose precision
|
|
243
|
+
'@typescript-eslint/no-loss-of-precision': ['error'],
|
|
244
|
+
// Disallowing magic numbers causes all sorts of problems
|
|
245
|
+
'@typescript-eslint/no-magic-numbers': 'off',
|
|
246
|
+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
|
247
|
+
'@typescript-eslint/no-redeclare': 'error',
|
|
248
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
249
|
+
'@typescript-eslint/no-restricted-imports': 'off',
|
|
250
|
+
// Disallow variable declarations from shadowing variables declared in the outer scope
|
|
251
|
+
'@typescript-eslint/no-shadow': ['error'],
|
|
252
|
+
// Aliasing can be useful
|
|
253
|
+
'@typescript-eslint/no-type-alias': 'off',
|
|
254
|
+
// Disallows unnecessary constraints on generic types
|
|
255
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
|
|
256
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
257
|
+
// Aims to eliminate unused expressions which have no effect on the state of the program.
|
|
258
|
+
'@typescript-eslint/no-unused-expressions': ['error'],
|
|
259
|
+
// Variables must be used unless name ends with "ignored"
|
|
260
|
+
'@typescript-eslint/no-unused-vars': [
|
|
261
|
+
'error',
|
|
262
|
+
{
|
|
263
|
+
// Useful for extracting args from props and ignoring them:
|
|
264
|
+
// { style: _style, ...restProps }
|
|
265
|
+
argsIgnorePattern: '^_',
|
|
266
|
+
varsIgnorePattern: '[iI]gnored',
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
270
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
271
|
+
// Disallow empty exports that don't change anything in a module file
|
|
272
|
+
'@typescript-eslint/no-useless-empty-export': 'warn',
|
|
273
|
+
'@typescript-eslint/padding-line-between-statements': [
|
|
274
|
+
'error',
|
|
275
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-block-like' },
|
|
276
|
+
{ blankLine: 'always', next: 'multiline-block-like', prev: '*' },
|
|
277
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-const' },
|
|
278
|
+
{ blankLine: 'always', next: 'multiline-const', prev: '*' },
|
|
279
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-let' },
|
|
280
|
+
{ blankLine: 'always', next: 'multiline-let', prev: '*' },
|
|
281
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-var' },
|
|
282
|
+
{ blankLine: 'always', next: 'multiline-var', prev: '*' },
|
|
283
|
+
],
|
|
284
|
+
// Not sure I need this, how many classes do I write?!
|
|
285
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/parameter-properties.md
|
|
286
|
+
'@typescript-eslint/parameter-properties': 'off',
|
|
287
|
+
'@typescript-eslint/prefer-enum-initializers': 'error',
|
|
288
|
+
// Unicorn does this better by providing a fixer
|
|
289
|
+
'@typescript-eslint/prefer-for-of': 'off',
|
|
290
|
+
'@typescript-eslint/prefer-function-type': 'warn',
|
|
291
|
+
// Require that all enum members be literal values to prevent unintended enum member name shadow issues.
|
|
292
|
+
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
|
293
|
+
// Recommends using // @ts-expect-error over // @ts-ignore
|
|
294
|
+
'@typescript-eslint/prefer-ts-expect-error': 'warn',
|
|
295
|
+
'@typescript-eslint/sort-type-constituents': 'warn',
|
|
296
|
+
// Not sure if required yet. Might be too strict and produce noist code.
|
|
297
|
+
'@typescript-eslint/typedef': 'off',
|
|
298
|
+
'@typescript-eslint/unified-signatures': 'error',
|
|
299
|
+
}
|
package/rules/unicorn.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
// This rule is superseded by the unicorn version below
|
|
3
|
+
'no-nested-ternary': 'off',
|
|
4
|
+
// Improve regexes by making them shorter, consistent, and safer
|
|
5
|
+
'unicorn/better-regex': 'warn',
|
|
6
|
+
// Catch error argument name should be "error"
|
|
7
|
+
'unicorn/catch-error-name': 'error',
|
|
8
|
+
// Use destructured variables over properties
|
|
9
|
+
'unicorn/consistent-destructuring': 'warn',
|
|
10
|
+
// Move function definitions to the highest possible scope
|
|
11
|
+
'unicorn/consistent-function-scoping': [
|
|
12
|
+
'error',
|
|
13
|
+
{ checkArrowFunctions: false },
|
|
14
|
+
],
|
|
15
|
+
// Custom Error classes must conform to standard
|
|
16
|
+
'unicorn/custom-error-definition': 'warn',
|
|
17
|
+
// Enforce no spaces between braces
|
|
18
|
+
'unicorn/empty-brace-spaces': 'warn',
|
|
19
|
+
// Enforces a message value to be passed in when throwing built-in Error
|
|
20
|
+
'unicorn/error-message': 'error',
|
|
21
|
+
// Enforces defining escape sequence values with uppercase characters rather
|
|
22
|
+
// than lowercase ones. This promotes readability by making the escaped
|
|
23
|
+
// value more distinguishable from the identifier.
|
|
24
|
+
'unicorn/escape-case': 'warn',
|
|
25
|
+
// Allows todo/fixme to be given expiry conditions and will error when met
|
|
26
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/expiring-todo-comments.md
|
|
27
|
+
'unicorn/expiring-todo-comments': 'error',
|
|
28
|
+
// Don't care how if(blah.length) is checked
|
|
29
|
+
'unicorn/explicit-length-check': 'off',
|
|
30
|
+
// TODO [eslint-plugin-unicorn@>=20] turn on when this feature added:
|
|
31
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/203
|
|
32
|
+
'unicorn/filename-case': 'off',
|
|
33
|
+
// Enforces requiring index file with . instead of ./, ./index or ./index.js
|
|
34
|
+
// Turned off for imports where this can mess with ESM.
|
|
35
|
+
'unicorn/import-index': ['warn', { ignoreImports: true }],
|
|
36
|
+
// Not sure if this is useful yet
|
|
37
|
+
'unicorn/import-style': 'off',
|
|
38
|
+
// Enforce the use of new for all builtins, except String, Number and Boolean
|
|
39
|
+
'unicorn/new-for-builtins': 'warn',
|
|
40
|
+
// Enforce specifying rules to disable in eslint-disable comments
|
|
41
|
+
'unicorn/no-abusive-eslint-disable': 'error',
|
|
42
|
+
// Allow passing a function reference directly to iterator methods
|
|
43
|
+
'unicorn/no-array-callback-reference': 'off',
|
|
44
|
+
// Prefer for…of over Array#forEach(…)
|
|
45
|
+
'unicorn/no-array-for-each': 'warn',
|
|
46
|
+
// Disallow using the this argument in array methods
|
|
47
|
+
'unicorn/no-array-method-this-argument': 'warn',
|
|
48
|
+
// Enforce combining multiple Array#push() into one call
|
|
49
|
+
'unicorn/no-array-push-push': 'warn',
|
|
50
|
+
// for..of is much easier to read
|
|
51
|
+
'unicorn/no-array-reduce': 'error',
|
|
52
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-expression-member.md
|
|
53
|
+
'unicorn/no-await-expression-member': 'warn',
|
|
54
|
+
// Do not use leading/trailing space between console.log parameters
|
|
55
|
+
'unicorn/no-console-spaces': 'warn',
|
|
56
|
+
// Do not use document.cookie directly
|
|
57
|
+
'unicorn/no-document-cookie': 'error',
|
|
58
|
+
// Disallow empty files
|
|
59
|
+
// TODO turn back on when it can exclude files. As this warns about the
|
|
60
|
+
// auto-generated next-env.d.ts file.
|
|
61
|
+
'unicorn/no-empty-file': 'off',
|
|
62
|
+
// Do not use a for loop that can be replaced with a for-of loop
|
|
63
|
+
'unicorn/no-for-loop': 'warn',
|
|
64
|
+
// Enforce the use of Unicode escapes instead of hexadecimal escapes
|
|
65
|
+
'unicorn/no-hex-escape': 'warn',
|
|
66
|
+
// Require Array.isArray() instead of instanceof Array
|
|
67
|
+
'unicorn/no-instanceof-array': 'warn',
|
|
68
|
+
// The removeEventListener function must be called with a reference to the same
|
|
69
|
+
// function that was passed to addEventListener.
|
|
70
|
+
'unicorn/no-invalid-remove-event-listener': 'error',
|
|
71
|
+
// Disallow identifiers (var names) starting with new.
|
|
72
|
+
// Do not check properties and allow "class" so that "className" is allowed.
|
|
73
|
+
'unicorn/no-keyword-prefix': [
|
|
74
|
+
'error',
|
|
75
|
+
{ checkProperties: false, disallowedPrefixes: ['new'] },
|
|
76
|
+
],
|
|
77
|
+
// This rule adds onto the built-in no-lonely-if rule, which only forbids if
|
|
78
|
+
// statements in else, not in if.
|
|
79
|
+
'unicorn/no-lonely-if': 'warn',
|
|
80
|
+
// This is an improved version of the no-negated-condition ESLint rule that
|
|
81
|
+
// makes it automatically fixable. ESLint did not want to make it fixable.
|
|
82
|
+
'unicorn/no-negated-condition': 'warn',
|
|
83
|
+
// Improved version of the no-nested-ternary ESLint rule, which allows cases
|
|
84
|
+
// where the nested ternary is only one level and wrapped in parens.
|
|
85
|
+
'unicorn/no-nested-ternary': 'warn',
|
|
86
|
+
// Disallow new Array()
|
|
87
|
+
'unicorn/no-new-array': 'warn',
|
|
88
|
+
// Enforce the use of Buffer.from() and Buffer.alloc() instead of the
|
|
89
|
+
// deprecated new Buffer()
|
|
90
|
+
'unicorn/no-new-buffer': 'warn',
|
|
91
|
+
// Allow the use of the null literal, it useful for React components and empty JSON values.
|
|
92
|
+
'unicorn/no-null': 'off',
|
|
93
|
+
// Disallow the use of objects as default parameters
|
|
94
|
+
'unicorn/no-object-as-default-parameter': 'error',
|
|
95
|
+
// Extension to ESLint's no-process-exit rule, that allows process.exit() to
|
|
96
|
+
// be called in files that start with a hashbang → #!/usr/bin/env node
|
|
97
|
+
'unicorn/no-process-exit': 'error',
|
|
98
|
+
// A class with only static members could just be an object instead
|
|
99
|
+
'unicorn/no-static-only-class': 'error',
|
|
100
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-thenable.md
|
|
101
|
+
'unicorn/no-thenable': 'error',
|
|
102
|
+
// Disallow assigning this to a variable
|
|
103
|
+
'unicorn/no-this-assignment': 'error',
|
|
104
|
+
// Checking if a value is undefined by using typeof value === 'undefined' is needlessly verbose.
|
|
105
|
+
'unicorn/no-typeof-undefined': 'warn',
|
|
106
|
+
// Disallow awaiting non-promise values
|
|
107
|
+
'unicorn/no-unnecessary-await': 'warn',
|
|
108
|
+
// Disallow [,, foo], use ignored vars instead
|
|
109
|
+
'unicorn/no-unreadable-array-destructuring': 'error',
|
|
110
|
+
// IIFE with parenthesized arrow function body is considered unreadable
|
|
111
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md
|
|
112
|
+
'unicorn/no-unreadable-iife': 'error',
|
|
113
|
+
// Uses safe-regex to disallow potentially catastrophic exponential-time regular expressions.
|
|
114
|
+
// Turned off for now, even Sindre doesn't like it: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/153
|
|
115
|
+
'unicorn/no-unsafe-regex': 'off',
|
|
116
|
+
// Recommended config turned this off so I will too
|
|
117
|
+
'unicorn/no-unused-properties': 'off',
|
|
118
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-fallback-in-spread.md
|
|
119
|
+
'unicorn/no-useless-fallback-in-spread': 'warn',
|
|
120
|
+
// Disallow useless array length check
|
|
121
|
+
'unicorn/no-useless-length-check': 'warn',
|
|
122
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md
|
|
123
|
+
'unicorn/no-useless-promise-resolve-reject': 'warn',
|
|
124
|
+
// Disallow useless spread
|
|
125
|
+
'unicorn/no-useless-spread': 'warn',
|
|
126
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md
|
|
127
|
+
'unicorn/no-useless-switch-case': 'error',
|
|
128
|
+
// ❌ let foo = undefined;
|
|
129
|
+
// ✅ let foo;
|
|
130
|
+
'unicorn/no-useless-undefined': 'warn',
|
|
131
|
+
// Disallow number literals with zero fractions or dangling dots
|
|
132
|
+
'unicorn/no-zero-fractions': 'warn',
|
|
133
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md
|
|
134
|
+
'unicorn/number-literal-case': 'warn',
|
|
135
|
+
// Enforce the style of numeric separators by correctly grouping digits
|
|
136
|
+
'unicorn/numeric-separators-style': 'warn',
|
|
137
|
+
// Prefer .addEventListener() and .removeEventListener() over on-functions
|
|
138
|
+
'unicorn/prefer-add-event-listener': 'warn',
|
|
139
|
+
// Prefer .find(…) over the first element from .filter(…)
|
|
140
|
+
'unicorn/prefer-array-find': 'warn',
|
|
141
|
+
// Prefer Array#flat() over legacy techniques to flatten arrays
|
|
142
|
+
'unicorn/prefer-array-flat': 'warn',
|
|
143
|
+
// Prefer .flatMap(…) over .map(…).flat()
|
|
144
|
+
'unicorn/prefer-array-flat-map': 'warn',
|
|
145
|
+
// Prefer Array#indexOf() over Array#findIndex() when looking for the index of an item
|
|
146
|
+
'unicorn/prefer-array-index-of': 'warn',
|
|
147
|
+
// Prefer using Array#some over Array#find when ensuring at least one element
|
|
148
|
+
// in the array passes a given check.
|
|
149
|
+
'unicorn/prefer-array-some': 'error',
|
|
150
|
+
// Prefer .at() method for index access and String#charAt()
|
|
151
|
+
'unicorn/prefer-at': 'warn',
|
|
152
|
+
// Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(…) and Blob#text() over FileReader#readAsText(…)
|
|
153
|
+
'unicorn/prefer-blob-reading-methods': 'error',
|
|
154
|
+
// Prefer String#codePointAt(…) over String#charCodeAt(…)
|
|
155
|
+
// and String.fromCodePoint(…) over String.fromCharCode(…)
|
|
156
|
+
'unicorn/prefer-code-point': 'error',
|
|
157
|
+
// Prefer Date.now() to get the number of milliseconds since the Unix Epoch
|
|
158
|
+
'unicorn/prefer-date-now': 'warn',
|
|
159
|
+
// Prefer default parameters over reassignment
|
|
160
|
+
'unicorn/prefer-default-parameters': 'warn',
|
|
161
|
+
// Prefer Node#append() over Node#appendChild()
|
|
162
|
+
'unicorn/prefer-dom-node-append': 'warn',
|
|
163
|
+
// Prefer using .dataset on DOM elements over .setAttribute(…)
|
|
164
|
+
'unicorn/prefer-dom-node-dataset': 'warn',
|
|
165
|
+
// Prefer node.remove() over parentNode.removeChild(node) and parentElement.removeChild(node)
|
|
166
|
+
'unicorn/prefer-dom-node-remove': 'warn',
|
|
167
|
+
// Prefer .textContent over .innerText
|
|
168
|
+
'unicorn/prefer-dom-node-text-content': 'warn',
|
|
169
|
+
// Prefer EventTarget over EventEmitter.
|
|
170
|
+
'unicorn/prefer-event-target': 'error',
|
|
171
|
+
// Prefer `export…from` when re-exporting
|
|
172
|
+
'unicorn/prefer-export-from': 'warn',
|
|
173
|
+
// Prefer .includes() over .indexOf() when checking for existence or non-existence
|
|
174
|
+
'unicorn/prefer-includes': 'warn',
|
|
175
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-json-parse-buffer.md
|
|
176
|
+
'unicorn/prefer-json-parse-buffer': 'warn',
|
|
177
|
+
// Prefer KeyboardEvent#key over KeyboardEvent#keyCode
|
|
178
|
+
'unicorn/prefer-keyboard-event-key': 'warn',
|
|
179
|
+
// Disallow ternary operators when simpler logical operator alternatives exist.
|
|
180
|
+
'unicorn/prefer-logical-operator-over-ternary': 'warn',
|
|
181
|
+
// Enforce the use of Math.trunc instead of bitwise operators
|
|
182
|
+
'unicorn/prefer-math-trunc': 'warn',
|
|
183
|
+
// e.g. foo.insertBefore(baz, bar) -> foo.before(bar, 'baz')
|
|
184
|
+
'unicorn/prefer-modern-dom-apis': 'warn',
|
|
185
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-math-apis.md
|
|
186
|
+
'unicorn/prefer-modern-math-apis': 'warn',
|
|
187
|
+
// Not ready yet for ESM modules
|
|
188
|
+
// https://github.com/microsoft/TypeScript/issues/33079
|
|
189
|
+
'unicorn/prefer-module': 'off',
|
|
190
|
+
// If a function is equivalent to String, Number, BigInt, Boolean, or Symbol,
|
|
191
|
+
// you should use the built-in one directly. Wrapping the built-in in a function is moot.
|
|
192
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-native-coercion-functions.md
|
|
193
|
+
'unicorn/prefer-native-coercion-functions': 'warn',
|
|
194
|
+
// Prefer negative index over .length - index
|
|
195
|
+
// for {String,Array,TypedArray}#slice() and Array#splice()
|
|
196
|
+
'unicorn/prefer-negative-index': 'warn',
|
|
197
|
+
// Prefer using the node: protocol when importing Node.js builtin modules
|
|
198
|
+
// TODO seems like this is not well supported by webpack yet
|
|
199
|
+
'unicorn/prefer-node-protocol': 'off',
|
|
200
|
+
// Prefer Number static properties over global ones
|
|
201
|
+
'unicorn/prefer-number-properties': 'warn',
|
|
202
|
+
// Prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object
|
|
203
|
+
'unicorn/prefer-object-from-entries': 'warn',
|
|
204
|
+
// Prefer Object.hasOwn(…) over Object.prototype.hasOwnProperty.call(…)
|
|
205
|
+
'unicorn/prefer-object-has-own': 'warn',
|
|
206
|
+
// Prefer omitting the catch binding parameter
|
|
207
|
+
'unicorn/prefer-optional-catch-binding': 'warn',
|
|
208
|
+
// Prefer borrowing methods from the prototype instead of methods from an instance
|
|
209
|
+
'unicorn/prefer-prototype-methods': 'warn',
|
|
210
|
+
// Prefer .querySelector() over .getElementById(),
|
|
211
|
+
// .querySelectorAll() over .getElementsByClassName() and .getElementsByTagName()
|
|
212
|
+
'unicorn/prefer-query-selector': 'warn',
|
|
213
|
+
// Prefer Reflect.apply() over Function#apply()
|
|
214
|
+
'unicorn/prefer-reflect-apply': 'warn',
|
|
215
|
+
// Prefer RegExp#test() over String#match() and RegExp#exec()
|
|
216
|
+
'unicorn/prefer-regexp-test': 'warn',
|
|
217
|
+
// Prefer Set#has() over Array#includes() when checking for existence or non-existence
|
|
218
|
+
// Set#has() is faster than Array#includes().
|
|
219
|
+
'unicorn/prefer-set-has': 'warn',
|
|
220
|
+
// Prefer using Set#size instead of Array#length
|
|
221
|
+
'unicorn/prefer-set-size': 'warn',
|
|
222
|
+
// Prefer the spread operator over Array.from()
|
|
223
|
+
'unicorn/prefer-spread': 'warn',
|
|
224
|
+
// Prefer String#replaceAll() over regex searches with the global flag
|
|
225
|
+
'unicorn/prefer-string-replace-all': 'warn',
|
|
226
|
+
// Prefer String#slice() over String#substr() and String#substring()
|
|
227
|
+
'unicorn/prefer-string-slice': 'warn',
|
|
228
|
+
// Prefer String#startsWith() & String#endsWith() over more complex alternatives
|
|
229
|
+
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
230
|
+
// Prefer String#trimStart() / String#trimEnd() over String#trimLeft() / String#trimRight()
|
|
231
|
+
'unicorn/prefer-string-trim-start-end': 'warn',
|
|
232
|
+
// Use whatever feels correct in the moment
|
|
233
|
+
'unicorn/prefer-switch': 'off',
|
|
234
|
+
// Prefer ternary expressions over simple if-else statements
|
|
235
|
+
'unicorn/prefer-ternary': ['warn', 'only-single-line'],
|
|
236
|
+
// Prefer top-level await over top-level promises and async function calls
|
|
237
|
+
'unicorn/prefer-top-level-await': 'error',
|
|
238
|
+
// Enforce throwing TypeError in type checking conditions
|
|
239
|
+
'unicorn/prefer-type-error': 'warn',
|
|
240
|
+
// Using complete words results in more readable code. Not everyone knows all your abbreviations.
|
|
241
|
+
// Code is written only once, but read many times.
|
|
242
|
+
'unicorn/prevent-abbreviations': [
|
|
243
|
+
'warn',
|
|
244
|
+
{
|
|
245
|
+
allowList: {
|
|
246
|
+
'next-env.d': true,
|
|
247
|
+
'react-app-env.d': true,
|
|
248
|
+
},
|
|
249
|
+
replacements: {
|
|
250
|
+
props: false,
|
|
251
|
+
ref: false,
|
|
252
|
+
refs: false,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
// Enforce the use of regex shorthands to improve readability
|
|
257
|
+
'unicorn/regex-shorthand': 'warn',
|
|
258
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/relative-url-style.md
|
|
259
|
+
'unicorn/relative-url-style': 'warn',
|
|
260
|
+
// Enforce using the separator argument with Array#join()
|
|
261
|
+
'unicorn/require-array-join-separator': 'warn',
|
|
262
|
+
// Enforce using the digits argument with Number#toFixed()
|
|
263
|
+
'unicorn/require-number-to-fixed-digits-argument': 'warn',
|
|
264
|
+
// Enforce using the targetOrigin argument with window.postMessage()
|
|
265
|
+
'unicorn/require-post-message-target-origin': 'error',
|
|
266
|
+
// No swaps needed yet
|
|
267
|
+
'unicorn/string-content': 'off',
|
|
268
|
+
// Only allow braces when there are variable declaration or function
|
|
269
|
+
// declaration which requires a scope.
|
|
270
|
+
'unicorn/switch-case-braces': ['warn', 'avoid'],
|
|
271
|
+
// Fix whitespace-insensitive template indentation
|
|
272
|
+
'unicorn/template-indent': [
|
|
273
|
+
'warn',
|
|
274
|
+
{
|
|
275
|
+
indent: 2,
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
'unicorn/text-encoding-identifier-case': 'error',
|
|
279
|
+
// Require new when throwing an error
|
|
280
|
+
'unicorn/throw-new-error': 'warn',
|
|
281
|
+
}
|