-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.json
519 lines (519 loc) · 20 KB
/
.eslintrc.json
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018
},
"env": {
"es6": true,
"node": true
},
"rules": {
"no-cond-assign": "off",
"no-unused-vars": "off",
"no-redeclare": "off",
"no-irregular-whitespace": "off",
"no-mixed-spaces-and-tabs": "off",
"no-param-reassign": "error",
"no-alert": "error",
"arrow-body-style": "off",
"no-continue": "off",
"no-useless-concat": "off",
"one-var": "off",
"max-statements": ["warn", 15],
"no-implicit-coercion": "warn",
"arithmetic/calc": "warn",
"no-undef": "warn",
"no-use-before-define": "warn",
"no-self-compare": "warn",
"global-require": "off",
"no-div-regex": "error",
"node/shebang": "off",
"unicorn/regex-shorthand": "warn",
"unicorn/prefer-query-selector": "warn",
"no-extend-native": "error",
"pureness/forbidden-expressions": ["warn", {
"masks": "*",
"expressions": ["Date.now", "_.now", "process.setuid", "process.*", "Math.random", "_.random", "*.push", "*.pop", "document.*"]
}],
"pureness/forbid-new": ["warn",
{
"masks": "*",
"allow-with-params": ["Date"]
},
{
"masks": "*",
"allow": ["Promise", "RuleTester"]
}
],
"pureness/forbidden-import": ["error",
{
"masks": "*",
"modules": [
"lodash.random", "random", "nanoid", "react-native-securerandom", "get-port", "tempfile", "chance"
]
}
],
"id-length": ["warn", {"min": 1}],
"no-global-assign": ["error", {"exceptions": ["__dirname", "__filename"]}],
"no-magic-numbers": [
"warn",
{
"ignore": [-1, 0, 0.5, 1, 2],
"enforceConst": true
}
],
"no-warning-comments": ["warn", { "terms": ["flemme", "hello world", "fuck", "fucking", "shit", "crappy", "stupid", ":poop:", "WTF", "////", "copy pasted", "💣", "⚠️", "/!\\", "!!", "slow", "impacté", "heavy", "Einstein", "utm_source", "O(N!)"], "location": "anywhere" }],
"id-blacklist": [
"warn", "data", "err", "e", "cb", "callback", "fn", "foo", "$FlowFixMe", "SequenceExpression", "rien", "clean", "myvar", "azerty", "querty", "$_", "require", "usersList", "caches"
],
"no-empty-function": "warn",
"no-unmodified-loop-condition": "warn",
"nuxt/no-this-in-fetch-data": "warn",
"no-invalid-regexp": "warn",
"arca/melted-constructs": "warn",
"no-useless-assign/no-useless-assign": "off",
"require-jsdoc": "off",
"jsdoc/valid-types": 1,
"jsdoc/check-types": 1,
"jsdoc/require-param": "off",
"no-console": [
"error",
{
"allow": [
"count",
"countReset",
"clear",
"error",
"group",
"groupEnd",
"info",
"time",
"timeEnd",
"timeLog",
"timeStamp",
"trace",
"warn"
]
}
],
"no-restricted-modules": ["warn", {
"patterns": [
"*rand*"
],
"paths":[{
"name": "eslint-docs",
"message": "eslint-docs is not a require module. Please, use only as command"
}, {
"name": "randomfill",
"message": "random, avoid this on a pure function"
}, {
"name": "nanoid/non-secure",
"message": "non-secure API: only on Web Workers"
}, {
"name": "nanoid/format",
"message": "prefer `nanoid/async/format`"
}, {
"name": "nanoid/generate",
"message": "prefer `nanoid/async/generate`"
}, {
"name": "require-from-string",
"message": "prefer require file. file: (file protocol) is supported by package.json since version 2.0.0 of npm"
}, {
"name": "import-fresh",
"message": "avoid bypass the cache"
}, {
"name": "captains-log",
"message": "captains-log can add log (no-use-captains-log)"
}, {
"name": "lodash.isequal",
"message": "lodash-modularized: `lodash.isequal` is very old, ie: lodash.isequal v4.5.0,lodash v4.17.11 (at 13 april 2019)"
}, {
"name": "ts-lint",
"message": "this npm module was published 2 years ago, look like bad. Prefer the npm module tslint"
}, {
"name": "@stdlib/stdlib",
"message": "stability-experimental as [email protected], at 15 april 2019, and huge librairy"
}, {
"name": "@stdlib/math/base/special/log10",
"message": "prefer Math.log10 function"
}, {
"name": "google-libphonenumber",
"message": "prefer `libphonenumber-js`: Much smaller footprint"
}, {
"name": "json-stable-stringify",
"message": "prefer `fast-json-stable-stringify`: faster version of @substack's json-stable-strigify without jsonify"
}, {
"name": "ago",
"message": "prefer native `Intl.RelativeTimeFormat`: see https://v8.dev/features/intl-relativetimeformat"
}, {
"name": "process",
"message": "Hard: Disallow process.exit()"
}]
}],
"no-restricted-imports": ["warn", {
"patterns": ["!lodash/*"],
"paths": [{
"name": "moment",
"message": "Use date-fns or Luxon instead! see https://moment.github.io/luxon/docs/manual/moment.html and https://inventi.studio/en/blog/why-you-shouldnt-use-moment-js for alternatives"
}, {
"name": "date-fns",
"message": "date-fns not support error throwing and don't have TZ support https://moment.github.io/luxon/docs/manual/moment.html and https://inventi.studio/en/blog/why-you-shouldnt-use-moment-js"
}, {
"name": "moment-timezone"
},{
"name": "frozen-moment"
},{
"name": "moment"
}, {
"name": "underscore",
"message": "Use lodash-es instead!"
}, {
"name": "lodash",
"message": "Use lodash-es instead!"
}, {
"name": "lodash-es"
}, {
"name": "q",
"message": "Use bluebird instead!"
}, {
"name": "minimatch",
"message": "Use micromatch instead!"
}, {
"name": "three",
"message": "huge librairy"
}, {
"name": "@vue/test-utils",
"message": "Currently in beta"
}, {
"name": "jscs",
"message": "deprecated tool: JSCS has merged with ESLint!"
}, {
"name": "twine",
"importNames": ["Bindings", "tw"],
"message": "Prefer Twine over Bindings as the name for twine imports. see https://github.com/Shopify/eslint-plugin-shopify/blob/master/docs/rules/prefer-twine.md"
}, {
"name": "compressorjs",
"message": "warning: works only in a browser"
}, {
"name": "domain",
"message": "warning: on browser, use very popular librairy `domain-browser`"
}, {
"name": "react-native",
"importNames": ["DatePickerIOS"],
"message": "only IOS, prefer `react-native-modal-datetime-picker`"
}]
}],
"no-restricted-properties": ["warn", {
"object": "Intl",
"property": "Locale",
"message": "'Intl.Locale' is not support by Node v10.15.1 but https://v8.dev/blog/v8-release-74"
}, {
"object": "Object",
"property": "fromEntries",
"message": "`Object.fromEntries, is not support by Node v10.15.1 but https://v8.dev/blog/v8-release-74"
}, {
"object": "querystring",
"property": "decode",
"message": "`querystring.decode()` function is an alias for `querystring.parse()`"
}, {
"object": "querystring",
"property": "encode",
"message": "`querystring.encode()` function is an alias for `querystring.stringify()`"
}, {
"object": "document",
"property": "all",
"message": "`document.all` is an object, but it is undefined, see https://github.com/denysdovhan/wtfjs#documentall-is-an-object-but-it-is-undefined"
}, {
"object": "Math",
"property": "seededRandoms",
"message": "`Math.seededRandoms()` (TC39 proposal: Stage 1) and is not supported by Node v10.15.1"
}, {
"object": "Math",
"property": "random",
"message": "avoid `Math.random()` for a having determinist code, and read https://web.archive.org/web/20180816031017/http://devoluk.com:80/google-chrome-math-random-issue.html"
}, {
"object": "_",
"property": "random",
"message": "avoid `_.random()` to having pure function"
}, {
"object": "require",
"message": "Please call require() directly."
}, {
"object": "window",
"property": "close",
"message": "`Avoid window.close()` see rules/no-nan.js"
}, {
"object": "window",
"property": "$x",
"message": "`Avoid window.$x()` works only on console"
}, {
"object": "clientInformation",
"message": "prefer 'navigator' or 'window.navigator' object"
}, {
"property": "getYear",
"message": "Deprecated, use getFullYear() method"
}, {
"property": "setYear",
"message": "Deprecated, use setFullYear() method"
}, {
"property": "lastModifiedDate",
"message": "File.lastModifiedDate is deprecated"
}, {
"property": "expandEntityReferences",
"message": "NodeIterator.expandEntityReferences is deprecated"
}, {
"property": "toFixed",
"message": "Number.toFixed() can behave a bit strange in different browsers, see https://github.com/denysdovhan/wtfjs#numbertofixed-display-different-numbers"
}, {
"property": "sort",
"message": "Array.sort(), unexpected results, see https://whydoesitsuck.com/why-does-javascript-suck/#Unexpected-Behavior"
}, {
"object": "Math",
"property": "MIN_VALUE",
"message": "see https://whydoesitsuck.com/why-does-javascript-suck/#Numeric-Boundaries"
}],
"no-restricted-syntax": [
"warn",
{
"selector": "NewExpression[callee.name='RegExp'][arguments.length=0]",
"message": "/()/ instead of new RegExp()"
},
{
"selector": "FunctionDeclaration[id.name='notif']",
"message": "Use long and descriptive names"
},
{
"selector": "FunctionDeclaration[params.1.name='isPublic']",
"message": "isPublic"
},
{
"selector": "Identifier[name=/is[a-zA-Z]+Not[a-zA-Z]+/]",
"message": "Avoid negative conditionals"
},
{
"selector": "MemberExpression[object.name='car'][property.name='carColor']",
"message": "Don't add unneeded context. Don't repeat you in your variable name"
},
{
"selector": "FunctionDeclaration[id.name='addToDate']",
"message": "Function names should say what they do"
},
{
"selector": "VariableDeclarator[id.name='done']",
"message": "Boolean variables, or functions that return a boolean value, should start with “is,” “has” or “should.”"
},
{
"selector": "VariableDeclarator[id.name=/[a-zA-Z]+FromServer/]",
"message": "don’t expose details of the implementation in the name"
},
{
"selector": "VariableDeclarator[id.name=/[a-zA-Z]+List/]",
"message": "prefer `listUsers` over `usersList`, see https://github.com/haskellcamargo/js-real-world-functional-programming#do-5"
},
{
"selector": "ExpressionStatement[expression.property.value]",
"message": "Use array destructuring"
},
{
"selector": "VariableDeclarator[id.name='date']",
"message": "Use a descriptive name for date"
},
{
"selector": "VariableDeclaration[declarations.0.id.name='arr'] + ExpressionStatement[expression.operator='=']",
"message": "Use [] Instead of New Array()"
},
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name='log'][arguments.0.name='arr']",
"message": "prefer `console.table(arr)` for debug an array"
},
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name='log'][arguments.0.name=/.+s$/]",
"message": "prefer `console.table()` for debug an array"
},
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",
"message": "could call `console.log(new Error().stack)` to debug or https://github.com/visionmedia/debug or https://github.com/luruke/magicshader for three.js"
},
{
"selector": "SequenceExpression",
"message": "The comma operator is confusing and a common mistake"
},
{
"selector": "ClassDeclaration[superClass.raw=\"null\"]",
"message": "avoid extends null, see https://github.com/denysdovhan/wtfjs#function-is-not-a-function and https://eslint.org/docs/rules/constructor-super"
},
{
"selector": "FunctionDeclaration[id.name='fn']",
"message": "use a more specific function name"
},
{
"selector": "FunctionDeclaration[id.name='set']",
"message": "use a more specific function name"
},
{
"selector": "UnaryExpression[operator=\"!\"][argument.type=\"ArrayExpression\"]",
"message": "see https://github.com/denysdovhan/wtfjs#-is-equal-"
},
{
"selector": "UnaryExpression[operator=\"typeof\"][argument.name=\"NaN\"]",
"message": "see https://github.com/denysdovhan/wtfjs#nan-is-not-a-number"
},
{
"selector": "BinaryExpression[left.type=\"BinaryExpression\"][operator=\">\"][left.operator=\">\"]",
"message": "see https://github.com/denysdovhan/wtfjs#comparison-of-three-numbers"
},
{
"selector": "CallExpression[callee.name='setTimeout'][arguments.length!=2]",
"message": "setTimeout must always be invoked with two arguments."
},
{
"selector": "CallExpression[callee.name='clearTimeout'][arguments.length!=1]",
"message": "clearTimeout must always be invoked with one argument."
},
{
"selector": "CallExpression[callee.object.name='window'][callee.property.name='clearTimeout'][arguments.length!=1]",
"message": "window.clearTimeout must always be invoked with one argument."
},
{
"selector": "CallExpression[callee.object.name='Object'][callee.property.name='freeze'][arguments.length!=1]",
"message": "Object.freeze must always be called with one argument."
},
{
"selector": "CallExpression[callee.object.name='Math'][callee.property.name='degrees']",
"message": "Math.degrees is in `Math Extensions`, a TC39 proposal on Stage 1"
},
{
"selector": "BinaryExpression[left.name=\"NaN\"]",
"message": "don't compare to NaN, see https://github.com/denysdovhan/wtfjs#nan-is-not-a-nan"
},
{
"selector": "BinaryExpression[right.name=\"NaN\"]",
"message": "don't compare to NaN, see https://github.com/denysdovhan/wtfjs#nan-is-not-a-nan"
},
{
"selector": "UpdateExpression[operator=\"--\"][argument.property.name=\"length\"]",
"message": "avoid `arr.length--`, see http://eamodeorubio.github.io/thejshorrorshow/#/44"
},
{
"selector": "[operator=instanceof]",
"message": "Using the operator `instanceof` is not allowed, see https://github.com/eslint/eslint/issues/11132"
},
{
"selector": "[operator=instanceof][right.type=\"Identifier\"][right.name=\"String\"]",
"message": "see https://github.com/denysdovhan/wtfjs#strings-arent-instances-of-string"
},
{
"selector": "CallExpression[callee.name.length=1]",
"message": "avoid call a short function name"
},
{
"selector": "NewExpression[callee.name='RegExp'][arguments.length > 2]",
"message": "Using 'RegExp' is not allowed with > two args"
},
{
"selector": "NewExpression[callee.name='Boolean']",
"message": "don't use new before Boolean constructor, see https://wtfjs.com/wtfs/2015-02-02-Boolean-constructor"
},
{
"selector": "CatchClause[param=null]",
"message": "Proposal: no-optional-catch-binding rule, see https://github.com/eslint/eslint/issues/10264"
},
{
"selector": "CallExpression > MemberExpression > ThisExpression[parent.property.name='$']",
"message": "Avoid Jquery (this.$)"
},
{
"selector": "MemberExpression[object.name='$'][property.name='each']",
"message": "Avoid Jquery ($.each)"
},
{
"selector": "MemberExpression[object.name='$']",
"message": "Avoid Jquery ($)"
},
{
"selector": "CallExpression[callee.name='$x']",
"message": "$x function is only available on browser console"
},
{
"selector": "CallExpression[callee.name='$$']",
"message": "$$ function is only available on browser console, prefer `document.querySelectorAll()`"
},
{
"selector": "CallExpression[callee.name='Number'][arguments.0.value.length>16]",
"message": "todo: repondre a https://github.com/eslint/eslint/issues/11279"
},
{
"selector": "CallExpression[callee.name='Number'][arguments.0.value>1234567890123456]",
"message": "todo: a finir, prefer BigInt (available on Node only) https://github.com/eslint/eslint/issues/11279"
},
{
"selector": "Literal[value>1234567890123456]:not([value.length])",
"message": "> 1234567890123456 https://github.com/eslint/eslint/issues/11279"
},
{
"selector": "Literal[value=/azerty|querty$/]",
"message": "for tests, prefer real data, see faker.js to generate massive amounts of fake data in the browser and node.js"
},
{
"selector": "[value.raw=/azerty|querty$/]",
"message": "for tests, prefer real data, see faker.js to generate massive amounts of fake data in the browser and node.js"
},
{
"selector": "VariableDeclaration > VariableDeclarator[init.callee.name=\"importLazy\"][id.properties.0.kind=\"init\"]",
"message": "don't destructuring for having lazy"
},
{
"selector": "WithStatement",
"message": "`with` statement is not recommended, as it may be the source of confusing bugs and compatibility issues, and is forbidden in ECMAScript 5 strict mode"
},
{
"selector": "CallExpression[callee.name=\"Boolean\"][arguments.0.type=\"CallExpression\"][arguments.0.callee.name=\"Boolean\"]",
"message": "Double Boolean constructor all"
},
{
"selector": "CallExpression[callee.name=\"asap\"][arguments.0.type=\"FunctionExpression\"][arguments.0.params.0]",
"message": "don't use parameter(s), use an anonymous function with `asap` librairy"
},
{
"selector": "CallExpression[callee.object.name=\"Promise\"][callee.property.name=\"all\"][arguments.0.type=\"ArrayExpression\"]",
"message": "Promise.all([]), https://blog.impulsebyingeniance.io/software-technology/eviter-le-fail-fast-de-promise-all/"
},
{
"selector": "AssignmentExpression[operator=\"=\"][left.name=\"arr\"][right.callee.name=\"Promise\"]",
"message": "arr = new Promise(); -> avoid arr"
},
{
"selector": "NewExpression[callee.name=\"PasswordCredential\"][arguments]",
"message": "new PasswordCredential constructor: need an id not empty and a password"
},
{
"selector": "VariableDeclarator[id.name=\"iconURL\"][init.value!=/(gif|jpeg|jpg|png|svg)$/]",
"message": "iconURL value: icon gif|jpeg|jpg|png|svg not detetected in URL"
},
{
"selector": "VariableDeclaration > VariableDeclarator[id.name][init.operator=\"+\"][init.right.value!=/(gif|jpeg|jpg|png|svg)$/]",
"message": "iconURL value: icon gif|jpeg|jpg|png|svg not detetected in URL construction"
}
]
},
"plugins": [
"markdown",
"arca",
"nuxt",
"json",
"arithmetic",
"no-useless-assign",
"jsdoc",
"node",
"unicorn",
"pureness"
],
"extends": [
"eslint:recommended",
"plugin:you-dont-need-lodash-underscore/compatible",
"plugin:node/recommended"
],
"globals": {
"PasswordCredential": "readonly"
}
}