@viclafouch/eslint-config-viclafouch 3.9.1 → 3.9.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +10 -0
- package/README.md +120 -40
- package/hooks.js +7 -0
- package/index.js +19 -3
- package/next.js +19 -0
- package/package.json +19 -29
- package/prettier.js +23 -0
- package/react.js +7 -0
- package/reset.d.ts +1 -0
- package/rules/best-practices.js +324 -0
- package/rules/errors.js +38 -0
- package/rules/es6.js +175 -0
- package/rules/imports.js +26 -0
- package/rules/node.js +14 -0
- package/rules/react-hooks.js +25 -0
- package/rules/react.js +387 -0
- package/rules/sort-imports.js +62 -0
- package/rules/style.js +20 -0
- package/rules/typescript.js +151 -0
- package/rules/variables.js +74 -0
- package/tsconfig.json +21 -0
- package/.eslintrc-base.js +0 -138
- package/.eslintrc.js +0 -17
- package/typescript.js +0 -17
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import("eslint").Linter.Config}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
env: {
|
|
6
|
+
browser: true
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
// enforces getter/setter pairs in objects
|
|
10
|
+
// https://eslint.org/docs/rules/accessor-pairs
|
|
11
|
+
'accessor-pairs': 'off',
|
|
12
|
+
|
|
13
|
+
// Force curly everytime
|
|
14
|
+
// https://eslint.org/docs/rules/curly
|
|
15
|
+
curly: ['error', 'all'],
|
|
16
|
+
|
|
17
|
+
// enforces return statements in callbacks of array's methods
|
|
18
|
+
// https://eslint.org/docs/rules/array-callback-return
|
|
19
|
+
'array-callback-return': ['error', { allowImplicit: true }],
|
|
20
|
+
|
|
21
|
+
// treat var statements as if they were block scoped
|
|
22
|
+
// https://eslint.org/docs/rules/block-scoped-var
|
|
23
|
+
'block-scoped-var': 'error',
|
|
24
|
+
|
|
25
|
+
// specify the maximum cyclomatic complexity allowed in a program
|
|
26
|
+
// https://eslint.org/docs/rules/complexity
|
|
27
|
+
complexity: ['off', 20],
|
|
28
|
+
|
|
29
|
+
// enforce that class methods use "this"
|
|
30
|
+
// https://eslint.org/docs/rules/class-methods-use-this
|
|
31
|
+
'class-methods-use-this': [
|
|
32
|
+
'error',
|
|
33
|
+
{
|
|
34
|
+
exceptMethods: []
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
|
|
38
|
+
// require return statements to either always or never specify values
|
|
39
|
+
// https://eslint.org/docs/rules/consistent-return
|
|
40
|
+
'consistent-return': 'error',
|
|
41
|
+
|
|
42
|
+
// require default case in switch statements
|
|
43
|
+
// https://eslint.org/docs/rules/default-case
|
|
44
|
+
'default-case': ['error', { commentPattern: '^no default$' }],
|
|
45
|
+
|
|
46
|
+
// Enforce default clauses in switch statements to be last
|
|
47
|
+
// https://eslint.org/docs/rules/default-case-last
|
|
48
|
+
'default-case-last': 'error',
|
|
49
|
+
|
|
50
|
+
// https://eslint.org/docs/rules/default-param-last
|
|
51
|
+
'default-param-last': 'error',
|
|
52
|
+
|
|
53
|
+
// encourages use of dot notation whenever possible
|
|
54
|
+
// https://eslint.org/docs/rules/dot-notation
|
|
55
|
+
'dot-notation': ['error', { allowKeywords: true }],
|
|
56
|
+
|
|
57
|
+
// enforces consistent newlines before or after dots
|
|
58
|
+
// https://eslint.org/docs/rules/dot-location
|
|
59
|
+
'dot-location': ['error', 'property'],
|
|
60
|
+
|
|
61
|
+
// make sure for-in loops have an if statement
|
|
62
|
+
// https://eslint.org/docs/rules/guard-for-in
|
|
63
|
+
'guard-for-in': 'error',
|
|
64
|
+
|
|
65
|
+
// disallow the use of alert, confirm, and prompt
|
|
66
|
+
// https://eslint.org/docs/rules/no-alert
|
|
67
|
+
'no-alert': 'error',
|
|
68
|
+
|
|
69
|
+
// disallow lexical declarations in case/default clauses
|
|
70
|
+
// https://eslint.org/docs/rules/no-case-declarations
|
|
71
|
+
'no-case-declarations': 'error',
|
|
72
|
+
|
|
73
|
+
// Disallow returning value in constructor
|
|
74
|
+
// https://eslint.org/docs/rules/no-constructor-return
|
|
75
|
+
'no-constructor-return': 'error',
|
|
76
|
+
|
|
77
|
+
// disallow else after a return in an if
|
|
78
|
+
// https://eslint.org/docs/rules/no-else-return
|
|
79
|
+
'no-else-return': ['error', { allowElseIf: false }],
|
|
80
|
+
|
|
81
|
+
// disallow empty functions, except for standalone funcs/arrows
|
|
82
|
+
// https://eslint.org/docs/rules/no-empty-function
|
|
83
|
+
'no-empty-function': [
|
|
84
|
+
'error',
|
|
85
|
+
{
|
|
86
|
+
allow: ['arrowFunctions', 'functions', 'methods']
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
|
|
90
|
+
// disallow empty destructuring patterns
|
|
91
|
+
// https://eslint.org/docs/rules/no-empty-pattern
|
|
92
|
+
'no-empty-pattern': 'error',
|
|
93
|
+
|
|
94
|
+
// disallow comparisons to null without a type-checking operator
|
|
95
|
+
// https://eslint.org/docs/rules/no-eq-null
|
|
96
|
+
'no-eq-null': 'off',
|
|
97
|
+
|
|
98
|
+
// disallow adding to native types
|
|
99
|
+
// https://eslint.org/docs/rules/no-extend-native
|
|
100
|
+
'no-extend-native': 'error',
|
|
101
|
+
|
|
102
|
+
// disallow Unnecessary Labels
|
|
103
|
+
// https://eslint.org/docs/rules/no-extra-label
|
|
104
|
+
'no-extra-label': 'error',
|
|
105
|
+
|
|
106
|
+
// disallow fallthrough of case statements
|
|
107
|
+
// https://eslint.org/docs/rules/no-fallthrough
|
|
108
|
+
'no-fallthrough': 'error',
|
|
109
|
+
|
|
110
|
+
// disallow the use of leading or trailing decimal points in numeric literals
|
|
111
|
+
// https://eslint.org/docs/rules/no-floating-decimal
|
|
112
|
+
'no-floating-decimal': 'error',
|
|
113
|
+
|
|
114
|
+
// disallow reassignments of native objects or read-only globals
|
|
115
|
+
// https://eslint.org/docs/rules/no-global-assign
|
|
116
|
+
'no-global-assign': ['error', { exceptions: [] }],
|
|
117
|
+
|
|
118
|
+
// deprecated in favor of no-global-assign
|
|
119
|
+
// https://eslint.org/docs/rules/no-native-reassign
|
|
120
|
+
'no-native-reassign': 'off',
|
|
121
|
+
|
|
122
|
+
// disallow implicit type conversions
|
|
123
|
+
// https://eslint.org/docs/rules/no-implicit-coercion
|
|
124
|
+
'no-implicit-coercion': 'error',
|
|
125
|
+
|
|
126
|
+
// disallow var and named functions in global scope
|
|
127
|
+
// https://eslint.org/docs/rules/no-implicit-globals
|
|
128
|
+
'no-implicit-globals': 'off',
|
|
129
|
+
|
|
130
|
+
// disallow this keywords outside of classes or class-like objects
|
|
131
|
+
// https://eslint.org/docs/rules/no-invalid-this
|
|
132
|
+
'no-invalid-this': 'off',
|
|
133
|
+
|
|
134
|
+
// disallow usage of __iterator__ property
|
|
135
|
+
// https://eslint.org/docs/rules/no-iterator
|
|
136
|
+
'no-iterator': 'error',
|
|
137
|
+
|
|
138
|
+
// disallow use of labels for anything other than loops and switches
|
|
139
|
+
// https://eslint.org/docs/rules/no-labels
|
|
140
|
+
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
|
141
|
+
|
|
142
|
+
// disallow unnecessary nested blocks
|
|
143
|
+
// https://eslint.org/docs/rules/no-lone-blocks
|
|
144
|
+
'no-lone-blocks': 'error',
|
|
145
|
+
|
|
146
|
+
// disallow use of multiple spaces
|
|
147
|
+
// https://eslint.org/docs/rules/no-multi-spaces
|
|
148
|
+
'no-multi-spaces': [
|
|
149
|
+
'error',
|
|
150
|
+
{
|
|
151
|
+
ignoreEOLComments: false
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
|
|
155
|
+
// disallow use of multiline strings
|
|
156
|
+
// https://eslint.org/docs/rules/no-multi-str
|
|
157
|
+
'no-multi-str': 'error',
|
|
158
|
+
|
|
159
|
+
// disallow use of new operator when not part of the assignment or comparison
|
|
160
|
+
// https://eslint.org/docs/rules/no-new
|
|
161
|
+
'no-new': 'error',
|
|
162
|
+
|
|
163
|
+
// disallows creating new instances of String, Number, and Boolean
|
|
164
|
+
// https://eslint.org/docs/rules/no-new-wrappers
|
|
165
|
+
'no-new-wrappers': 'error',
|
|
166
|
+
|
|
167
|
+
// disallow use of (old style) octal literals
|
|
168
|
+
// https://eslint.org/docs/rules/no-octal
|
|
169
|
+
'no-octal': 'error',
|
|
170
|
+
|
|
171
|
+
// disallow use of octal escape sequences in string literals, such as
|
|
172
|
+
// var foo = 'Copyright \251';
|
|
173
|
+
// https://eslint.org/docs/rules/no-octal-escape
|
|
174
|
+
'no-octal-escape': 'error',
|
|
175
|
+
|
|
176
|
+
// disallow reassignment of function parameters
|
|
177
|
+
// disallow parameter object manipulation except for specific exclusions
|
|
178
|
+
// rule: https://eslint.org/docs/rules/no-param-reassign.html
|
|
179
|
+
'no-param-reassign': [
|
|
180
|
+
'error',
|
|
181
|
+
{
|
|
182
|
+
ignorePropertyModificationsForRegex: [
|
|
183
|
+
'draft',
|
|
184
|
+
'context2D',
|
|
185
|
+
'canvasElement'
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
|
|
190
|
+
// disallow declaring the same variable more than once
|
|
191
|
+
// https://eslint.org/docs/rules/no-redeclare
|
|
192
|
+
'no-redeclare': 'error',
|
|
193
|
+
|
|
194
|
+
// disallow certain object properties
|
|
195
|
+
// https://eslint.org/docs/rules/no-restricted-properties
|
|
196
|
+
'no-restricted-properties': [
|
|
197
|
+
'error',
|
|
198
|
+
{
|
|
199
|
+
object: 'arguments',
|
|
200
|
+
property: 'callee',
|
|
201
|
+
message: 'arguments.callee is deprecated'
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
object: 'global',
|
|
205
|
+
property: 'isFinite',
|
|
206
|
+
message: 'Please use Number.isFinite instead'
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
object: 'self',
|
|
210
|
+
property: 'isFinite',
|
|
211
|
+
message: 'Please use Number.isFinite instead'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
object: 'window',
|
|
215
|
+
property: 'isFinite',
|
|
216
|
+
message: 'Please use Number.isFinite instead'
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
object: 'global',
|
|
220
|
+
property: 'isNaN',
|
|
221
|
+
message: 'Please use Number.isNaN instead'
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
object: 'self',
|
|
225
|
+
property: 'isNaN',
|
|
226
|
+
message: 'Please use Number.isNaN instead'
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
object: 'window',
|
|
230
|
+
property: 'isNaN',
|
|
231
|
+
message: 'Please use Number.isNaN instead'
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
object: 'Math',
|
|
235
|
+
property: 'pow',
|
|
236
|
+
message: 'Use the exponentiation operator (**) instead.'
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
|
|
240
|
+
// disallow use of assignment in return statement
|
|
241
|
+
// https://eslint.org/docs/rules/no-return-assign
|
|
242
|
+
'no-return-assign': ['error', 'always'],
|
|
243
|
+
|
|
244
|
+
// disallow self assignment
|
|
245
|
+
// https://eslint.org/docs/rules/no-self-assign
|
|
246
|
+
'no-self-assign': [
|
|
247
|
+
'error',
|
|
248
|
+
{
|
|
249
|
+
props: true
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
|
|
253
|
+
// disallow comparisons where both sides are exactly the same
|
|
254
|
+
// https://eslint.org/docs/rules/no-self-compare
|
|
255
|
+
'no-self-compare': 'error',
|
|
256
|
+
|
|
257
|
+
// restrict what can be thrown as an exception
|
|
258
|
+
// https://eslint.org/docs/rules/no-throw-literal
|
|
259
|
+
'no-throw-literal': 'error',
|
|
260
|
+
|
|
261
|
+
// disallow unmodified conditions of loops
|
|
262
|
+
// https://eslint.org/docs/rules/no-unmodified-loop-condition
|
|
263
|
+
'no-unmodified-loop-condition': 'off',
|
|
264
|
+
|
|
265
|
+
// disallow usage of expressions in statement position
|
|
266
|
+
// https://eslint.org/docs/rules/no-unused-expressions
|
|
267
|
+
'no-unused-expressions': [
|
|
268
|
+
'error',
|
|
269
|
+
{
|
|
270
|
+
allowShortCircuit: false,
|
|
271
|
+
allowTernary: false,
|
|
272
|
+
allowTaggedTemplates: false
|
|
273
|
+
}
|
|
274
|
+
],
|
|
275
|
+
|
|
276
|
+
// disallow unused labels
|
|
277
|
+
// https://eslint.org/docs/rules/no-unused-labels
|
|
278
|
+
'no-unused-labels': 'error',
|
|
279
|
+
|
|
280
|
+
// disallow unnecessary .call() and .apply()
|
|
281
|
+
// https://eslint.org/docs/rules/no-useless-call
|
|
282
|
+
'no-useless-call': 'off',
|
|
283
|
+
|
|
284
|
+
// Disallow unnecessary catch clauses
|
|
285
|
+
// https://eslint.org/docs/rules/no-useless-catch
|
|
286
|
+
'no-useless-catch': 'error',
|
|
287
|
+
|
|
288
|
+
// disallow useless string concatenation
|
|
289
|
+
// https://eslint.org/docs/rules/no-useless-concat
|
|
290
|
+
'no-useless-concat': 'error',
|
|
291
|
+
|
|
292
|
+
// disallow unnecessary string escaping
|
|
293
|
+
// https://eslint.org/docs/rules/no-useless-escape
|
|
294
|
+
'no-useless-escape': 'error',
|
|
295
|
+
|
|
296
|
+
// disallow redundant return; keywords
|
|
297
|
+
// https://eslint.org/docs/rules/no-useless-return
|
|
298
|
+
'no-useless-return': 'error',
|
|
299
|
+
|
|
300
|
+
// require using Error objects as Promise rejection reasons
|
|
301
|
+
// https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
302
|
+
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
|
|
303
|
+
|
|
304
|
+
// Suggest using named capture group in regular expression
|
|
305
|
+
// https://eslint.org/docs/rules/prefer-named-capture-group
|
|
306
|
+
'prefer-named-capture-group': 'off',
|
|
307
|
+
|
|
308
|
+
// https://eslint.org/docs/rules/prefer-regex-literals
|
|
309
|
+
'prefer-regex-literals': [
|
|
310
|
+
'error',
|
|
311
|
+
{
|
|
312
|
+
disallowRedundantWrapping: true
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
|
|
316
|
+
// require use of the second argument for parseInt()
|
|
317
|
+
// https://eslint.org/docs/rules/radix
|
|
318
|
+
radix: 'error',
|
|
319
|
+
|
|
320
|
+
// Enforce the use of u flag on RegExp
|
|
321
|
+
// https://eslint.org/docs/rules/require-unicode-regexp
|
|
322
|
+
'require-unicode-regexp': 'off'
|
|
323
|
+
}
|
|
324
|
+
}
|
package/rules/errors.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import("eslint").Linter.Config}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
rules: {
|
|
6
|
+
// Disallow await inside of loops
|
|
7
|
+
// https://eslint.org/docs/rules/no-await-in-loop
|
|
8
|
+
'no-await-in-loop': 'error',
|
|
9
|
+
|
|
10
|
+
// disallow assignment in conditional expressions
|
|
11
|
+
'no-cond-assign': ['error', 'always'],
|
|
12
|
+
|
|
13
|
+
// disallow use of console
|
|
14
|
+
'no-console': 'warn',
|
|
15
|
+
|
|
16
|
+
// disallow use of constant expressions in conditions
|
|
17
|
+
'no-constant-condition': 'warn',
|
|
18
|
+
|
|
19
|
+
// disallow use of debugger
|
|
20
|
+
'no-debugger': 'error',
|
|
21
|
+
|
|
22
|
+
// Disallow duplicate conditions in if-else-if chains
|
|
23
|
+
// https://eslint.org/docs/rules/no-dupe-else-if
|
|
24
|
+
'no-dupe-else-if': 'error',
|
|
25
|
+
|
|
26
|
+
// disallow a duplicate case label.
|
|
27
|
+
'no-duplicate-case': 'error',
|
|
28
|
+
|
|
29
|
+
// disallow duplicate keys when creating object literals
|
|
30
|
+
'no-dupe-keys': 'error',
|
|
31
|
+
|
|
32
|
+
// disallow assigning to the exception in a catch block
|
|
33
|
+
'no-ex-assign': 'error',
|
|
34
|
+
|
|
35
|
+
// disallow unnecessary semicolons
|
|
36
|
+
'no-extra-semi': 'error'
|
|
37
|
+
}
|
|
38
|
+
}
|
package/rules/es6.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import("eslint").Linter.Config}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
plugins: ['promise'],
|
|
6
|
+
env: {
|
|
7
|
+
es6: true
|
|
8
|
+
},
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 6,
|
|
11
|
+
sourceType: 'module'
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
// Always arrow functions
|
|
15
|
+
// https://eslint.org/docs/rules/arrow-body-style
|
|
16
|
+
'arrow-body-style': ['error', 'always'],
|
|
17
|
+
|
|
18
|
+
// require parens in arrow function arguments
|
|
19
|
+
// https://eslint.org/docs/rules/arrow-parens
|
|
20
|
+
'arrow-parens': ['error', 'always'],
|
|
21
|
+
|
|
22
|
+
// require space before/after arrow function's arrow
|
|
23
|
+
// https://eslint.org/docs/rules/arrow-spacing
|
|
24
|
+
'arrow-spacing': ['error', { before: true, after: true }],
|
|
25
|
+
|
|
26
|
+
// verify super() callings in constructors
|
|
27
|
+
'constructor-super': 'error',
|
|
28
|
+
|
|
29
|
+
// disallow modifying variables of class declarations
|
|
30
|
+
// https://eslint.org/docs/rules/no-class-assign
|
|
31
|
+
'no-class-assign': 'error',
|
|
32
|
+
|
|
33
|
+
// disallow arrow functions where they could be confused with comparisons
|
|
34
|
+
// https://eslint.org/docs/rules/no-confusing-arrow
|
|
35
|
+
'no-confusing-arrow': [
|
|
36
|
+
'error',
|
|
37
|
+
{
|
|
38
|
+
allowParens: true
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
// disallow modifying variables that are declared using const
|
|
43
|
+
'no-const-assign': 'error',
|
|
44
|
+
|
|
45
|
+
// disallow importing from the same path more than once
|
|
46
|
+
// https://eslint.org/docs/rules/no-duplicate-imports
|
|
47
|
+
// replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
|
|
48
|
+
'no-duplicate-imports': 'off',
|
|
49
|
+
|
|
50
|
+
// Disallow specified names in exports
|
|
51
|
+
// https://eslint.org/docs/rules/no-restricted-exports
|
|
52
|
+
'no-restricted-exports': [
|
|
53
|
+
'error',
|
|
54
|
+
{
|
|
55
|
+
restrictedNamedExports: [
|
|
56
|
+
'default', // use `export default` to provide a default export
|
|
57
|
+
'then' // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
|
|
62
|
+
// disallow to use this/super before super() calling in constructors.
|
|
63
|
+
// https://eslint.org/docs/rules/no-this-before-super
|
|
64
|
+
'no-this-before-super': 'error',
|
|
65
|
+
|
|
66
|
+
// disallow useless computed property keys
|
|
67
|
+
// https://eslint.org/docs/rules/no-useless-computed-key
|
|
68
|
+
'no-useless-computed-key': 'error',
|
|
69
|
+
|
|
70
|
+
// disallow unnecessary constructor
|
|
71
|
+
// https://eslint.org/docs/rules/no-useless-constructor
|
|
72
|
+
'no-useless-constructor': 'error',
|
|
73
|
+
|
|
74
|
+
// disallow renaming import, export, and destructured assignments to the same name
|
|
75
|
+
// https://eslint.org/docs/rules/no-useless-rename
|
|
76
|
+
'no-useless-rename': [
|
|
77
|
+
'error',
|
|
78
|
+
{
|
|
79
|
+
ignoreDestructuring: false,
|
|
80
|
+
ignoreImport: false,
|
|
81
|
+
ignoreExport: false
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
|
|
85
|
+
// require let or const instead of var
|
|
86
|
+
'no-var': 'error',
|
|
87
|
+
|
|
88
|
+
// require method and property shorthand syntax for object literals
|
|
89
|
+
// https://eslint.org/docs/rules/object-shorthand
|
|
90
|
+
'object-shorthand': [
|
|
91
|
+
'error',
|
|
92
|
+
'always',
|
|
93
|
+
{
|
|
94
|
+
ignoreConstructors: false,
|
|
95
|
+
avoidQuotes: true
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
|
|
99
|
+
// suggest using arrow functions as callbacks
|
|
100
|
+
'prefer-arrow-callback': [
|
|
101
|
+
'error',
|
|
102
|
+
{
|
|
103
|
+
allowNamedFunctions: false,
|
|
104
|
+
allowUnboundThis: true
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
// suggest using of const declaration for variables that are never modified after declared
|
|
109
|
+
'prefer-const': [
|
|
110
|
+
'error',
|
|
111
|
+
{
|
|
112
|
+
destructuring: 'any',
|
|
113
|
+
ignoreReadBeforeAssign: true
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
|
|
117
|
+
// Prefer destructuring from arrays and objects
|
|
118
|
+
// https://eslint.org/docs/rules/prefer-destructuring
|
|
119
|
+
'prefer-destructuring': [
|
|
120
|
+
'error',
|
|
121
|
+
{
|
|
122
|
+
VariableDeclarator: {
|
|
123
|
+
array: false,
|
|
124
|
+
object: true
|
|
125
|
+
},
|
|
126
|
+
AssignmentExpression: {
|
|
127
|
+
array: true,
|
|
128
|
+
object: false
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
enforceForRenamedProperties: false
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
|
|
136
|
+
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
|
137
|
+
// https://eslint.org/docs/rules/prefer-numeric-literals
|
|
138
|
+
'prefer-numeric-literals': 'error',
|
|
139
|
+
|
|
140
|
+
// suggest using Reflect methods where applicable
|
|
141
|
+
// https://eslint.org/docs/rules/prefer-reflect
|
|
142
|
+
'prefer-reflect': 'off',
|
|
143
|
+
|
|
144
|
+
// use rest parameters instead of arguments
|
|
145
|
+
// https://eslint.org/docs/rules/prefer-rest-params
|
|
146
|
+
'prefer-rest-params': 'error',
|
|
147
|
+
|
|
148
|
+
// suggest using the spread syntax instead of .apply()
|
|
149
|
+
// https://eslint.org/docs/rules/prefer-spread
|
|
150
|
+
'prefer-spread': 'error',
|
|
151
|
+
|
|
152
|
+
// suggest using template literals instead of string concatenation
|
|
153
|
+
// https://eslint.org/docs/rules/prefer-template
|
|
154
|
+
'prefer-template': 'error',
|
|
155
|
+
|
|
156
|
+
// enforce spacing between object rest-spread
|
|
157
|
+
// https://eslint.org/docs/rules/rest-spread-spacing
|
|
158
|
+
'rest-spread-spacing': ['error', 'never'],
|
|
159
|
+
|
|
160
|
+
// enforce usage of spacing in template strings
|
|
161
|
+
// https://eslint.org/docs/rules/template-curly-spacing
|
|
162
|
+
'template-curly-spacing': 'error',
|
|
163
|
+
|
|
164
|
+
// Disallow unnecessary return await
|
|
165
|
+
// https://eslint.org/docs/latest/rules/no-return-await
|
|
166
|
+
'no-return-await': 'error',
|
|
167
|
+
|
|
168
|
+
// Disallow async functions which have no await expression
|
|
169
|
+
// https://eslint.org/docs/latest/rules/require-await
|
|
170
|
+
'require-await': 2,
|
|
171
|
+
|
|
172
|
+
// Prefer to use async/await for Promises
|
|
173
|
+
'promise/prefer-await-to-then': 2
|
|
174
|
+
}
|
|
175
|
+
}
|
package/rules/imports.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parserOptions: {
|
|
3
|
+
sourceType: 'module'
|
|
4
|
+
},
|
|
5
|
+
env: {
|
|
6
|
+
es6: true
|
|
7
|
+
},
|
|
8
|
+
plugins: ['simple-import-sort', 'import'],
|
|
9
|
+
rules: {
|
|
10
|
+
'simple-import-sort/imports': 'error',
|
|
11
|
+
'simple-import-sort/exports': 'error',
|
|
12
|
+
'import/first': 'error',
|
|
13
|
+
'import/newline-after-import': 'error',
|
|
14
|
+
'import/no-duplicates': 'error'
|
|
15
|
+
},
|
|
16
|
+
settings: {
|
|
17
|
+
'import/resolver': {
|
|
18
|
+
node: {
|
|
19
|
+
extensions: ['.mjs', '.js', '.json']
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
'import/extensions': ['.js', '.mjs', '.jsx'],
|
|
23
|
+
'import/core-modules': [],
|
|
24
|
+
'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$']
|
|
25
|
+
}
|
|
26
|
+
}
|
package/rules/node.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import("eslint").Linter.Config}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
env: {
|
|
6
|
+
node: true,
|
|
7
|
+
jest: true
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
// require all requires be top-level
|
|
11
|
+
// https://eslint.org/docs/rules/global-require
|
|
12
|
+
'global-require': 'error'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import("eslint").Linter.Config}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
plugins: ['react-hooks'],
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaFeatures: {
|
|
8
|
+
jsx: true
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
// Enforce Rules of Hooks
|
|
13
|
+
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
14
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
15
|
+
|
|
16
|
+
// Verify the list of the dependencies for Hooks like useEffect and similar
|
|
17
|
+
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
18
|
+
'react-hooks/exhaustive-deps': 'error',
|
|
19
|
+
|
|
20
|
+
// Prefer to have a convention for naming states
|
|
21
|
+
// e.g: [thing, setThing]
|
|
22
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
23
|
+
'react/hook-use-state': 'error'
|
|
24
|
+
}
|
|
25
|
+
}
|