|
| 1 | +/** The official Eslint rules that are constructive and not included in recommended. |
| 2 | + * The formatting/stylistic rules are not among these. |
| 3 | + * The rules that might be useful in future are commented. |
| 4 | + */ |
| 5 | +exports.eslintRulesExtra = { |
| 6 | + // Source https://eslint.org/docs/rules/#possible-errors |
| 7 | + "no-await-in-loop": "error", // disallow `await` inside of loops |
| 8 | + // "no-console": ["error", { allow: ["warn", "error"] }], // disallow the use of `console` // console.log is useful in CLI tools |
| 9 | + "no-loss-of-precision": "error", // disallow literal numbers that lose precision |
| 10 | + "no-promise-executor-return": "error", // disallow returning values from Promise executor functions |
| 11 | + "no-template-curly-in-string": "warn", // disallow template literal placeholder syntax in regular strings |
| 12 | + "no-unreachable-loop": "error", // disallow loops with a body that allows only one iteration |
| 13 | + // "no-unsafe-optional-chaining": "error", // disallow use of optional chaining in contexts where the `undefined` value is not allowed // TODO doesn't work |
| 14 | + "no-useless-backreference": "error", // disallow useless backreferences in regular expressions |
| 15 | + "require-atomic-updates": "error", // disallow assignments that can lead to race conditions due to usage of `await` or `yield` |
| 16 | + |
| 17 | + // Source https://eslint.org/docs/rules/#best-practices |
| 18 | + // "accessor-pairs": "error", // enforce getter and setter pairs in objects and classes |
| 19 | + "array-callback-return": "error", // enforce `return` statements in callbacks of array methods |
| 20 | + "block-scoped-var": "error", // enforce the use of variables within the scope they are defined |
| 21 | + "class-methods-use-this": "error", // enforce that class methods utilize `this` |
| 22 | + // complexity: "error", // enforce a maximum cyclomatic complexity allowed in a program |
| 23 | + // "consistent-return": "error", // require `return` statements to either always or never specify values |
| 24 | + curly: "error", // enforce consistent brace style for all control statements |
| 25 | + "default-case": "error", // require `default` cases in `switch` statements |
| 26 | + "default-case-last": "error", // enforce default clauses in switch statements to be last |
| 27 | + "default-param-last": "error", // enforce default parameters to be last |
| 28 | + "dot-notation": "error", // enforce dot notation whenever possible |
| 29 | + eqeqeq: "error", // require the use of `===` and `!==` |
| 30 | + "grouped-accessor-pairs": "error", // require grouped accessor pairs in object literals and classes |
| 31 | + // "guard-for-in": "error", // require `for-in` loops to include an `if` statement |
| 32 | + // "no-alert": "error", // disallow the use of `alert`, `confirm`, and `prompt` |
| 33 | + "no-caller": "error", // disallow the use of `arguments.caller` or `arguments.callee` |
| 34 | + "no-constructor-return": "error", // disallow returning value from constructor |
| 35 | + "no-div-regex": "error", // disallow division operators explicitly at the beginning of regular expressions |
| 36 | + "no-empty-function": "error", // disallow empty functions |
| 37 | + "no-eq-null": "error", // disallow `null` comparisons without type-checking operators |
| 38 | + "no-eval": "error", // disallow the use of `eval()` |
| 39 | + "no-extend-native": "error", // disallow extending native types |
| 40 | + "no-extra-bind": "error", // disallow unnecessary calls to `.bind()` |
| 41 | + "no-extra-label": "error", // disallow unnecessary labels |
| 42 | + "no-floating-decimal": "error", // disallow leading or trailing decimal points in numeric literals |
| 43 | + "no-implicit-coercion": "error", // disallow shorthand type conversions |
| 44 | + "no-implicit-globals": "error", // disallow declarations in the global scope // check |
| 45 | + "no-implied-eval": "error", // disallow the use of `eval()`-like methods |
| 46 | + "no-invalid-this": "error", // disallow `this` keywords outside of classes or class-like objects |
| 47 | + "no-iterator": "error", // disallow the use of the `__iterator__` property |
| 48 | + "no-labels": "error", // disallow labeled statements |
| 49 | + "no-lone-blocks": "error", // disallow unnecessary nested blocks |
| 50 | + "no-loop-func": "error", // disallow function declarations that contain unsafe references inside loop statements |
| 51 | + // "no-magic-numbers": "error", // disallow magic numbers |
| 52 | + "no-multi-str": "error", // disallow multiline strings |
| 53 | + "no-new": "error", // disallow `new` operators outside of assignments or comparisons |
| 54 | + "no-new-func": "error", // disallow `new` operators with the `Function` object |
| 55 | + "no-new-wrappers": "error", // disallow `new` operators with the `String`, `Number`, and `Boolean` objects |
| 56 | + // "no-nonoctal-decimal-escape": "error", // disallow `\8` and `\9` escape sequences in string literals // TODO doesn't work |
| 57 | + "no-octal-escape": "error", // disallow octal escape sequences in string literals |
| 58 | + "no-param-reassign": ["error", { props: false }], // disallow reassigning `function` parameters |
| 59 | + "no-proto": "error", // disallow the use of the `__proto__` property |
| 60 | + // "no-restricted-properties": "error", // disallow certain properties on certain objects |
| 61 | + "no-return-assign": "error", // disallow assignment operators in `return` statements |
| 62 | + "no-return-await": "error", // disallow unnecessary `return await` |
| 63 | + "no-script-url": "error", // disallow `javascript:` urls |
| 64 | + "no-self-compare": "error", // disallow comparisons where both sides are exactly the same |
| 65 | + "no-sequences": "error", // disallow comma operators |
| 66 | + "no-throw-literal": "error", // disallow throwing literals as exceptions |
| 67 | + // "no-unmodified-loop-condition": "error", // disallow unmodified loop conditions |
| 68 | + "no-unused-expressions": "error", // disallow unused expressions |
| 69 | + "no-useless-call": "error", // disallow unnecessary calls to `.call()` and `.apply()` |
| 70 | + "no-useless-concat": "error", // disallow unnecessary concatenation of literals or template literals |
| 71 | + // "no-useless-return": "error", // disallow redundant return statements |
| 72 | + // "no-void": "error", // disallow `void` operators |
| 73 | + // "no-warning-comments": "error", // disallow specified warning terms in comments |
| 74 | + // "prefer-named-capture-group": "error", // enforce using named capture group in regular expression |
| 75 | + "prefer-promise-reject-errors": ["error", { allowEmptyReject: true }], // require using Error objects as Promise rejection reasons |
| 76 | + "prefer-regex-literals": "error", // disallow use of the `RegExp` constructor in favor of regular expression literals |
| 77 | + radix: "error", // enforce the consistent use of the radix argument when using `parseInt()` |
| 78 | + "require-await": "error", // disallow async functions which have no `await` expression // check |
| 79 | + // "require-unicode-regexp": "error", // enforce the use of `u` flag on RegExp |
| 80 | + // "vars-on-top": "error", // require `var` declarations be placed at the top of their containing scope |
| 81 | + // "wrap-iife": "error", // require parentheses around immediate `function` invocations |
| 82 | + // yoda: "error", // require or disallow "Yoda" conditions |
| 83 | + |
| 84 | + // https://eslint.org/docs/rules/#strict-mode |
| 85 | + strict: "error", // require or disallow strict mode directives |
| 86 | + |
| 87 | + // Source: https://eslint.org/docs/rules/#variables |
| 88 | + // "init-declarations": "error", //require or disallow initialization in variable declarations |
| 89 | + "no-label-var": "error", //disallow labels that share a name with a variable |
| 90 | + // "no-restricted-globals": "error", //disallow specified global variables |
| 91 | + "no-shadow": ["error", { builtinGlobals: false, hoist: "all", allow: [] }], //disallow variable declarations from shadowing variables declared in the outer scope |
| 92 | + // TODO Atom's Range, Notification, Window cause this rule to error. In Atom env, these should error once not imported. |
| 93 | + |
| 94 | + // "no-use-before-define": "error", // disallow the use of variables before they are defined |
| 95 | + |
| 96 | + // Source: https://eslint.org/docs/rules/#ecmascript-6 |
| 97 | + "no-confusing-arrow": "error", // disallow arrow functions where they could be confused with comparisons |
| 98 | + // "no-duplicate-imports": "error", // disallow duplicate module imports // Buggy with Flow and TypeScript |
| 99 | + // "no-restricted-exports": "error", // disallow specified names in exports |
| 100 | + // "no-restricted-imports": "error", // disallow specified modules when loaded by `import` |
| 101 | + "no-useless-computed-key": "error", // disallow unnecessary computed property keys in objects and classes |
| 102 | + "no-useless-constructor": "error", // disallow unnecessary constructors |
| 103 | + "no-useless-rename": "error", // disallow renaming import, export, and destructured assignments to the same name |
| 104 | + "no-var": "error", // require `let` or `const` instead of `var` |
| 105 | + "object-shorthand": "error", // require or disallow method and property shorthand syntax for object literals |
| 106 | + // "prefer-arrow-callback": "error", // require using arrow functions for callbacks |
| 107 | + "prefer-const": "error", // require `const` declarations for variables that are never reassigned after declared |
| 108 | + // "prefer-destructuring": "error", // require destructuring from arrays and/or objects |
| 109 | + "prefer-numeric-literals": "error", // disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals |
| 110 | + "prefer-rest-params": "error", // require rest parameters instead of `arguments` |
| 111 | + "prefer-spread": "error", // require spread operators instead of `.apply()` |
| 112 | + "prefer-template": "error", // require template literals instead of string concatenation |
| 113 | + "symbol-description": "error", // require symbol descriptions |
| 114 | +} |
0 commit comments