eslint 8.0.0-beta.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +4 -4
  2. package/bin/eslint.js +1 -1
  3. package/conf/eslint-recommended.js +1 -1
  4. package/conf/{category-list.json → rule-type-list.json} +4 -7
  5. package/lib/cli-engine/cli-engine.js +11 -3
  6. package/lib/cli-engine/file-enumerator.js +4 -3
  7. package/lib/cli-engine/formatters/html.js +1 -1
  8. package/lib/cli-engine/hash.js +2 -2
  9. package/lib/cli-engine/xml-escape.js +1 -1
  10. package/lib/config/flat-config-array.js +2 -2
  11. package/lib/config/flat-config-schema.js +1 -1
  12. package/lib/config/rule-validator.js +25 -8
  13. package/lib/eslint/eslint.js +4 -0
  14. package/lib/init/autoconfig.js +17 -18
  15. package/lib/init/config-file.js +3 -3
  16. package/lib/init/config-initializer.js +11 -10
  17. package/lib/init/config-rule.js +15 -16
  18. package/lib/init/npm-utils.js +16 -15
  19. package/lib/init/source-code-utils.js +6 -5
  20. package/lib/linter/apply-disable-directives.js +80 -11
  21. package/lib/linter/code-path-analysis/code-path-analyzer.js +115 -36
  22. package/lib/linter/code-path-analysis/code-path-segment.js +0 -1
  23. package/lib/linter/code-path-analysis/code-path-state.js +4 -1
  24. package/lib/linter/code-path-analysis/code-path.js +14 -5
  25. package/lib/linter/code-path-analysis/debug-helpers.js +2 -2
  26. package/lib/linter/code-path-analysis/fork-context.js +0 -1
  27. package/lib/linter/code-path-analysis/id-generator.js +0 -1
  28. package/lib/linter/config-comment-parser.js +1 -1
  29. package/lib/linter/linter.js +51 -22
  30. package/lib/linter/node-event-generator.js +0 -1
  31. package/lib/linter/report-translator.js +12 -12
  32. package/lib/linter/rules.js +3 -0
  33. package/lib/linter/safe-emitter.js +2 -2
  34. package/lib/linter/source-code-fixer.js +2 -2
  35. package/lib/linter/timing.js +2 -2
  36. package/lib/rule-tester/rule-tester.js +12 -2
  37. package/lib/rules/accessor-pairs.js +0 -1
  38. package/lib/rules/array-bracket-newline.js +0 -1
  39. package/lib/rules/array-bracket-spacing.js +0 -1
  40. package/lib/rules/array-callback-return.js +0 -1
  41. package/lib/rules/array-element-newline.js +0 -1
  42. package/lib/rules/arrow-body-style.js +0 -1
  43. package/lib/rules/arrow-parens.js +0 -1
  44. package/lib/rules/arrow-spacing.js +0 -1
  45. package/lib/rules/block-scoped-var.js +0 -1
  46. package/lib/rules/block-spacing.js +0 -1
  47. package/lib/rules/brace-style.js +0 -1
  48. package/lib/rules/callback-return.js +1 -1
  49. package/lib/rules/camelcase.js +17 -19
  50. package/lib/rules/capitalized-comments.js +0 -1
  51. package/lib/rules/class-methods-use-this.js +51 -9
  52. package/lib/rules/comma-dangle.js +0 -1
  53. package/lib/rules/comma-spacing.js +0 -1
  54. package/lib/rules/comma-style.js +0 -1
  55. package/lib/rules/complexity.js +47 -56
  56. package/lib/rules/computed-property-spacing.js +0 -1
  57. package/lib/rules/consistent-return.js +0 -1
  58. package/lib/rules/consistent-this.js +1 -2
  59. package/lib/rules/constructor-super.js +0 -1
  60. package/lib/rules/curly.js +0 -1
  61. package/lib/rules/default-case-last.js +0 -1
  62. package/lib/rules/default-case.js +2 -3
  63. package/lib/rules/default-param-last.js +1 -2
  64. package/lib/rules/dot-location.js +0 -1
  65. package/lib/rules/dot-notation.js +0 -1
  66. package/lib/rules/eol-last.js +6 -2
  67. package/lib/rules/eqeqeq.js +1 -2
  68. package/lib/rules/for-direction.js +0 -1
  69. package/lib/rules/func-call-spacing.js +0 -1
  70. package/lib/rules/func-name-matching.js +9 -6
  71. package/lib/rules/func-names.js +0 -1
  72. package/lib/rules/func-style.js +0 -1
  73. package/lib/rules/function-call-argument-newline.js +0 -1
  74. package/lib/rules/function-paren-newline.js +1 -1
  75. package/lib/rules/generator-star-spacing.js +0 -1
  76. package/lib/rules/getter-return.js +0 -1
  77. package/lib/rules/global-require.js +1 -1
  78. package/lib/rules/grouped-accessor-pairs.js +0 -1
  79. package/lib/rules/guard-for-in.js +0 -1
  80. package/lib/rules/handle-callback-err.js +1 -1
  81. package/lib/rules/id-blacklist.js +1 -1
  82. package/lib/rules/id-denylist.js +0 -1
  83. package/lib/rules/id-length.js +0 -1
  84. package/lib/rules/id-match.js +0 -1
  85. package/lib/rules/implicit-arrow-linebreak.js +0 -1
  86. package/lib/rules/indent-legacy.js +1 -1
  87. package/lib/rules/indent.js +7 -10
  88. package/lib/rules/index.js +1 -1
  89. package/lib/rules/init-declarations.js +0 -1
  90. package/lib/rules/jsx-quotes.js +0 -1
  91. package/lib/rules/key-spacing.js +4 -5
  92. package/lib/rules/keyword-spacing.js +19 -3
  93. package/lib/rules/line-comment-position.js +0 -1
  94. package/lib/rules/linebreak-style.js +0 -1
  95. package/lib/rules/lines-around-comment.js +0 -1
  96. package/lib/rules/lines-around-directive.js +1 -2
  97. package/lib/rules/lines-between-class-members.js +50 -3
  98. package/lib/rules/max-classes-per-file.js +31 -8
  99. package/lib/rules/max-depth.js +0 -1
  100. package/lib/rules/max-len.js +1 -2
  101. package/lib/rules/max-lines-per-function.js +1 -2
  102. package/lib/rules/max-lines.js +0 -1
  103. package/lib/rules/max-nested-callbacks.js +0 -1
  104. package/lib/rules/max-params.js +0 -1
  105. package/lib/rules/max-statements-per-line.js +0 -1
  106. package/lib/rules/max-statements.js +0 -1
  107. package/lib/rules/multiline-comment-style.js +0 -1
  108. package/lib/rules/multiline-ternary.js +0 -1
  109. package/lib/rules/new-cap.js +2 -2
  110. package/lib/rules/new-parens.js +0 -1
  111. package/lib/rules/newline-after-var.js +4 -5
  112. package/lib/rules/newline-before-return.js +2 -3
  113. package/lib/rules/newline-per-chained-call.js +1 -2
  114. package/lib/rules/no-alert.js +0 -1
  115. package/lib/rules/no-array-constructor.js +0 -1
  116. package/lib/rules/no-async-promise-executor.js +0 -1
  117. package/lib/rules/no-await-in-loop.js +0 -1
  118. package/lib/rules/no-bitwise.js +5 -6
  119. package/lib/rules/no-buffer-constructor.js +1 -1
  120. package/lib/rules/no-caller.js +0 -1
  121. package/lib/rules/no-case-declarations.js +0 -1
  122. package/lib/rules/no-catch-shadow.js +0 -1
  123. package/lib/rules/no-class-assign.js +0 -1
  124. package/lib/rules/no-compare-neg-zero.js +0 -1
  125. package/lib/rules/no-cond-assign.js +0 -1
  126. package/lib/rules/no-confusing-arrow.js +0 -1
  127. package/lib/rules/no-console.js +0 -1
  128. package/lib/rules/no-const-assign.js +0 -1
  129. package/lib/rules/no-constant-condition.js +0 -1
  130. package/lib/rules/no-constructor-return.js +0 -1
  131. package/lib/rules/no-continue.js +0 -1
  132. package/lib/rules/no-control-regex.js +0 -1
  133. package/lib/rules/no-debugger.js +0 -1
  134. package/lib/rules/no-delete-var.js +0 -1
  135. package/lib/rules/no-div-regex.js +0 -1
  136. package/lib/rules/no-dupe-args.js +0 -1
  137. package/lib/rules/no-dupe-class-members.js +0 -1
  138. package/lib/rules/no-dupe-else-if.js +0 -1
  139. package/lib/rules/no-dupe-keys.js +0 -2
  140. package/lib/rules/no-duplicate-case.js +0 -1
  141. package/lib/rules/no-duplicate-imports.js +0 -1
  142. package/lib/rules/no-else-return.js +0 -1
  143. package/lib/rules/no-empty-character-class.js +0 -1
  144. package/lib/rules/no-empty-function.js +0 -1
  145. package/lib/rules/no-empty-pattern.js +0 -1
  146. package/lib/rules/no-empty.js +0 -1
  147. package/lib/rules/no-eq-null.js +0 -1
  148. package/lib/rules/no-eval.js +0 -1
  149. package/lib/rules/no-ex-assign.js +0 -1
  150. package/lib/rules/no-extend-native.js +0 -1
  151. package/lib/rules/no-extra-bind.js +0 -1
  152. package/lib/rules/no-extra-boolean-cast.js +1 -1
  153. package/lib/rules/no-extra-label.js +0 -1
  154. package/lib/rules/no-extra-parens.js +0 -1
  155. package/lib/rules/no-extra-semi.js +0 -1
  156. package/lib/rules/no-fallthrough.js +0 -1
  157. package/lib/rules/no-floating-decimal.js +0 -1
  158. package/lib/rules/no-func-assign.js +0 -1
  159. package/lib/rules/no-global-assign.js +0 -1
  160. package/lib/rules/no-implicit-coercion.js +0 -1
  161. package/lib/rules/no-implicit-globals.js +0 -1
  162. package/lib/rules/no-implied-eval.js +0 -1
  163. package/lib/rules/no-import-assign.js +0 -1
  164. package/lib/rules/no-inline-comments.js +0 -1
  165. package/lib/rules/no-inner-declarations.js +0 -1
  166. package/lib/rules/no-invalid-regexp.js +0 -1
  167. package/lib/rules/no-invalid-this.js +0 -1
  168. package/lib/rules/no-irregular-whitespace.js +0 -1
  169. package/lib/rules/no-iterator.js +0 -1
  170. package/lib/rules/no-label-var.js +0 -1
  171. package/lib/rules/no-labels.js +0 -1
  172. package/lib/rules/no-lone-blocks.js +0 -1
  173. package/lib/rules/no-lonely-if.js +0 -1
  174. package/lib/rules/no-loop-func.js +1 -2
  175. package/lib/rules/no-loss-of-precision.js +0 -1
  176. package/lib/rules/no-magic-numbers.js +0 -1
  177. package/lib/rules/no-misleading-character-class.js +0 -1
  178. package/lib/rules/no-mixed-operators.js +1 -2
  179. package/lib/rules/no-mixed-requires.js +1 -1
  180. package/lib/rules/no-mixed-spaces-and-tabs.js +0 -1
  181. package/lib/rules/no-multi-assign.js +0 -1
  182. package/lib/rules/no-multi-spaces.js +0 -1
  183. package/lib/rules/no-multi-str.js +0 -1
  184. package/lib/rules/no-multiple-empty-lines.js +0 -1
  185. package/lib/rules/no-native-reassign.js +0 -1
  186. package/lib/rules/no-negated-condition.js +0 -1
  187. package/lib/rules/no-negated-in-lhs.js +0 -1
  188. package/lib/rules/no-nested-ternary.js +0 -1
  189. package/lib/rules/no-new-func.js +34 -7
  190. package/lib/rules/no-new-object.js +0 -1
  191. package/lib/rules/no-new-require.js +1 -1
  192. package/lib/rules/no-new-symbol.js +0 -1
  193. package/lib/rules/no-new-wrappers.js +0 -1
  194. package/lib/rules/no-new.js +0 -1
  195. package/lib/rules/no-nonoctal-decimal-escape.js +0 -1
  196. package/lib/rules/no-obj-calls.js +0 -1
  197. package/lib/rules/no-octal-escape.js +0 -1
  198. package/lib/rules/no-octal.js +0 -1
  199. package/lib/rules/no-param-reassign.js +0 -1
  200. package/lib/rules/no-path-concat.js +1 -1
  201. package/lib/rules/no-plusplus.js +0 -1
  202. package/lib/rules/no-process-env.js +1 -1
  203. package/lib/rules/no-process-exit.js +1 -1
  204. package/lib/rules/no-promise-executor-return.js +0 -1
  205. package/lib/rules/no-proto.js +0 -1
  206. package/lib/rules/no-prototype-builtins.js +0 -1
  207. package/lib/rules/no-redeclare.js +0 -1
  208. package/lib/rules/no-regex-spaces.js +0 -1
  209. package/lib/rules/no-restricted-exports.js +0 -1
  210. package/lib/rules/no-restricted-globals.js +1 -2
  211. package/lib/rules/no-restricted-imports.js +5 -6
  212. package/lib/rules/no-restricted-modules.js +3 -3
  213. package/lib/rules/no-restricted-properties.js +2 -3
  214. package/lib/rules/no-restricted-syntax.js +1 -2
  215. package/lib/rules/no-return-assign.js +0 -1
  216. package/lib/rules/no-return-await.js +0 -1
  217. package/lib/rules/no-script-url.js +1 -3
  218. package/lib/rules/no-self-assign.js +0 -1
  219. package/lib/rules/no-self-compare.js +0 -1
  220. package/lib/rules/no-sequences.js +0 -1
  221. package/lib/rules/no-setter-return.js +0 -1
  222. package/lib/rules/no-shadow-restricted-names.js +0 -1
  223. package/lib/rules/no-shadow.js +1 -2
  224. package/lib/rules/no-spaced-func.js +0 -1
  225. package/lib/rules/no-sparse-arrays.js +0 -1
  226. package/lib/rules/no-sync.js +1 -3
  227. package/lib/rules/no-tabs.js +0 -1
  228. package/lib/rules/no-template-curly-in-string.js +0 -1
  229. package/lib/rules/no-ternary.js +0 -1
  230. package/lib/rules/no-this-before-super.js +0 -1
  231. package/lib/rules/no-throw-literal.js +0 -1
  232. package/lib/rules/no-trailing-spaces.js +0 -1
  233. package/lib/rules/no-undef-init.js +9 -61
  234. package/lib/rules/no-undef.js +0 -1
  235. package/lib/rules/no-undefined.js +0 -1
  236. package/lib/rules/no-underscore-dangle.js +0 -1
  237. package/lib/rules/no-unexpected-multiline.js +0 -1
  238. package/lib/rules/no-unmodified-loop-condition.js +0 -1
  239. package/lib/rules/no-unneeded-ternary.js +0 -1
  240. package/lib/rules/no-unreachable-loop.js +0 -1
  241. package/lib/rules/no-unreachable.js +26 -25
  242. package/lib/rules/no-unsafe-finally.js +0 -1
  243. package/lib/rules/no-unsafe-negation.js +0 -1
  244. package/lib/rules/no-unsafe-optional-chaining.js +0 -1
  245. package/lib/rules/no-unused-expressions.js +4 -5
  246. package/lib/rules/no-unused-labels.js +0 -1
  247. package/lib/rules/no-unused-vars.js +26 -28
  248. package/lib/rules/no-use-before-define.js +0 -1
  249. package/lib/rules/no-useless-backreference.js +0 -1
  250. package/lib/rules/no-useless-call.js +0 -1
  251. package/lib/rules/no-useless-catch.js +0 -1
  252. package/lib/rules/no-useless-computed-key.js +1 -1
  253. package/lib/rules/no-useless-concat.js +0 -1
  254. package/lib/rules/no-useless-constructor.js +0 -1
  255. package/lib/rules/no-useless-escape.js +9 -9
  256. package/lib/rules/no-useless-rename.js +0 -1
  257. package/lib/rules/no-useless-return.js +0 -1
  258. package/lib/rules/no-var.js +0 -1
  259. package/lib/rules/no-void.js +0 -1
  260. package/lib/rules/no-warning-comments.js +0 -1
  261. package/lib/rules/no-whitespace-before-property.js +0 -1
  262. package/lib/rules/no-with.js +0 -1
  263. package/lib/rules/nonblock-statement-body-position.js +0 -1
  264. package/lib/rules/object-curly-newline.js +0 -1
  265. package/lib/rules/object-curly-spacing.js +0 -1
  266. package/lib/rules/object-property-newline.js +0 -1
  267. package/lib/rules/object-shorthand.js +3 -8
  268. package/lib/rules/one-var-declaration-per-line.js +0 -1
  269. package/lib/rules/one-var.js +1 -2
  270. package/lib/rules/operator-assignment.js +6 -7
  271. package/lib/rules/operator-linebreak.js +0 -1
  272. package/lib/rules/padded-blocks.js +1 -1
  273. package/lib/rules/padding-line-between-statements.js +0 -1
  274. package/lib/rules/prefer-arrow-callback.js +1 -1
  275. package/lib/rules/prefer-const.js +0 -1
  276. package/lib/rules/prefer-destructuring.js +1 -2
  277. package/lib/rules/prefer-exponentiation-operator.js +0 -1
  278. package/lib/rules/prefer-named-capture-group.js +0 -1
  279. package/lib/rules/prefer-numeric-literals.js +0 -1
  280. package/lib/rules/prefer-object-spread.js +0 -1
  281. package/lib/rules/prefer-promise-reject-errors.js +0 -1
  282. package/lib/rules/prefer-reflect.js +0 -1
  283. package/lib/rules/prefer-regex-literals.js +0 -1
  284. package/lib/rules/prefer-rest-params.js +0 -1
  285. package/lib/rules/prefer-spread.js +0 -1
  286. package/lib/rules/prefer-template.js +0 -1
  287. package/lib/rules/quote-props.js +8 -9
  288. package/lib/rules/quotes.js +0 -1
  289. package/lib/rules/radix.js +0 -1
  290. package/lib/rules/require-atomic-updates.js +24 -9
  291. package/lib/rules/require-await.js +0 -1
  292. package/lib/rules/require-jsdoc.js +1 -1
  293. package/lib/rules/require-unicode-regexp.js +0 -1
  294. package/lib/rules/require-yield.js +0 -1
  295. package/lib/rules/rest-spread-spacing.js +0 -1
  296. package/lib/rules/semi-spacing.js +0 -1
  297. package/lib/rules/semi-style.js +0 -1
  298. package/lib/rules/semi.js +66 -6
  299. package/lib/rules/sort-imports.js +0 -1
  300. package/lib/rules/sort-keys.js +0 -1
  301. package/lib/rules/sort-vars.js +0 -1
  302. package/lib/rules/space-before-blocks.js +14 -3
  303. package/lib/rules/space-before-function-paren.js +0 -1
  304. package/lib/rules/space-in-parens.js +0 -1
  305. package/lib/rules/space-infix-ops.js +0 -1
  306. package/lib/rules/space-unary-ops.js +0 -1
  307. package/lib/rules/spaced-comment.js +0 -1
  308. package/lib/rules/strict.js +0 -1
  309. package/lib/rules/switch-colon-spacing.js +1 -14
  310. package/lib/rules/symbol-description.js +0 -1
  311. package/lib/rules/template-curly-spacing.js +0 -1
  312. package/lib/rules/template-tag-spacing.js +0 -1
  313. package/lib/rules/unicode-bom.js +0 -1
  314. package/lib/rules/use-isnan.js +0 -1
  315. package/lib/rules/utils/ast-utils.js +29 -7
  316. package/lib/rules/utils/lazy-loading-rule-map.js +3 -3
  317. package/lib/rules/valid-jsdoc.js +1 -1
  318. package/lib/rules/valid-typeof.js +0 -1
  319. package/lib/rules/vars-on-top.js +1 -2
  320. package/lib/rules/wrap-iife.js +0 -1
  321. package/lib/rules/wrap-regex.js +0 -1
  322. package/lib/rules/yield-star-spacing.js +0 -1
  323. package/lib/rules/yoda.js +0 -1
  324. package/lib/shared/ajv.js +1 -1
  325. package/lib/shared/config-validator.js +10 -5
  326. package/lib/shared/logging.js +1 -1
  327. package/lib/shared/relative-module-resolver.js +1 -0
  328. package/lib/shared/runtime-info.js +3 -0
  329. package/lib/shared/traverser.js +2 -2
  330. package/lib/shared/types.js +2 -2
  331. package/lib/source-code/source-code.js +11 -5
  332. package/lib/source-code/token-store/cursor.js +1 -1
  333. package/package.json +5 -5
