-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
258 lines (243 loc) · 8.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
const { noUnusedVars } = require("./lib/constants.js")
module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
env: {
es2022: true,
node: true,
browser: true,
},
plugins: ["sonarjs", "unicorn", "node", "promise", "import"],
rules: {
// Possible Errors
"for-direction": "error",
"getter-return": ["error", { allowImplicit: true }],
"no-async-promise-executor": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"no-control-regex": "error",
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-else-if": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-empty-character-class": "error",
"no-ex-assign": "error",
"no-extra-boolean-cast": ["error", { enforceForLogicalOperands: true }],
"no-func-assign": "error",
"no-import-assign": "error",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": ["error", { skipStrings: false }],
"no-loss-of-precision": "error",
"no-misleading-character-class": "error",
"no-obj-calls": "error",
"no-promise-executor-return": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-setter-return": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "warn",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-unreachable-loop": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
"require-atomic-updates": "error",
"use-isnan": "error",
"valid-typeof": ["error", { requireStringLiterals: true }],
"no-bitwise": "warn",
// Best Practices
"array-callback-return": ["error", { allowImplicit: true }],
"no-case-declarations": "error",
"no-constructor-return": "error",
"no-else-return": "error",
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-global-assign": "error",
"no-implied-eval": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-nonoctal-decimal-escape": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": [
"error",
{
props: true,
ignorePropertyModificationsFor: [
"acc",
"accumulator",
"e",
"ctx",
"context",
"req",
"request",
"res",
"response",
"$scope",
"staticContext",
],
},
],
"no-proto": "error",
"no-redeclare": "error",
"no-return-assign": ["error", "always"],
"no-return-await": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-throw-literal": "warn",
"no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true }],
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "warn",
"no-void": "error",
"no-with": "error",
"eqeqeq": ["error", "smart"],
"radix": ["error", "as-needed"],
"yoda": ["error", "never"],
// Complexity
"complexity": ["warn", 20],
"sonarjs/cognitive-complexity": ["error", 15],
"max-depth": ["warn", 4],
"max-lines": ["warn", { max: 300, skipBlankLines: true, skipComments: true }],
"max-params": ["warn", 3],
"sonarjs/max-switch-cases": ["error", 10],
// Variables
"init-declarations": ["error", "always"],
"no-delete-var": "error",
"no-shadow-restricted-names": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unused-vars": noUnusedVars,
"no-use-before-define": ["error", { functions: false }],
"no-useless-backreference": "error",
// Stylistic Issues
"id-match": [
"error",
"[a-zA-Z_$][0-9a-zA-Z_$]*",
{ properties: true, onlyDeclarations: false },
],
"no-array-constructor": "error",
"no-lonely-if": "error",
"no-multi-assign": "error",
"no-new-object": "error",
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
// ECMAScript 6
"constructor-super": "error",
"no-class-assign": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-duplicate-imports": ["error", { includeExports: true }],
"no-new-symbol": "error",
"no-this-before-super": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-var": "error",
"object-shorthand": "error",
"prefer-const": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"require-yield": "error",
// Bug Detection
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-element-overwrite": "error",
"sonarjs/no-extra-arguments": "error",
"sonarjs/no-identical-conditions": "error",
"sonarjs/no-identical-expressions": "error",
"sonarjs/no-one-iteration-loop": "error",
"sonarjs/no-use-of-empty-return-value": "error",
// Code Smell Detection
"sonarjs/no-collapsible-if": "error",
"sonarjs/no-duplicate-string": ["error", 3],
"sonarjs/no-duplicated-branches": "error",
"sonarjs/no-gratuitous-expressions": "error",
"sonarjs/no-identical-functions": "error",
"sonarjs/no-inverted-boolean-check": "error",
"sonarjs/no-nested-switch": "error",
"sonarjs/no-redundant-boolean": "error",
"sonarjs/no-redundant-jump": "error",
"sonarjs/no-small-switch": "error",
"sonarjs/no-unused-collection": "error",
"sonarjs/no-useless-catch": "error",
"sonarjs/prefer-immediate-return": "error",
"sonarjs/prefer-object-literal": "error",
"sonarjs/prefer-single-boolean-return": "error",
"sonarjs/prefer-while": "error",
// Node.js and CommonJS
"node/handle-callback-err": ["warn", "^(err|error)$"],
"node/no-exports-assign": "error",
"node/no-new-require": "error",
"node/no-path-concat": "error",
"node/process-exit-as-throw": "error",
"node/no-deprecated-api": "warn",
"node/callback-return": "warn",
"node/global-require": "warn",
"node/no-mixed-requires": "error",
// Promise
"promise/param-names": "error",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "error",
"promise/valid-params": "error",
// Import
"import/no-webpack-loader-syntax": "error",
"import/no-self-import": "error",
"import/export": "error",
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-deprecated": "warn",
"import/no-mutable-exports": "error",
"import/first": "error",
"import/no-duplicates": "error",
"import/no-named-default": "error",
// Unicorn
"unicorn/catch-error-name": "error",
"unicorn/consistent-function-scoping": "error",
"unicorn/error-message": "error",
"unicorn/escape-case": "error",
"unicorn/expiring-todo-comments": ["error", { allowWarningComments: true }],
"unicorn/new-for-builtins": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-for-loop": "error",
"unicorn/no-instanceof-array": "error",
"unicorn/no-invalid-remove-event-listener": "error",
"no-nested-ternary": "off",
"unicorn/no-nested-ternary": "error",
"unicorn/no-new-buffer": "error",
"unicorn/no-thenable": "error",
"unicorn/no-unreadable-array-destructuring": "error",
"unicorn/no-unsafe-regex": "warn",
"unicorn/no-useless-fallback-in-spread": "error",
"unicorn/no-useless-length-check": "error",
"unicorn/no-useless-promise-resolve-reject": "error",
"unicorn/no-useless-spread": "error",
"unicorn/no-zero-fractions": "error",
"unicorn/number-literal-case": "warn",
"unicorn/prefer-array-find": "error",
"unicorn/prefer-array-flat": "error",
"unicorn/prefer-array-some": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-node-protocol": "warn",
"unicorn/prefer-object-from-entries": "warn",
"unicorn/prefer-reflect-apply": "warn",
"unicorn/prefer-string-slice": "warn",
"unicorn/prefer-string-starts-ends-with": "error",
},
}