|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + "env": { |
| 5 | + "node": true, |
| 6 | + "es6": true |
| 7 | + }, |
| 8 | + |
| 9 | + "parserOptions": { |
| 10 | + "ecmaVersion": 9 |
| 11 | + }, |
| 12 | + |
| 13 | + "globals": { |
| 14 | + "fetch": false, |
| 15 | + "WebAssembly": false |
| 16 | + }, |
| 17 | + |
| 18 | + "rules": { |
| 19 | + // Require spacing around => |
| 20 | + "arrow-spacing": "error", |
| 21 | + |
| 22 | + // Braces only needed for multi-line arrow function blocks |
| 23 | + // "arrow-body-style": ["error", "as-needed"] |
| 24 | + |
| 25 | + // Always require spacing around a single line block |
| 26 | + "block-spacing": "error", |
| 27 | + |
| 28 | + // No newline before open brace for a block |
| 29 | + "brace-style": ["error", "1tbs", { "allowSingleLine": true }], |
| 30 | + |
| 31 | + // No space before always a space after a comma |
| 32 | + "comma-spacing": ["error", {"after": true, "before": false}], |
| 33 | + |
| 34 | + // Commas at the end of the line not the start |
| 35 | + "comma-style": "error", |
| 36 | + |
| 37 | + // Warn about cyclomatic complexity in functions. |
| 38 | + // XXX Get this down to 20? |
| 39 | + "complexity": ["error", 25], |
| 40 | + |
| 41 | + // Don't require spaces around computed properties |
| 42 | + "computed-property-spacing": ["error", "never"], |
| 43 | + |
| 44 | + // Functions must always return something or nothing |
| 45 | + "consistent-return": "error", |
| 46 | + |
| 47 | + // Require braces around blocks that start a new line |
| 48 | + "curly": ["error", "multi-line"], |
| 49 | + |
| 50 | + // Encourage the use of dot notation whenever possible. |
| 51 | + "dot-notation": "error", |
| 52 | + |
| 53 | + // Always require a trailing EOL |
| 54 | + "eol-last": "error", |
| 55 | + |
| 56 | + // No spaces between function name and parentheses |
| 57 | + "func-call-spacing": "error", |
| 58 | + |
| 59 | + // Require function* name() |
| 60 | + "generator-star-spacing": ["error", {"after": true, "before": false}], |
| 61 | + |
| 62 | + // Two space indent |
| 63 | + // "indent": ["error", 2, { "SwitchCase": 1 }], |
| 64 | + |
| 65 | + // Space after colon not before in property declarations |
| 66 | + "key-spacing": ["error", { |
| 67 | + "afterColon": true, |
| 68 | + "beforeColon": false, |
| 69 | + "mode": "minimum" |
| 70 | + }], |
| 71 | + |
| 72 | + // Require spaces before and after keywords |
| 73 | + "keyword-spacing": "error", |
| 74 | + |
| 75 | + // Unix linebreaks |
| 76 | + "linebreak-style": ["error", "unix"], |
| 77 | + |
| 78 | + // Don't enforce the maximum depth that blocks can be nested. The complexity |
| 79 | + // rule is a better rule to check this. |
| 80 | + "max-depth": "off", |
| 81 | + |
| 82 | + // Maximum depth callbacks can be nested. |
| 83 | + "max-nested-callbacks": ["error", 10], |
| 84 | + |
| 85 | + // Always require parenthesis for new calls |
| 86 | + "new-parens": "error", |
| 87 | + |
| 88 | + // Use [] instead of Array() |
| 89 | + "no-array-constructor": "error", |
| 90 | + |
| 91 | + // Disallow use of arguments.caller or arguments.callee. |
| 92 | + "no-caller": "error", |
| 93 | + |
| 94 | + // Disallow modifying variables of class declarations. |
| 95 | + "no-class-assign": "error", |
| 96 | + |
| 97 | + // Disallow assignment operators in conditional statements |
| 98 | + "no-cond-assign": "error", |
| 99 | + |
| 100 | + // Disallow modifying variables that are declared using const. |
| 101 | + "no-const-assign": "error", |
| 102 | + |
| 103 | + // Disallow control characters in regular expressions. |
| 104 | + "no-control-regex": "error", |
| 105 | + |
| 106 | + // Disallow the use of debugger |
| 107 | + "no-debugger": "error", |
| 108 | + |
| 109 | + // Disallow deleting variables |
| 110 | + "no-delete-var": "error", |
| 111 | + |
| 112 | + // No duplicate arguments in function declarations |
| 113 | + "no-dupe-args": "error", |
| 114 | + |
| 115 | + // Disallow duplicate class members. |
| 116 | + "no-dupe-class-members": "error", |
| 117 | + |
| 118 | + // No duplicate keys in object declarations |
| 119 | + "no-dupe-keys": "error", |
| 120 | + |
| 121 | + // No duplicate cases in switch statements |
| 122 | + "no-duplicate-case": "error", |
| 123 | + |
| 124 | + // If an if block ends with a return no need for an else block |
| 125 | + "no-else-return": "error", |
| 126 | + |
| 127 | + // No empty statements |
| 128 | + "no-empty": ["error", {"allowEmptyCatch": true}], |
| 129 | + |
| 130 | + // No empty character classes in regex |
| 131 | + "no-empty-character-class": "error", |
| 132 | + |
| 133 | + // Disallow empty destructuring |
| 134 | + "no-empty-pattern": "error", |
| 135 | + |
| 136 | + // Disallow eval and setInteral/setTimeout with strings |
| 137 | + "no-eval": "error", |
| 138 | + |
| 139 | + // No assigning to exception variable |
| 140 | + "no-ex-assign": "error", |
| 141 | + |
| 142 | + // Disallow unnecessary calls to .bind() |
| 143 | + "no-extra-bind": "error", |
| 144 | + |
| 145 | + // No using !! where casting to boolean is already happening |
| 146 | + "no-extra-boolean-cast": "error", |
| 147 | + |
| 148 | + // No double semicolon |
| 149 | + "no-extra-semi": "error", |
| 150 | + |
| 151 | + // No overwriting defined functions |
| 152 | + "no-func-assign": "error", |
| 153 | + |
| 154 | + // Disallow eval and setInteral/setTimeout with strings |
| 155 | + "no-implied-eval": "error", |
| 156 | + |
| 157 | + // No invalid regular expressions |
| 158 | + "no-invalid-regexp": "error", |
| 159 | + |
| 160 | + // No odd whitespace characters |
| 161 | + "no-irregular-whitespace": "error", |
| 162 | + |
| 163 | + // Disallow the use of the __iterator__ property |
| 164 | + "no-iterator": "error", |
| 165 | + |
| 166 | + // No labels |
| 167 | + "no-labels": "error", |
| 168 | + |
| 169 | + // Disallow unnecessary nested blocks |
| 170 | + "no-lone-blocks": "error", |
| 171 | + |
| 172 | + // No single if block inside an else block |
| 173 | + "no-lonely-if": "error", |
| 174 | + |
| 175 | + // no-tabs disallows tabs completely. |
| 176 | + // "no-mixed-spaces-and-tabs": "error", |
| 177 | + |
| 178 | + // No unnecessary spacing |
| 179 | + "no-multi-spaces": ["error", { exceptions: { |
| 180 | + "ArrayExpression": true, |
| 181 | + "AssignmentExpression": true, |
| 182 | + "ObjectExpression": true, |
| 183 | + "VariableDeclarator": true |
| 184 | + } }], |
| 185 | + |
| 186 | + // No reassigning native JS objects |
| 187 | + "no-native-reassign": "error", |
| 188 | + |
| 189 | + // Nested ternary statements are confusing |
| 190 | + "no-nested-ternary": "error", |
| 191 | + |
| 192 | + // Use {} instead of new Object() |
| 193 | + "no-new-object": "error", |
| 194 | + |
| 195 | + // Dissallow use of new wrappers |
| 196 | + "no-new-wrappers": "error", |
| 197 | + |
| 198 | + // No Math() or JSON() |
| 199 | + "no-obj-calls": "error", |
| 200 | + |
| 201 | + // No octal literals |
| 202 | + "no-octal": "error", |
| 203 | + |
| 204 | + // No redeclaring variables |
| 205 | + "no-redeclare": "error", |
| 206 | + |
| 207 | + // Disallow multiple spaces in regular expressions |
| 208 | + "no-regex-spaces": "error", |
| 209 | + |
| 210 | + // Disallows unnecessary `return await ...`. |
| 211 | + "no-return-await": "error", |
| 212 | + |
| 213 | + // Disallow assignments where both sides are exactly the same |
| 214 | + "no-self-assign": "error", |
| 215 | + |
| 216 | + // No unnecessary comparisons |
| 217 | + "no-self-compare": "error", |
| 218 | + |
| 219 | + // No declaring variables from an outer scope |
| 220 | + "no-shadow": "error", |
| 221 | + |
| 222 | + // No declaring variables that hide things like arguments |
| 223 | + "no-shadow-restricted-names": "error", |
| 224 | + |
| 225 | + // Disallow sparse arrays |
| 226 | + "no-sparse-arrays": "error", |
| 227 | + |
| 228 | + // Disallow tabs. |
| 229 | + "no-tabs": "error", |
| 230 | + |
| 231 | + // No trailing whitespace |
| 232 | + "no-trailing-spaces": "error", |
| 233 | + |
| 234 | + // No using undeclared variables |
| 235 | + "no-undef": "error", |
| 236 | + |
| 237 | + // Error on newline where a semicolon is needed |
| 238 | + "no-unexpected-multiline": "error", |
| 239 | + |
| 240 | + // Disallow the use of Boolean literals in conditional expressions. |
| 241 | + "no-unneeded-ternary": "error", |
| 242 | + |
| 243 | + // No unreachable statements |
| 244 | + "no-unreachable": "error", |
| 245 | + |
| 246 | + // Disallow control flow statements in finally blocks |
| 247 | + "no-unsafe-finally": "error", |
| 248 | + |
| 249 | + // No (!foo in bar) or (!object instanceof Class) |
| 250 | + "no-unsafe-negation": "error", |
| 251 | + |
| 252 | + // No declaring variables that are never used |
| 253 | + "no-unused-vars": ["error", { |
| 254 | + "args": "none", |
| 255 | + "vars": "local" |
| 256 | + }], |
| 257 | + |
| 258 | + // No using variables before defined |
| 259 | + "no-use-before-define": ["error", "nofunc"], |
| 260 | + |
| 261 | + // Disallow unnecessary .call() and .apply() |
| 262 | + "no-useless-call": "error", |
| 263 | + |
| 264 | + // Don't concatenate string literals together (unless they span multiple |
| 265 | + // lines) |
| 266 | + "no-useless-concat": "error", |
| 267 | + |
| 268 | + // Disallow redundant return statements |
| 269 | + "no-useless-return": "error", |
| 270 | + |
| 271 | + // Disallow whitespace before properties. |
| 272 | + "no-whitespace-before-property": "error", |
| 273 | + |
| 274 | + // No using with |
| 275 | + "no-with": "error", |
| 276 | + |
| 277 | + // Require object-literal shorthand with ES6 method syntax |
| 278 | + "object-shorthand": ["error", "always", { "avoidQuotes": true }], |
| 279 | + |
| 280 | + // Require double-quotes everywhere, except where quotes are escaped |
| 281 | + // or template literals are used. |
| 282 | + "quotes": ["error", "double", { |
| 283 | + "allowTemplateLiterals": true, |
| 284 | + "avoidEscape": true |
| 285 | + }], |
| 286 | + |
| 287 | + // No spacing inside rest or spread expressions |
| 288 | + "rest-spread-spacing": "error", |
| 289 | + |
| 290 | + // Always require semicolon at end of statement |
| 291 | + "semi": ["error", "always"], |
| 292 | + |
| 293 | + // Require space before blocks |
| 294 | + "space-before-blocks": "error", |
| 295 | + |
| 296 | + // Never use spaces before function parentheses |
| 297 | + "space-before-function-paren": ["error", { |
| 298 | + "anonymous": "never", |
| 299 | + "asyncArrow": "always", |
| 300 | + "named": "never" |
| 301 | + }], |
| 302 | + |
| 303 | + // No space padding in parentheses |
| 304 | + "space-in-parens": ["error", "never"], |
| 305 | + |
| 306 | + // Require spaces around operators |
| 307 | + "space-infix-ops": ["error", { "int32Hint": true }], |
| 308 | + |
| 309 | + // ++ and -- should not need spacing |
| 310 | + "space-unary-ops": ["error", { |
| 311 | + "nonwords": false, |
| 312 | + "overrides": { |
| 313 | + "typeof": false // We tend to use typeof as a function call |
| 314 | + }, |
| 315 | + "words": true |
| 316 | + }], |
| 317 | + |
| 318 | + // Requires or disallows a whitespace (space or tab) beginning a comment |
| 319 | + "spaced-comment": "error", |
| 320 | + |
| 321 | + // No comparisons to NaN |
| 322 | + "use-isnan": "error", |
| 323 | + |
| 324 | + // Only check typeof against valid results |
| 325 | + "valid-typeof": "error" |
| 326 | + } |
| 327 | +}; |
0 commit comments