errors.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. module.exports = {
  2. rules: {
  3. // Enforce “for” loop update clause moving the counter in the right direction
  4. // https://eslint.org/docs/rules/for-direction
  5. 'for-direction': 'error',
  6. // Enforces that a return statement is present in property getters
  7. // https://eslint.org/docs/rules/getter-return
  8. 'getter-return': ['error', { allowImplicit: true }],
  9. // disallow using an async function as a Promise executor
  10. // https://eslint.org/docs/rules/no-async-promise-executor
  11. 'no-async-promise-executor': 'error',
  12. // Disallow await inside of loops
  13. // https://eslint.org/docs/rules/no-await-in-loop
  14. 'no-await-in-loop': 'error',
  15. // Disallow comparisons to negative zero
  16. // https://eslint.org/docs/rules/no-compare-neg-zero
  17. 'no-compare-neg-zero': 'error',
  18. // disallow assignment in conditional expressions
  19. 'no-cond-assign': ['error', 'always'],
  20. // disallow use of console
  21. 'no-console': 'warn',
  22. // disallow use of constant expressions in conditions
  23. 'no-constant-condition': 'warn',
  24. // disallow control characters in regular expressions
  25. 'no-control-regex': 'error',
  26. // disallow use of debugger
  27. 'no-debugger': 'error',
  28. // disallow duplicate arguments in functions
  29. 'no-dupe-args': 'error',
  30. // Disallow duplicate conditions in if-else-if chains
  31. // https://eslint.org/docs/rules/no-dupe-else-if
  32. 'no-dupe-else-if': 'error',
  33. // disallow duplicate keys when creating object literals
  34. 'no-dupe-keys': 'error',
  35. // disallow a duplicate case label.
  36. 'no-duplicate-case': 'error',
  37. // disallow empty statements
  38. 'no-empty': 'error',
  39. // disallow the use of empty character classes in regular expressions
  40. 'no-empty-character-class': 'error',
  41. // disallow assigning to the exception in a catch block
  42. 'no-ex-assign': 'error',
  43. // disallow double-negation boolean casts in a boolean context
  44. // https://eslint.org/docs/rules/no-extra-boolean-cast
  45. 'no-extra-boolean-cast': 'error',
  46. // disallow unnecessary parentheses
  47. // https://eslint.org/docs/rules/no-extra-parens
  48. 'no-extra-parens': ['off', 'all', {
  49. conditionalAssign: true,
  50. nestedBinaryExpressions: false,
  51. returnAssign: false,
  52. ignoreJSX: 'all', // delegate to eslint-plugin-react
  53. enforceForArrowConditionals: false,
  54. }],
  55. // disallow unnecessary semicolons
  56. 'no-extra-semi': 'error',
  57. // disallow overwriting functions written as function declarations
  58. 'no-func-assign': 'error',
  59. // https://eslint.org/docs/rules/no-import-assign
  60. 'no-import-assign': 'error',
  61. // disallow function or variable declarations in nested blocks
  62. 'no-inner-declarations': 'error',
  63. // disallow invalid regular expression strings in the RegExp constructor
  64. 'no-invalid-regexp': 'error',
  65. // disallow irregular whitespace outside of strings and comments
  66. 'no-irregular-whitespace': 'error',
  67. // Disallow Number Literals That Lose Precision
  68. // https://eslint.org/docs/rules/no-loss-of-precision
  69. 'no-loss-of-precision': 'error',
  70. // Disallow characters which are made with multiple code points in character class syntax
  71. // https://eslint.org/docs/rules/no-misleading-character-class
  72. 'no-misleading-character-class': 'error',
  73. // disallow the use of object properties of the global object (Math and JSON) as functions
  74. 'no-obj-calls': 'error',
  75. // Disallow returning values from Promise executor functions
  76. // https://eslint.org/docs/rules/no-promise-executor-return
  77. 'no-promise-executor-return': 'error',
  78. // disallow use of Object.prototypes builtins directly
  79. // https://eslint.org/docs/rules/no-prototype-builtins
  80. 'no-prototype-builtins': 'error',
  81. // disallow multiple spaces in a regular expression literal
  82. 'no-regex-spaces': 'error',
  83. // Disallow returning values from setters
  84. // https://eslint.org/docs/rules/no-setter-return
  85. 'no-setter-return': 'error',
  86. // disallow sparse arrays
  87. 'no-sparse-arrays': 'error',
  88. // Disallow template literal placeholder syntax in regular strings
  89. // https://eslint.org/docs/rules/no-template-curly-in-string
  90. 'no-template-curly-in-string': 'error',
  91. // Avoid code that looks like two expressions but is actually one
  92. // https://eslint.org/docs/rules/no-unexpected-multiline
  93. 'no-unexpected-multiline': 'error',
  94. // disallow unreachable statements after a return, throw, continue, or break statement
  95. 'no-unreachable': 'error',
  96. // Disallow loops with a body that allows only one iteration
  97. // https://eslint.org/docs/rules/no-unreachable-loop
  98. 'no-unreachable-loop': ['error', {
  99. ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
  100. }],
  101. // disallow return/throw/break/continue inside finally blocks
  102. // https://eslint.org/docs/rules/no-unsafe-finally
  103. 'no-unsafe-finally': 'error',
  104. // disallow negating the left operand of relational operators
  105. // https://eslint.org/docs/rules/no-unsafe-negation
  106. 'no-unsafe-negation': 'error',
  107. // disallow use of optional chaining in contexts where the undefined value is not allowed
  108. // https://eslint.org/docs/rules/no-unsafe-optional-chaining
  109. 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
  110. // Disallow Unused Private Class Members
  111. // https://eslint.org/docs/rules/no-unused-private-class-members
  112. // TODO: enable once eslint 7 is dropped (which is semver-major)
  113. 'no-unused-private-class-members': 'off',
  114. // Disallow useless backreferences in regular expressions
  115. // https://eslint.org/docs/rules/no-useless-backreference
  116. 'no-useless-backreference': 'error',
  117. // disallow negation of the left operand of an in expression
  118. // deprecated in favor of no-unsafe-negation
  119. 'no-negated-in-lhs': 'off',
  120. // Disallow assignments that can lead to race conditions due to usage of await or yield
  121. // https://eslint.org/docs/rules/require-atomic-updates
  122. // note: not enabled because it is very buggy
  123. 'require-atomic-updates': 'off',
  124. // disallow comparisons with the value NaN
  125. 'use-isnan': 'error',
  126. // ensure JSDoc comments are valid
  127. // https://eslint.org/docs/rules/valid-jsdoc
  128. 'valid-jsdoc': 'off',
  129. // ensure that the results of typeof are compared against a valid string
  130. // https://eslint.org/docs/rules/valid-typeof
  131. 'valid-typeof': ['error', { requireStringLiterals: true }],
  132. }
  133. };