1
+ {
2
+ "extends": "airbnb-base",
3
+ "parserOptions": {
4
+ "sourceType": "script"
5
+ },
6
+
7
+ "rules": {
8
+ // === Configure rules for our style ===
9
+ // imports must be resolvable
10
+ "import/no-unresolved": "error",
11
+ // use single quotes,
12
+ // unless a different style allows avoiding escapes
13
+ "quotes": ["error", "single", {
14
+ "avoidEscape": true,
15
+ "allowTemplateLiterals": true
16
+ }],
17
+ // allow else-if return
18
+ "no-else-return": [ "error", { "allowElseIf": true } ],
19
+ // expressions split over multiple lines
20
+ // should break after the operator
21
+ "operator-linebreak": [ "error", "after" ],
22
+ // require arrow parens only when needed
23
+ // and whenever the body is a block
24
+ "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
25
+ // what variables are errors in callbacks
26
+ "handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
27
+ // allow dangling commas in functions
28
+ // require them everywhere else
29
+ "comma-dangle": ["error", {
30
+ "arrays": "always-multiline",
31
+ "objects": "always-multiline",
32
+ "imports": "always-multiline",
33
+ "exports": "always-multiline",
34
+ "functions": "only-multiline"
35
+ }],
36
+ // we actually encourage `return await`
37
+ "no-return-await": "off",
38
+ // allow `while (true)`
39
+ "no-constant-condition": ["error", { "checkLoops": false }],
40
+ // allow ignoring an error with `catch`
41
+ "no-empty": ["error", { "allowEmptyCatch": true }],
42
+ // allow `3 + 5 - 1`, but not `3 * 5 - 1`
43
+ "no-mixed-operators": ["error", { "allowSamePrecedence": true }],
44
+ // require `'use strict';`
45
+ "strict": ["error", "global"],
46
+ // we actually use tabs for indentation
47
+ "indent": ["error", "tab", { "SwitchCase": 1 }],
48
+ "no-tabs": "off",
49
+ // we want `== null` to also handle undefined
50
+ "no-eq-null": "off",
51
+ // allow `for (..; i++)`
52
+ "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
53
+ // allow using functions defined later
54
+ "no-use-before-define": ["error", "nofunc"],
55
+ // require consistent newlines before and after braces
56
+ // if contents are multiline
57
+ "object-curly-newline": ["error", { "consistent": true, "multiline": true }],
58
+ // require consistent linebreaks inline function parenthesis (arguments or params)
59
+ "function-paren-newline": ["error", "consistent"],
60
+ // only require const if all parts of destructuring can be const
61
+ "prefer-const": ["error", { "destructuring": "all" }],
62
+ // don't require destructuring for arrays or assignment
63
+ "prefer-destructuring": ["error", {
64
+ "VariableDeclarator": { "array": false, "object": true },
65
+ "AssignmentExpression": { "array": false, "object": false }
66
+ }],
67
+ // identical to airbnb rule, except for allowing for..of, because we want to use it
68
+ "no-restricted-syntax": [
69
+ "error",
70
+ {
71
+ "selector": "ForInStatement",
72
+ "message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
73
+ },
74
+ {
75
+ "selector": "LabeledStatement",
76
+ "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
77
+ },
78
+ {
79
+ "selector": "WithStatement",
80
+ "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
81
+ }
82
+ ],
83
+ // allow lines of up to 120 characters
84
+ "max-len": ["error", { "code": 120, "tabWidth": 2, "ignoreUrls": true, "ignoreStrings": true, "ignoreTemplateLiterals": true, "ignoreRegExpLiterals": true }],
85
+
86
+ // === Disable rules ===
87
+ // more liberal naming
88
+ "camelcase": "off",
89
+ "no-underscore-dangle": "off",
90
+ // don't require anonymous function names
91
+ "func-names": "off",
92
+ // allow console
93
+ "no-console": "off",
94
+ // allow new for side effects
95
+ // allow new with non-capitalized
96
+ "no-new": "off",
97
+ "new-cap": "off",
98
+ // allow shadowing variables (usually callbacks)
99
+ "no-shadow": "off",
100
+ // allow multiple empty lines in a row
101
+ "no-multiple-empty-lines": "off",
102
+ // allow not using object shorthand
103
+ "object-shorthand": "off",
104
+
105
+ // TODO
106
+ "consistent-return": "off",
107
+ "no-restricted-globals": "off",
108
+ "no-prototype-builtins": "off",
109
+ "import/no-extraneous-dependencies": "off",
110
+ "import/no-dynamic-require": "off",
111
+ "global-require": "off",
112
+ "no-param-reassign": "off",
113
+ "default-case": "off"
114
+ }
115
+ }
0 commit comments