@@ -28,7 +28,6 @@ module.exports = {
28
28
 
29
29
  docs: {
30
30
  description: "require or disallow method and property shorthand syntax for object literals",
31
- category: "ECMAScript 6",
32
31
  recommended: false,
33
32
  url: "https://eslint.org/docs/rules/object-shorthand"
34
33
  },
@@ -149,7 +148,6 @@ module.exports = {
149
148
  * @param {ASTNode} property Property AST node
150
149
  * @returns {boolean} True if the property can have a shorthand form
151
150
  * @private
152
- *
153
151
  */
154
152
  function canHaveShorthand(property) {
155
153
  return (property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty");
@@ -157,7 +155,7 @@ module.exports = {
157
155
 
158
156
  /**
159
157
  * Checks whether a node is a string literal.
160
- * @param {ASTNode} node Any AST node.
158
+ * @param {ASTNode} node Any AST node.
161
159
  * @returns {boolean} `true` if it is a string literal.
162
160
  */
163
161
  function isStringLiteral(node) {
@@ -169,7 +167,6 @@ module.exports = {
169
167
  * @param {ASTNode} property Property AST node
170
168
  * @returns {boolean} True if the property is considered shorthand, false if not.
171
169
  * @private
172
- *
173
170
  */
174
171
  function isShorthand(property) {
175
172
 
@@ -182,7 +179,6 @@ module.exports = {
182
179
  * @param {ASTNode} property Property AST node
183
180
  * @returns {boolean} True if the key and value are named equally, false if not.
184
181
  * @private
185
- *
186
182
  */
187
183
  function isRedundant(property) {
188
184
  const value = property.value;
@@ -199,10 +195,9 @@ module.exports = {
199
195
 
200
196
  /**
201
197
  * Ensures that an object's properties are consistently shorthand, or not shorthand at all.
202
- * @param {ASTNode} node Property AST node
203
- * @param {boolean} checkRedundancy Whether to check longform redundancy
198
+ * @param {ASTNode} node Property AST node
199
+ * @param {boolean} checkRedundancy Whether to check longform redundancy
204
200
  * @returns {void}
205
- *
206
201
  */
207
202
  function checkConsistency(node, checkRedundancy) {
208
203
 
@@ -14,7 +14,6 @@ module.exports = {
14
14
 
15
15
  docs: {
16
16
  description: "require or disallow newlines around variable declarations",
17
- category: "Stylistic Issues",
18
17
  recommended: false,
19
18
  url: "https://eslint.org/docs/rules/one-var-declaration-per-line"
20
19
  },
@@ -34,7 +34,6 @@ module.exports = {
34
34
 
35
35
  docs: {
36
36
  description: "enforce variables to be declared either together or separately in functions",
37
- category: "Stylistic Issues",
38
37
  recommended: false,
39
38
  url: "https://eslint.org/docs/rules/one-var"
40
39
  },
@@ -209,7 +208,7 @@ module.exports = {
209
208
 
210
209
  /**
211
210
  * Determines the current scope (function or block)
212
- * @param {string} statementType node.kind, one of: "var", "let", or "const"
211
+ * @param {string} statementType node.kind, one of: "var", "let", or "const"
213
212
  * @returns {Object} The scope associated with statementType
214
213
  */
215
214
  function getCurrentScope(statementType) {
@@ -17,8 +17,8 @@ const astUtils = require("./utils/ast-utils");
17
17
  /**
18
18
  * Checks whether an operator is commutative and has an operator assignment
19
19
  * shorthand form.
20
- * @param {string} operator Operator to check.
21
- * @returns {boolean} True if the operator is commutative and has a
20
+ * @param {string} operator Operator to check.
21
+ * @returns {boolean} True if the operator is commutative and has a
22
22
  * shorthand form.
23
23
  */
24
24
  function isCommutativeOperatorWithShorthand(operator) {
@@ -28,8 +28,8 @@ function isCommutativeOperatorWithShorthand(operator) {
28
28
  /**
29
29
  * Checks whether an operator is not commutative and has an operator assignment
30
30
  * shorthand form.
31
- * @param {string} operator Operator to check.
32
- * @returns {boolean} True if the operator is not commutative and has
31
+ * @param {string} operator Operator to check.
32
+ * @returns {boolean} True if the operator is not commutative and has
33
33
  * a shorthand form.
34
34
  */
35
35
  function isNonCommutativeOperatorWithShorthand(operator) {
@@ -63,7 +63,6 @@ module.exports = {
63
63
 
64
64
  docs: {
65
65
  description: "require or disallow assignment operator shorthand where possible",
66
- category: "Stylistic Issues",
67
66
  recommended: false,
68
67
  url: "https://eslint.org/docs/rules/operator-assignment"
69
68
  },
@@ -96,7 +95,7 @@ module.exports = {
96
95
 
97
96
  /**
98
97
  * Ensures that an assignment uses the shorthand form where possible.
99
- * @param {ASTNode} node An AssignmentExpression node.
98
+ * @param {ASTNode} node An AssignmentExpression node.
100
99
  * @returns {void}
101
100
  */
102
101
  function verify(node) {
@@ -149,7 +148,7 @@ module.exports = {
149
148
 
150
149
  /**
151
150
  * Warns if an assignment expression uses operator assignment shorthand.
152
- * @param {ASTNode} node An AssignmentExpression node.
151
+ * @param {ASTNode} node An AssignmentExpression node.
153
152
  * @returns {void}
154
153
  */
155
154
  function prohibit(node) {
@@ -21,7 +21,6 @@ module.exports = {
21
21
 
22
22
  docs: {
23
23
  description: "enforce consistent linebreak style for operators",
24
- category: "Stylistic Issues",
25
24
  recommended: false,
26
25
  url: "https://eslint.org/docs/rules/operator-linebreak"
27
26
  },
@@ -21,7 +21,6 @@ module.exports = {
21
21
 
22
22
  docs: {
23
23
  description: "require or disallow padding within blocks",
24
- category: "Stylistic Issues",
25
24
  recommended: false,
26
25
  url: "https://eslint.org/docs/rules/padded-blocks"
27
26
  },
@@ -167,6 +166,7 @@ module.exports = {
167
166
  /**
168
167
  * Checks if a node should be padded, according to the rule config.
169
168
  * @param {ASTNode} node The AST node to check.
169
+ * @throws {Error} (Unreachable)
170
170
  * @returns {boolean} True if the node should be padded, false otherwise.
171
171
  */
172
172
  function requirePaddingFor(node) {
@@ -431,7 +431,6 @@ module.exports = {
431
431
 
432
432
  docs: {
433
433
  description: "require or disallow padding lines between statements",
434
- category: "Stylistic Issues",
435
434
  recommended: false,
436
435
  url: "https://eslint.org/docs/rules/padding-line-between-statements"
437
436
  },
@@ -60,6 +60,7 @@ function getVariableOfArguments(scope) {
60
60
  /**
61
61
  * Checks whether or not a given node is a callback.
62
62
  * @param {ASTNode} node A node to check.
63
+ * @throws {Error} (Unreachable.)
63
64
  * @returns {Object}
64
65
  * {boolean} retv.isCallback - `true` if the node is a callback.
65
66
  * {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`.
@@ -150,7 +151,6 @@ module.exports = {
150
151
 
151
152
  docs: {
152
153
  description: "require using arrow functions for callbacks",
153
- category: "ECMAScript 6",
154
154
  recommended: false,
155
155
  url: "https://eslint.org/docs/rules/prefer-arrow-callback"
156
156
  },
@@ -332,7 +332,6 @@ module.exports = {
332
332
 
333
333
  docs: {
334
334
  description: "require `const` declarations for variables that are never reassigned after declared",
335
- category: "ECMAScript 6",
336
335
  recommended: false,
337
336
  url: "https://eslint.org/docs/rules/prefer-const"
338
337
  },
@@ -26,7 +26,6 @@ module.exports = {
26
26
 
27
27
  docs: {
28
28
  description: "require destructuring from arrays and/or objects",
29
- category: "ECMAScript 6",
30
29
  recommended: false,
31
30
  url: "https://eslint.org/docs/rules/prefer-destructuring"
32
31
  },
@@ -119,8 +118,8 @@ module.exports = {
119
118
  // Helpers
120
119
  //--------------------------------------------------------------------------
121
120
 
122
- // eslint-disable-next-line jsdoc/require-description
123
121
  /**
122
+ * Checks if destructuring type should be checked.
124
123
  * @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
125
124
  * @param {string} destructuringType "array" or "object"
126
125
  * @returns {boolean} `true` if the destructuring type should be checked for the given node
@@ -90,7 +90,6 @@ module.exports = {
90
90
 
91
91
  docs: {
92
92
  description: "disallow the use of `Math.pow` in favor of the `**` operator",
93
- category: "Stylistic Issues",
94
93
  recommended: false,
95
94
  url: "https://eslint.org/docs/rules/prefer-exponentiation-operator"
96
95
  },
@@ -33,7 +33,6 @@ module.exports = {
33
33
 
34
34
  docs: {
35
35
  description: "enforce using named capture group in regular expression",
36
- category: "Best Practices",
37
36
  recommended: false,
38
37
  url: "https://eslint.org/docs/rules/prefer-named-capture-group"
39
38
  },
@@ -45,7 +45,6 @@ module.exports = {
45
45
 
46
46
  docs: {
47
47
  description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
48
- category: "ECMAScript 6",
49
48
  recommended: false,
50
49
  url: "https://eslint.org/docs/rules/prefer-numeric-literals"
51
50
  },
@@ -247,7 +247,6 @@ module.exports = {
247
247
  docs: {
248
248
  description:
249
249
  "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.",
250
- category: "Stylistic Issues",
251
250
  recommended: false,
252
251
  url: "https://eslint.org/docs/rules/prefer-object-spread"
253
252
  },
@@ -16,7 +16,6 @@ module.exports = {
16
16
 
17
17
  docs: {
18
18
  description: "require using Error objects as Promise rejection reasons",
19
- category: "Best Practices",
20
19
  recommended: false,
21
20
  url: "https://eslint.org/docs/rules/prefer-promise-reject-errors"
22
21
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require `Reflect` methods where applicable",
18
- category: "ECMAScript 6",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/prefer-reflect"
21
20
  },
@@ -54,7 +54,6 @@ module.exports = {
54
54
 
55
55
  docs: {
56
56
  description: "disallow use of the `RegExp` constructor in favor of regular expression literals",
57
- category: "Best Practices",
58
57
  recommended: false,
59
58
  url: "https://eslint.org/docs/rules/prefer-regex-literals"
60
59
  },
@@ -65,7 +65,6 @@ module.exports = {
65
65
 
66
66
  docs: {
67
67
  description: "require rest parameters instead of `arguments`",
68
- category: "ECMAScript 6",
69
68
  recommended: false,
70
69
  url: "https://eslint.org/docs/rules/prefer-rest-params"
71
70
  },
@@ -49,7 +49,6 @@ module.exports = {
49
49
 
50
50
  docs: {
51
51
  description: "require spread operators instead of `.apply()`",
52
- category: "ECMAScript 6",
53
52
  recommended: false,
54
53
  url: "https://eslint.org/docs/rules/prefer-spread"
55
54
  },
@@ -128,7 +128,6 @@ module.exports = {
128
128
 
129
129
  docs: {
130
130
  description: "require template literals instead of string concatenation",
131
- category: "ECMAScript 6",
132
131
  recommended: false,
133
132
  url: "https://eslint.org/docs/rules/prefer-template"
134
133
  },
@@ -22,7 +22,6 @@ module.exports = {
22
22
 
23
23
  docs: {
24
24
  description: "require quotes around object literal property names",
25
- category: "Stylistic Issues",
26
25
  recommended: false,
27
26
  url: "https://eslint.org/docs/rules/quote-props"
28
27
  },
@@ -91,7 +90,7 @@ module.exports = {
91
90
 
92
91
  /**
93
92
  * Checks whether a certain string constitutes an ES3 token
94
- * @param {string} tokenStr The string to be checked.
93
+ * @param {string} tokenStr The string to be checked.
95
94
  * @returns {boolean} `true` if it is an ES3 token.
96
95
  */
97
96
  function isKeyword(tokenStr) {
@@ -100,9 +99,9 @@ module.exports = {
100
99
 
101
100
  /**
102
101
  * Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary)
103
- * @param {string} rawKey The raw key value from the source
104
- * @param {espreeTokens} tokens The espree-tokenized node key
105
- * @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked
102
+ * @param {string} rawKey The raw key value from the source
103
+ * @param {espreeTokens} tokens The espree-tokenized node key
104
+ * @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked
106
105
  * @returns {boolean} Whether or not a key has redundant quotes.
107
106
  * @private
108
107
  */
@@ -139,7 +138,7 @@ module.exports = {
139
138
 
140
139
  /**
141
140
  * Ensures that a property's key is quoted only when necessary
142
- * @param {ASTNode} node Property AST node
141
+ * @param {ASTNode} node Property AST node
143
142
  * @returns {void}
144
143
  */
145
144
  function checkUnnecessaryQuotes(node) {
@@ -195,7 +194,7 @@ module.exports = {
195
194
 
196
195
  /**
197
196
  * Ensures that a property's key is quoted
198
- * @param {ASTNode} node Property AST node
197
+ * @param {ASTNode} node Property AST node
199
198
  * @returns {void}
200
199
  */
201
200
  function checkOmittedQuotes(node) {
@@ -213,8 +212,8 @@ module.exports = {
213
212
 
214
213
  /**
215
214
  * Ensures that an object's keys are consistently quoted, optionally checks for redundancy of quotes
216
- * @param {ASTNode} node Property AST node
217
- * @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy
215
+ * @param {ASTNode} node Property AST node
216
+ * @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy
218
217
  * @returns {void}
219
218
  */
220
219
  function checkConsistency(node, checkQuotesRedundancy) {
@@ -80,7 +80,6 @@ module.exports = {
80
80
 
81
81
  docs: {
82
82
  description: "enforce the consistent use of either backticks, double, or single quotes",
83
- category: "Stylistic Issues",
84
83
  recommended: false,
85
84
  url: "https://eslint.org/docs/rules/quotes"
86
85
  },
@@ -80,7 +80,6 @@ module.exports = {
80
80
 
81
81
  docs: {
82
82
  description: "enforce the consistent use of the radix argument when using `parseInt()`",
83
- category: "Best Practices",
84
83
  recommended: false,
85
84
  url: "https://eslint.org/docs/rules/radix"
86
85
  },
@@ -79,6 +79,9 @@ function isLocalVariableWithoutEscape(variable, isMemberAccess) {
79
79
  reference.from.variableScope === functionScope);
80
80
  }
81
81
 
82
+ /**
83
+ * Represents segment information.
84
+ */
82
85
  class SegmentInfo {
83
86
  constructor() {
84
87
  this.info = new WeakMap();
@@ -168,7 +171,6 @@ module.exports = {
168
171
 
169
172
  docs: {
170
173
  description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
171
- category: "Possible Errors",
172
174
  recommended: false,
173
175
  url: "https://eslint.org/docs/rules/require-atomic-updates"
174
176
  },
@@ -177,7 +179,8 @@ module.exports = {
177
179
  schema: [],
178
180
 
179
181
  messages: {
180
- nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`."
182
+ nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`.",
183
+ nonAtomicObjectUpdate: "Possible race condition: `{{value}}` might be assigned based on an outdated state of `{{object}}`."
181
184
  }
182
185
  },
183
186
 
@@ -273,13 +276,25 @@ module.exports = {
273
276
  const variable = reference.resolved;
274
277
 
275
278
  if (segmentInfo.isOutdated(codePath.currentSegments, variable)) {
276
- context.report({
277
- node: node.parent,
278
- messageId: "nonAtomicUpdate",
279
- data: {
280
- value: sourceCode.getText(node.parent.left)
281
- }
282
- });
279
+ if (node.parent.left === reference.identifier) {
280
+ context.report({
281
+ node: node.parent,
282
+ messageId: "nonAtomicUpdate",
283
+ data: {
284
+ value: variable.name
285
+ }
286
+ });
287
+ } else {
288
+ context.report({
289
+ node: node.parent,
290
+ messageId: "nonAtomicObjectUpdate",
291
+ data: {
292
+ value: sourceCode.getText(node.parent.left),
293
+ object: variable.name
294
+ }
295
+ });
296
+ }
297
+
283
298
  }
284
299
  }
285
300
  }
@@ -34,7 +34,6 @@ module.exports = {
34
34
 
35
35
  docs: {
36
36
  description: "disallow async functions which have no `await` expression",
37
- category: "Best Practices",
38
37
  recommended: false,
39
38
  url: "https://eslint.org/docs/rules/require-await"
40
39
  },
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to check for jsdoc presence.
3
3
  * @author Gyandeep Singh
4
+ * @deprecated in ESLint v5.10.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -10,7 +11,6 @@ module.exports = {
10
11
 
11
12
  docs: {
12
13
  description: "require JSDoc comments",
13
- category: "Stylistic Issues",
14
14
  recommended: false,
15
15
  url: "https://eslint.org/docs/rules/require-jsdoc"
16
16
  },
@@ -26,7 +26,6 @@ module.exports = {
26
26
 
27
27
  docs: {
28
28
  description: "enforce the use of `u` flag on RegExp",
29
- category: "Best Practices",
30
29
  recommended: false,
31
30
  url: "https://eslint.org/docs/rules/require-unicode-regexp"
32
31
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require generator functions to contain `yield`",
18
- category: "ECMAScript 6",
19
18
  recommended: true,
20
19
  url: "https://eslint.org/docs/rules/require-yield"
21
20
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "enforce spacing between rest and spread operators and their expressions",
18
- category: "ECMAScript 6",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/rest-spread-spacing"
21
20
  },
@@ -17,7 +17,6 @@ module.exports = {
17
17
 
18
18
  docs: {
19
19
  description: "enforce consistent spacing before and after semicolons",
20
- category: "Stylistic Issues",
21
20
  recommended: false,
22
21
  url: "https://eslint.org/docs/rules/semi-spacing"
23
22
  },
@@ -67,7 +67,6 @@ module.exports = {
67
67
 
68
68
  docs: {
69
69
  description: "enforce location of semicolons",
70
- category: "Stylistic Issues",
71
70
  recommended: false,
72
71
  url: "https://eslint.org/docs/rules/semi-style"
73
72
  },
package/lib/rules/semi.js CHANGED
@@ -21,7 +21,6 @@ module.exports = {
21
21
 
22
22
  docs: {
23
23
  description: "require or disallow semicolons instead of ASI",
24
- category: "Stylistic Issues",
25
24
  recommended: false,
26
25
  url: "https://eslint.org/docs/rules/semi"
27
26
  },
@@ -78,6 +77,8 @@ module.exports = {
78
77
  create(context) {
79
78
 
80
79
  const OPT_OUT_PATTERN = /^[-[(/+`]/u; // One of [(/+-`
80
+ const unsafeClassFieldNames = new Set(["get", "set", "static"]);
81
+ const unsafeClassFieldFollowers = new Set(["*", "in", "instanceof"]);
81
82
  const options = context.options[1];
82
83
  const never = context.options[0] === "never";
83
84
  const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
@@ -166,6 +167,55 @@ module.exports = {
166
167
  );
167
168
  }
168
169
 
170
+ /**
171
+ * Checks if a given PropertyDefinition node followed by a semicolon
172
+ * can safely remove that semicolon. It is not to safe to remove if
173
+ * the class field name is "get", "set", or "static", or if
174
+ * followed by a generator method.
175
+ * @param {ASTNode} node The node to check.
176
+ * @returns {boolean} `true` if the node cannot have the semicolon
177
+ * removed.
178
+ */
179
+ function maybeClassFieldAsiHazard(node) {
180
+
181
+ if (node.type !== "PropertyDefinition") {
182
+ return false;
183
+ }
184
+
185
+ /*
186
+ * Computed property names and non-identifiers are always safe
187
+ * as they can be distinguished from keywords easily.
188
+ */
189
+ const needsNameCheck = !node.computed && node.key.type === "Identifier";
190
+
191
+ /*
192
+ * Certain names are problematic unless they also have a
193
+ * a way to distinguish between keywords and property
194
+ * names.
195
+ */
196
+ if (needsNameCheck && unsafeClassFieldNames.has(node.key.name)) {
197
+
198
+ /*
199
+ * Special case: If the field name is `static`,
200
+ * it is only valid if the field is marked as static,
201
+ * so "static static" is okay but "static" is not.
202
+ */
203
+ const isStaticStatic = node.static && node.key.name === "static";
204
+
205
+ /*
206
+ * For other unsafe names, we only care if there is no
207
+ * initializer. No initializer = hazard.
208
+ */
209
+ if (!isStaticStatic && !node.value) {
210
+ return true;
211
+ }
212
+ }
213
+
214
+ const followingToken = sourceCode.getTokenAfter(node);
215
+
216
+ return unsafeClassFieldFollowers.has(followingToken.value);
217
+ }
218
+
169
219
  /**
170
220
  * Check whether a given node is on the same line with the next token.
171
221
  * @param {Node} node A statement node to check.
@@ -204,9 +254,6 @@ module.exports = {
204
254
  if (isEndOfArrowBlock(sourceCode.getLastToken(node, 1))) {
205
255
  return false;
206
256
  }
207
- if (t === "PropertyDefinition") {
208
- return Boolean(t.value);
209
- }
210
257
 
211
258
  return true;
212
259
  }
@@ -236,10 +283,19 @@ module.exports = {
236
283
  if (isRedundantSemi(sourceCode.getLastToken(node))) {
237
284
  return true; // `;;` or `;}`
238
285
  }
286
+ if (maybeClassFieldAsiHazard(node)) {
287
+ return false;
288
+ }
239
289
  if (isOnSameLineWithNextToken(node)) {
240
290
  return false; // One liner.
241
291
  }
242
- if (beforeStatementContinuationChars === "never" && !maybeAsiHazardAfter(node)) {
292
+
293
+ // continuation characters should not apply to class fields
294
+ if (
295
+ node.type !== "PropertyDefinition" &&
296
+ beforeStatementContinuationChars === "never" &&
297
+ !maybeAsiHazardAfter(node)
298
+ ) {
243
299
  return true; // ASI works. This statement doesn't connect to the next.
244
300
  }
245
301
  if (!maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
@@ -279,7 +335,11 @@ module.exports = {
279
335
  if (never) {
280
336
  if (isSemi && canRemoveSemicolon(node)) {
281
337
  report(node, true);
282
- } else if (!isSemi && beforeStatementContinuationChars === "always" && maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
338
+ } else if (
339
+ !isSemi && beforeStatementContinuationChars === "always" &&
340
+ node.type !== "PropertyDefinition" &&
341
+ maybeAsiHazardBefore(sourceCode.getTokenAfter(node))
342
+ ) {
283
343
  report(node);
284
344
  }
285
345
  } else {
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "enforce sorted import declarations within modules",
18
- category: "ECMAScript 6",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/sort-imports"
21
20
  },
@@ -81,7 +81,6 @@ module.exports = {
81
81
 
82
82
  docs: {
83
83
  description: "require object keys to be sorted",
84
- category: "Stylistic Issues",
85
84
  recommended: false,
86
85
  url: "https://eslint.org/docs/rules/sort-keys"
87
86
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require variables within the same declaration block to be sorted",
18
- category: "Stylistic Issues",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/sort-vars"
21
20
  },