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
@@ -40,7 +40,6 @@ module.exports = {
40
40
 
41
41
  docs: {
42
42
  description: "enforce consistent spacing before blocks",
43
- category: "Stylistic Issues",
44
43
  recommended: false,
45
44
  url: "https://eslint.org/docs/rules/space-before-blocks"
46
45
  },
@@ -108,13 +107,25 @@ module.exports = {
108
107
  * Checks whether the spacing before the given block is already controlled by another rule:
109
108
  * - `arrow-spacing` checks spaces after `=>`.
110
109
  * - `keyword-spacing` checks spaces after keywords in certain contexts.
110
+ * - `switch-colon-spacing` checks spaces after `:` of switch cases.
111
111
  * @param {Token} precedingToken first token before the block.
112
112
  * @param {ASTNode|Token} node `BlockStatement` node or `{` token of a `SwitchStatement` node.
113
113
  * @returns {boolean} `true` if requiring or disallowing spaces before the given block could produce conflicts with other rules.
114
114
  */
115
115
  function isConflicted(precedingToken, node) {
116
- return astUtils.isArrowToken(precedingToken) ||
117
- astUtils.isKeywordToken(precedingToken) && !isFunctionBody(node);
116
+ return (
117
+ astUtils.isArrowToken(precedingToken) ||
118
+ (
119
+ astUtils.isKeywordToken(precedingToken) &&
120
+ !isFunctionBody(node)
121
+ ) ||
122
+ (
123
+ astUtils.isColonToken(precedingToken) &&
124
+ node.parent &&
125
+ node.parent.type === "SwitchCase" &&
126
+ precedingToken === astUtils.getSwitchCaseColonToken(node.parent, sourceCode)
127
+ )
128
+ );
118
129
  }
119
130
 
120
131
  /**
@@ -20,7 +20,6 @@ module.exports = {
20
20
 
21
21
  docs: {
22
22
  description: "enforce consistent spacing before `function` definition opening parenthesis",
23
- category: "Stylistic Issues",
24
23
  recommended: false,
25
24
  url: "https://eslint.org/docs/rules/space-before-function-paren"
26
25
  },
@@ -16,7 +16,6 @@ module.exports = {
16
16
 
17
17
  docs: {
18
18
  description: "enforce consistent spacing inside parentheses",
19
- category: "Stylistic Issues",
20
19
  recommended: false,
21
20
  url: "https://eslint.org/docs/rules/space-in-parens"
22
21
  },
@@ -16,7 +16,6 @@ module.exports = {
16
16
 
17
17
  docs: {
18
18
  description: "require spacing around infix operators",
19
- category: "Stylistic Issues",
20
19
  recommended: false,
21
20
  url: "https://eslint.org/docs/rules/space-infix-ops"
22
21
  },
@@ -20,7 +20,6 @@ module.exports = {
20
20
 
21
21
  docs: {
22
22
  description: "enforce consistent spacing before or after unary operators",
23
- category: "Stylistic Issues",
24
23
  recommended: false,
25
24
  url: "https://eslint.org/docs/rules/space-unary-ops"
26
25
  },
@@ -152,7 +152,6 @@ module.exports = {
152
152
 
153
153
  docs: {
154
154
  description: "enforce consistent spacing after the `//` or `/*` in a comment",
155
- category: "Stylistic Issues",
156
155
  recommended: false,
157
156
  url: "https://eslint.org/docs/rules/spaced-comment"
158
157
  },
@@ -69,7 +69,6 @@ module.exports = {
69
69
 
70
70
  docs: {
71
71
  description: "require or disallow strict mode directives",
72
- category: "Strict Mode",
73
72
  recommended: false,
74
73
  url: "https://eslint.org/docs/rules/strict"
75
74
  },
@@ -21,7 +21,6 @@ module.exports = {
21
21
 
22
22
  docs: {
23
23
  description: "enforce spacing around colons of switch statements",
24
- category: "Stylistic Issues",
25
24
  recommended: false,
26
25
  url: "https://eslint.org/docs/rules/switch-colon-spacing"
27
26
  },
@@ -51,18 +50,6 @@ module.exports = {
51
50
  const beforeSpacing = options.before === true; // false by default
52
51
  const afterSpacing = options.after !== false; // true by default
53
52
 
54
- /**
55
- * Get the colon token of the given SwitchCase node.
56
- * @param {ASTNode} node The SwitchCase node to get.
57
- * @returns {Token} The colon token of the node.
58
- */
59
- function getColonToken(node) {
60
- if (node.test) {
61
- return sourceCode.getTokenAfter(node.test, astUtils.isColonToken);
62
- }
63
- return sourceCode.getFirstToken(node, 1);
64
- }
65
-
66
53
  /**
67
54
  * Check whether the spacing between the given 2 tokens is valid or not.
68
55
  * @param {Token} left The left token to check.
@@ -115,7 +102,7 @@ module.exports = {
115
102
 
116
103
  return {
117
104
  SwitchCase(node) {
118
- const colonToken = getColonToken(node);
105
+ const colonToken = astUtils.getSwitchCaseColonToken(node, sourceCode);
119
106
  const beforeToken = sourceCode.getTokenBefore(colonToken);
120
107
  const afterToken = sourceCode.getTokenAfter(colonToken);
121
108
 
@@ -22,7 +22,6 @@ module.exports = {
22
22
 
23
23
  docs: {
24
24
  description: "require symbol descriptions",
25
- category: "ECMAScript 6",
26
25
  recommended: false,
27
26
  url: "https://eslint.org/docs/rules/symbol-description"
28
27
  },
@@ -21,7 +21,6 @@ module.exports = {
21
21
 
22
22
  docs: {
23
23
  description: "require or disallow spacing around embedded expressions of template strings",
24
- category: "ECMAScript 6",
25
24
  recommended: false,
26
25
  url: "https://eslint.org/docs/rules/template-curly-spacing"
27
26
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require or disallow spacing between template tags and their literals",
18
- category: "Stylistic Issues",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/template-tag-spacing"
21
20
  },
@@ -14,7 +14,6 @@ module.exports = {
14
14
 
15
15
  docs: {
16
16
  description: "require or disallow Unicode byte order mark (BOM)",
17
- category: "Stylistic Issues",
18
17
  recommended: false,
19
18
  url: "https://eslint.org/docs/rules/unicode-bom"
20
19
  },
@@ -37,7 +37,6 @@ module.exports = {
37
37
 
38
38
  docs: {
39
39
  description: "require calls to `isNaN()` when checking for `NaN`",
40
- category: "Possible Errors",
41
40
  recommended: true,
42
41
  url: "https://eslint.org/docs/rules/use-isnan"
43
42
  },
@@ -756,6 +756,19 @@ function isLogicalAssignmentOperator(operator) {
756
756
  return LOGICAL_ASSIGNMENT_OPERATORS.has(operator);
757
757
  }
758
758
 
759
+ /**
760
+ * Get the colon token of the given SwitchCase node.
761
+ * @param {ASTNode} node The SwitchCase node to get.
762
+ * @param {SourceCode} sourceCode The source code object to get tokens.
763
+ * @returns {Token} The colon token of the node.
764
+ */
765
+ function getSwitchCaseColonToken(node, sourceCode) {
766
+ if (node.test) {
767
+ return sourceCode.getTokenAfter(node.test, isColonToken);
768
+ }
769
+ return sourceCode.getFirstToken(node, 1);
770
+ }
771
+
759
772
  //------------------------------------------------------------------------------
760
773
  // Public Interface
761
774
  //------------------------------------------------------------------------------
@@ -858,8 +871,8 @@ module.exports = {
858
871
 
859
872
  /**
860
873
  * Validate that a string passed in is surrounded by the specified character
861
- * @param {string} val The text to check.
862
- * @param {string} character The character to see if it's surrounded by.
874
+ * @param {string} val The text to check.
875
+ * @param {string} character The character to see if it's surrounded by.
863
876
  * @returns {boolean} True if the text is surrounded by the character, false if not.
864
877
  * @private
865
878
  */
@@ -875,7 +888,14 @@ module.exports = {
875
888
  isDirectiveComment(node) {
876
889
  const comment = node.value.trim();
877
890
 
878
- return /^(?:eslint[- ]|(?:globals?|exported) )/u.test(comment);
891
+ return (
892
+ node.type === "Line" && comment.indexOf("eslint-") === 0 ||
893
+ node.type === "Block" && (
894
+ comment.indexOf("global ") === 0 ||
895
+ comment.indexOf("eslint ") === 0 ||
896
+ comment.indexOf("eslint-") === 0
897
+ )
898
+ );
879
899
  },
880
900
 
881
901
  /**
@@ -1288,7 +1308,8 @@ module.exports = {
1288
1308
  * 5e1_000 // false
1289
1309
  * 5n // false
1290
1310
  * 1_000n // false
1291
- * '5' // false
1311
+ * "5" // false
1312
+ *
1292
1313
  */
1293
1314
  isDecimalInteger(node) {
1294
1315
  return node.type === "Literal" && typeof node.value === "number" &&
@@ -1632,9 +1653,9 @@ module.exports = {
1632
1653
  return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]);
1633
1654
  },
1634
1655
 
1635
- /*
1656
+ /**
1636
1657
  * Determine if a node has a possibility to be an Error object
1637
- * @param {ASTNode} node ASTNode to check
1658
+ * @param {ASTNode} node ASTNode to check
1638
1659
  * @returns {boolean} True if there is a chance it contains an Error obj
1639
1660
  */
1640
1661
  couldBeError(node) {
@@ -1864,5 +1885,6 @@ module.exports = {
1864
1885
  isSpecificMemberAccess,
1865
1886
  equalLiteralValue,
1866
1887
  isSameReference,
1867
- isLogicalAssignmentOperator
1888
+ isLogicalAssignmentOperator,
1889
+ getSwitchCaseColonToken
1868
1890
  };
@@ -14,10 +14,10 @@ const debug = require("debug")("eslint:rules");
14
14
  * const rules = new LazyLoadingRuleMap([
15
15
  * ["eqeqeq", () => require("eqeqeq")],
16
16
  * ["semi", () => require("semi")],
17
- * ["no-unused-vars", () => require("no-unused-vars")],
18
- * ])
17
+ * ["no-unused-vars", () => require("no-unused-vars")]
18
+ * ]);
19
19
  *
20
- * rules.get("semi") // call `() => require("semi")` here.
20
+ * rules.get("semi"); // call `() => require("semi")` here.
21
21
  *
22
22
  * @extends {Map<string, () => Rule>}
23
23
  */
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Validates JSDoc comments are syntactically correct
3
3
  * @author Nicholas C. Zakas
4
+ * @deprecated in ESLint v5.10.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -20,7 +21,6 @@ module.exports = {
20
21
 
21
22
  docs: {
22
23
  description: "enforce valid JSDoc comments",
23
- category: "Possible Errors",
24
24
  recommended: false,
25
25
  url: "https://eslint.org/docs/rules/valid-jsdoc"
26
26
  },
@@ -14,7 +14,6 @@ module.exports = {
14
14
 
15
15
  docs: {
16
16
  description: "enforce comparing `typeof` expressions against valid strings",
17
- category: "Possible Errors",
18
17
  recommended: true,
19
18
  url: "https://eslint.org/docs/rules/valid-typeof"
20
19
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require `var` declarations be placed at the top of their containing scope",
18
- category: "Best Practices",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/vars-on-top"
21
20
  },
@@ -32,8 +31,8 @@ module.exports = {
32
31
  // Helpers
33
32
  //--------------------------------------------------------------------------
34
33
 
35
- // eslint-disable-next-line jsdoc/require-description
36
34
  /**
35
+ * Has AST suggesting a directive.
37
36
  * @param {ASTNode} node any node
38
37
  * @returns {boolean} whether the given node structurally represents a directive
39
38
  */
@@ -43,7 +43,6 @@ module.exports = {
43
43
 
44
44
  docs: {
45
45
  description: "require parentheses around immediate `function` invocations",
46
- category: "Best Practices",
47
46
  recommended: false,
48
47
  url: "https://eslint.org/docs/rules/wrap-iife"
49
48
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require parenthesis around regex literals",
18
- category: "Stylistic Issues",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/wrap-regex"
21
20
  },
@@ -15,7 +15,6 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "require or disallow spacing around the `*` in `yield*` expressions",
18
- category: "ECMAScript 6",
19
18
  recommended: false,
20
19
  url: "https://eslint.org/docs/rules/yield-star-spacing"
21
20
  },
package/lib/rules/yoda.js CHANGED
@@ -121,7 +121,6 @@ module.exports = {
121
121
 
122
122
  docs: {
123
123
  description: 'require or disallow "Yoda" conditions',
124
- category: "Best Practices",
125
124
  recommended: false,
126
125
  url: "https://eslint.org/docs/rules/yoda"
127
126
  },
package/lib/shared/ajv.js CHANGED
@@ -27,7 +27,7 @@ module.exports = (additionalOptions = {}) => {
27
27
  });
28
28
 
29
29
  ajv.addMetaSchema(metaSchema);
30
- // eslint-disable-next-line no-underscore-dangle
30
+ // eslint-disable-next-line no-underscore-dangle -- Ajv's API
31
31
  ajv._opts.defaultMeta = metaSchema.id;
32
32
 
33
33
  return ajv;
@@ -84,6 +84,7 @@ function getRuleOptionsSchema(rule) {
84
84
  /**
85
85
  * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
86
86
  * @param {options} options The given options for the rule.
87
+ * @throws {Error} Wrong severity value.
87
88
  * @returns {number|string} The rule's severity value
88
89
  */
89
90
  function validateRuleSeverity(options) {
@@ -102,6 +103,7 @@ function validateRuleSeverity(options) {
102
103
  * Validates the non-severity options passed to a rule, based on its schema.
103
104
  * @param {{create: Function}} rule The rule to validate
104
105
  * @param {Array} localOptions The options for the rule, excluding severity
106
+ * @throws {Error} Any rule validation errors.
105
107
  * @returns {void}
106
108
  */
107
109
  function validateRuleSchema(rule, localOptions) {
@@ -132,6 +134,7 @@ function validateRuleSchema(rule, localOptions) {
132
134
  * @param {Array|number} options The given options for the rule.
133
135
  * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
134
136
  * no source is prepended to the message.
137
+ * @throws {Error} Upon any bad rule configuration.
135
138
  * @returns {void}
136
139
  */
137
140
  function validateRuleOptions(rule, ruleId, options, source = null) {
@@ -156,7 +159,7 @@ function validateRuleOptions(rule, ruleId, options, source = null) {
156
159
  * Validates an environment object
157
160
  * @param {Object} environment The environment config object to validate.
158
161
  * @param {string} source The name of the configuration source to report in any errors.
159
- * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
162
+ * @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded environments.
160
163
  * @returns {void}
161
164
  */
162
165
  function validateEnvironment(
@@ -185,7 +188,7 @@ function validateEnvironment(
185
188
  * Validates a rules config object
186
189
  * @param {Object} rulesConfig The rules config object to validate.
187
190
  * @param {string} source The name of the configuration source to report in any errors.
188
- * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
191
+ * @param {(ruleId:string) => Object} getAdditionalRule A map from strings to loaded rules
189
192
  * @returns {void}
190
193
  */
191
194
  function validateRules(
@@ -229,7 +232,8 @@ function validateGlobals(globalsConfig, source = null) {
229
232
  * Validate `processor` configuration.
230
233
  * @param {string|undefined} processorName The processor name.
231
234
  * @param {string} source The name of config file.
232
- * @param {function(id:string): Processor} getProcessor The getter of defined processors.
235
+ * @param {(id:string) => Processor} getProcessor The getter of defined processors.
236
+ * @throws {Error} For invalid processor configuration.
233
237
  * @returns {void}
234
238
  */
235
239
  function validateProcessor(processorName, source, getProcessor) {
@@ -268,6 +272,7 @@ function formatErrors(errors) {
268
272
  * Validates the top level properties of the config object.
269
273
  * @param {Object} config The config object to validate.
270
274
  * @param {string} source The name of the configuration source to report in any errors.
275
+ * @throws {Error} For any config invalid per the schema.
271
276
  * @returns {void}
272
277
  */
273
278
  function validateConfigSchema(config, source = null) {
@@ -286,8 +291,8 @@ function validateConfigSchema(config, source = null) {
286
291
  * Validates an entire config object.
287
292
  * @param {Object} config The config object to validate.
288
293
  * @param {string} source The name of the configuration source to report in any errors.
289
- * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
290
- * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
294
+ * @param {(ruleId:string) => Object} [getAdditionalRule] A map from strings to loaded rules.
295
+ * @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded envs.
291
296
  * @returns {void}
292
297
  */
293
298
  function validate(config, source, getAdditionalRule, getAdditionalEnv) {
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /* eslint no-console: "off" */
8
+ /* eslint no-console: "off" -- Logging util */
9
9
 
10
10
  /* istanbul ignore next */
11
11
  module.exports = {
@@ -26,6 +26,7 @@ module.exports = {
26
26
  * @param {string} moduleName The name of a Node module, or a path to a Node module.
27
27
  * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
28
28
  * a file rather than a directory, but the file need not actually exist.
29
+ * @throws {Error} Any error from `module.createRequire` or its `resolve`.
29
30
  * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
30
31
  */
31
32
  resolve(moduleName, relativeToPath) {
@@ -40,6 +40,7 @@ function environment() {
40
40
  * Synchronously executes a shell command and formats the result.
41
41
  * @param {string} cmd The command to execute.
42
42
  * @param {Array} args The arguments to be executed with the command.
43
+ * @throws {Error} As may be collected by `cross-spawn.sync`.
43
44
  * @returns {string} The version returned by the command.
44
45
  */
45
46
  function execCommand(cmd, args) {
@@ -73,6 +74,7 @@ function environment() {
73
74
  /**
74
75
  * Gets bin version.
75
76
  * @param {string} bin The bin to check.
77
+ * @throws {Error} As may be collected by `cross-spawn.sync`.
76
78
  * @returns {string} The normalized version returned by the command.
77
79
  */
78
80
  function getBinVersion(bin) {
@@ -90,6 +92,7 @@ function environment() {
90
92
  * Gets installed npm package version.
91
93
  * @param {string} pkg The package to check.
92
94
  * @param {boolean} global Whether to check globally or not.
95
+ * @throws {Error} As may be collected by `cross-spawn.sync`.
93
96
  * @returns {string} The normalized version returned by the command.
94
97
  */
95
98
  function getNpmPackageVersion(pkg, { global = false } = {}) {
@@ -65,16 +65,16 @@ class Traverser {
65
65
  this._leave = null;
66
66
  }
67
67
 
68
- // eslint-disable-next-line jsdoc/require-description
69
68
  /**
69
+ * Gives current node.
70
70
  * @returns {ASTNode} The current node.
71
71
  */
72
72
  current() {
73
73
  return this._current;
74
74
  }
75
75
 
76
- // eslint-disable-next-line jsdoc/require-description
77
76
  /**
77
+ * Gives a a copy of the ancestor nodes.
78
78
  * @returns {ASTNode[]} The ancestor nodes.
79
79
  */
80
80
  parents() {
@@ -83,12 +83,12 @@ module.exports = {};
83
83
 
84
84
  /**
85
85
  * @typedef {Object} LintMessage
86
- * @property {number} column The 1-based column number.
86
+ * @property {number|undefined} column The 1-based column number.
87
87
  * @property {number} [endColumn] The 1-based column number of the end location.
88
88
  * @property {number} [endLine] The 1-based line number of the end location.
89
89
  * @property {boolean} fatal If `true` then this is a fatal error.
90
90
  * @property {{range:[number,number], text:string}} [fix] Information for autofix.
91
- * @property {number} line The 1-based line number.
91
+ * @property {number|undefined} line The 1-based line number.
92
92
  * @property {string} message The error message.
93
93
  * @property {string|null} ruleId The ID of the rule which makes this message.
94
94
  * @property {0|1|2} severity The severity of this message.
@@ -143,10 +143,12 @@ function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) {
143
143
  // Public Interface
144
144
  //------------------------------------------------------------------------------
145
145
 
146
+ /**
147
+ * Represents parsed source code.
148
+ */
146
149
  class SourceCode extends TokenStore {
147
150
 
148
151
  /**
149
- * Represents parsed source code.
150
152
  * @param {string|Object} textOrConfig The source code text or config object.
151
153
  * @param {string} textOrConfig.text The source code text.
152
154
  * @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
@@ -175,20 +177,20 @@ class SourceCode extends TokenStore {
175
177
 
176
178
  /**
177
179
  * The flag to indicate that the source code has Unicode BOM.
178
- * @type boolean
180
+ * @type {boolean}
179
181
  */
180
182
  this.hasBOM = (text.charCodeAt(0) === 0xFEFF);
181
183
 
182
184
  /**
183
185
  * The original text source code.
184
186
  * BOM was stripped from this text.
185
- * @type string
187
+ * @type {string}
186
188
  */
187
189
  this.text = (this.hasBOM ? text.slice(1) : text);
188
190
 
189
191
  /**
190
192
  * The parsed AST for the source code.
191
- * @type ASTNode
193
+ * @type {ASTNode}
192
194
  */
193
195
  this.ast = ast;
194
196
 
@@ -223,7 +225,7 @@ class SourceCode extends TokenStore {
223
225
  /**
224
226
  * The source code split into lines according to ECMA-262 specification.
225
227
  * This is done to avoid each rule needing to do so separately.
226
- * @type string[]
228
+ * @type {string[]}
227
229
  */
228
230
  this.lines = [];
229
231
  this.lineStartIndices = [0];
@@ -506,6 +508,7 @@ class SourceCode extends TokenStore {
506
508
  /**
507
509
  * Converts a source text index into a (line, column) pair.
508
510
  * @param {number} index The index of a character in a file
511
+ * @throws {TypeError} If non-numeric index or index out of range.
509
512
  * @returns {Object} A {line, column} location object with a 0-indexed column
510
513
  * @public
511
514
  */
@@ -545,6 +548,9 @@ class SourceCode extends TokenStore {
545
548
  * @param {Object} loc A line/column location
546
549
  * @param {number} loc.line The line number of the location (1-indexed)
547
550
  * @param {number} loc.column The column number of the location (0-indexed)
551
+ * @throws {TypeError|RangeError} If `loc` is not an object with a numeric
552
+ * `line` and `column`, if the `line` is less than or equal to zero or
553
+ * the line or column is out of the expected range.
548
554
  * @returns {number} The range index of the location in the file.
549
555
  * @public
550
556
  */
@@ -70,7 +70,7 @@ module.exports = class Cursor {
70
70
  * @abstract
71
71
  */
72
72
  /* istanbul ignore next */
73
- moveNext() { // eslint-disable-line class-methods-use-this
73
+ moveNext() { // eslint-disable-line class-methods-use-this -- Unused
74
74
  throw new Error("Not implemented.");
75
75
  }
76
76
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.0.0-beta.0",
3
+ "version": "8.0.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -23,7 +23,6 @@
23
23
  "generate-betarelease": "node Makefile.js generatePrerelease -- beta",
24
24
  "generate-rcrelease": "node Makefile.js generatePrerelease -- rc",
25
25
  "publish-release": "node Makefile.js publishRelease",
26
- "docs": "node Makefile.js docs",
27
26
  "gensite": "node Makefile.js gensite",
28
27
  "webpack": "node Makefile.js webpack",
29
28
  "perf": "node Makefile.js perf"
@@ -48,7 +47,7 @@
48
47
  "homepage": "https://eslint.org",
49
48
  "bugs": "https://github.com/eslint/eslint/issues/",
50
49
  "dependencies": {
51
- "@eslint/eslintrc": "^1.0.0",
50
+ "@eslint/eslintrc": "^1.0.2",
52
51
  "@humanwhocodes/config-array": "^0.6.0",
53
52
  "ajv": "^6.10.0",
54
53
  "chalk": "^4.0.0",
@@ -60,7 +59,7 @@
60
59
  "eslint-scope": "^6.0.0",
61
60
  "eslint-utils": "^3.0.0",
62
61
  "eslint-visitor-keys": "^3.0.0",
63
- "espree": "^8.0.0",
62
+ "espree": "^9.0.0",
64
63
  "esquery": "^1.4.0",
65
64
  "esutils": "^2.0.2",
66
65
  "fast-deep-equal": "^3.1.3",
@@ -99,9 +98,10 @@
99
98
  "ejs": "^3.0.2",
100
99
  "eslint": "file:.",
101
100
  "eslint-config-eslint": "file:packages/eslint-config-eslint",
101
+ "eslint-plugin-eslint-comments": "^3.2.0",
102
102
  "eslint-plugin-eslint-plugin": "^3.5.3",
103
103
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
104
- "eslint-plugin-jsdoc": "^33.3.0",
104
+ "eslint-plugin-jsdoc": "^36.0.6",
105
105
  "eslint-plugin-node": "^11.1.0",
106
106
  "eslint-release": "^3.1.2",
107
107
  "eslump": "^3.0.0",