eslint 8.39.0 → 8.41.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 (308) hide show
  1. package/README.md +4 -3
  2. package/lib/cli-engine/cli-engine.js +3 -1
  3. package/lib/cli.js +2 -28
  4. package/lib/config/default-config.js +1 -1
  5. package/lib/config/flat-config-schema.js +57 -35
  6. package/lib/eslint/eslint-helpers.js +8 -7
  7. package/lib/eslint/flat-eslint.js +101 -46
  8. package/lib/linter/apply-disable-directives.js +11 -1
  9. package/lib/linter/config-comment-parser.js +9 -2
  10. package/lib/linter/linter.js +20 -11
  11. package/lib/linter/report-translator.js +4 -19
  12. package/lib/rules/accessor-pairs.js +2 -2
  13. package/lib/rules/array-bracket-newline.js +2 -2
  14. package/lib/rules/array-bracket-spacing.js +2 -2
  15. package/lib/rules/array-callback-return.js +2 -2
  16. package/lib/rules/array-element-newline.js +2 -2
  17. package/lib/rules/arrow-body-style.js +2 -2
  18. package/lib/rules/arrow-parens.js +2 -2
  19. package/lib/rules/arrow-spacing.js +2 -2
  20. package/lib/rules/block-scoped-var.js +2 -2
  21. package/lib/rules/block-spacing.js +2 -2
  22. package/lib/rules/brace-style.js +2 -2
  23. package/lib/rules/callback-return.js +2 -2
  24. package/lib/rules/camelcase.js +2 -2
  25. package/lib/rules/capitalized-comments.js +2 -2
  26. package/lib/rules/class-methods-use-this.js +2 -2
  27. package/lib/rules/comma-dangle.js +2 -2
  28. package/lib/rules/comma-spacing.js +2 -2
  29. package/lib/rules/comma-style.js +2 -2
  30. package/lib/rules/complexity.js +1 -1
  31. package/lib/rules/computed-property-spacing.js +2 -2
  32. package/lib/rules/consistent-return.js +3 -3
  33. package/lib/rules/consistent-this.js +2 -2
  34. package/lib/rules/constructor-super.js +1 -1
  35. package/lib/rules/curly.js +2 -2
  36. package/lib/rules/default-case-last.js +1 -1
  37. package/lib/rules/default-case.js +2 -2
  38. package/lib/rules/default-param-last.js +1 -1
  39. package/lib/rules/dot-location.js +2 -2
  40. package/lib/rules/dot-notation.js +2 -2
  41. package/lib/rules/eol-last.js +2 -2
  42. package/lib/rules/eqeqeq.js +2 -2
  43. package/lib/rules/for-direction.js +1 -1
  44. package/lib/rules/func-call-spacing.js +2 -2
  45. package/lib/rules/func-name-matching.js +1 -1
  46. package/lib/rules/func-names.js +2 -2
  47. package/lib/rules/func-style.js +1 -1
  48. package/lib/rules/function-call-argument-newline.js +2 -2
  49. package/lib/rules/function-paren-newline.js +2 -2
  50. package/lib/rules/generator-star-spacing.js +2 -2
  51. package/lib/rules/getter-return.js +2 -2
  52. package/lib/rules/global-require.js +2 -2
  53. package/lib/rules/grouped-accessor-pairs.js +2 -2
  54. package/lib/rules/guard-for-in.js +1 -1
  55. package/lib/rules/handle-callback-err.js +2 -2
  56. package/lib/rules/id-blacklist.js +2 -2
  57. package/lib/rules/id-denylist.js +2 -2
  58. package/lib/rules/id-length.js +3 -36
  59. package/lib/rules/id-match.js +2 -2
  60. package/lib/rules/implicit-arrow-linebreak.js +2 -2
  61. package/lib/rules/indent-legacy.js +2 -2
  62. package/lib/rules/indent.js +40 -56
  63. package/lib/rules/init-declarations.js +1 -1
  64. package/lib/rules/jsx-quotes.js +1 -1
  65. package/lib/rules/key-spacing.js +4 -10
  66. package/lib/rules/keyword-spacing.js +2 -2
  67. package/lib/rules/line-comment-position.js +2 -2
  68. package/lib/rules/linebreak-style.js +2 -2
  69. package/lib/rules/lines-around-comment.js +2 -2
  70. package/lib/rules/lines-around-directive.js +2 -2
  71. package/lib/rules/lines-between-class-members.js +2 -2
  72. package/lib/rules/logical-assignment-operators.js +2 -2
  73. package/lib/rules/max-classes-per-file.js +1 -1
  74. package/lib/rules/max-depth.js +1 -1
  75. package/lib/rules/max-len.js +2 -2
  76. package/lib/rules/max-lines-per-function.js +2 -2
  77. package/lib/rules/max-lines.js +2 -2
  78. package/lib/rules/max-nested-callbacks.js +1 -1
  79. package/lib/rules/max-params.js +2 -2
  80. package/lib/rules/max-statements-per-line.js +2 -2
  81. package/lib/rules/max-statements.js +1 -1
  82. package/lib/rules/multiline-comment-style.js +2 -2
  83. package/lib/rules/multiline-ternary.js +2 -2
  84. package/lib/rules/new-cap.js +2 -2
  85. package/lib/rules/new-parens.js +2 -2
  86. package/lib/rules/newline-after-var.js +2 -2
  87. package/lib/rules/newline-before-return.js +2 -2
  88. package/lib/rules/newline-per-chained-call.js +2 -2
  89. package/lib/rules/no-alert.js +2 -2
  90. package/lib/rules/no-array-constructor.js +1 -1
  91. package/lib/rules/no-async-promise-executor.js +2 -2
  92. package/lib/rules/no-await-in-loop.js +1 -1
  93. package/lib/rules/no-bitwise.js +1 -1
  94. package/lib/rules/no-buffer-constructor.js +1 -1
  95. package/lib/rules/no-caller.js +1 -1
  96. package/lib/rules/no-case-declarations.js +1 -1
  97. package/lib/rules/no-catch-shadow.js +2 -2
  98. package/lib/rules/no-class-assign.js +2 -2
  99. package/lib/rules/no-compare-neg-zero.js +1 -1
  100. package/lib/rules/no-cond-assign.js +2 -2
  101. package/lib/rules/no-confusing-arrow.js +2 -2
  102. package/lib/rules/no-console.js +2 -2
  103. package/lib/rules/no-const-assign.js +2 -2
  104. package/lib/rules/no-constant-binary-expression.js +2 -2
  105. package/lib/rules/no-constant-condition.js +2 -2
  106. package/lib/rules/no-constructor-return.js +1 -1
  107. package/lib/rules/no-continue.js +1 -1
  108. package/lib/rules/no-control-regex.js +1 -1
  109. package/lib/rules/no-debugger.js +1 -1
  110. package/lib/rules/no-delete-var.js +1 -1
  111. package/lib/rules/no-div-regex.js +2 -2
  112. package/lib/rules/no-dupe-args.js +2 -2
  113. package/lib/rules/no-dupe-class-members.js +1 -1
  114. package/lib/rules/no-dupe-else-if.js +2 -2
  115. package/lib/rules/no-dupe-keys.js +1 -1
  116. package/lib/rules/no-duplicate-case.js +2 -2
  117. package/lib/rules/no-duplicate-imports.js +1 -1
  118. package/lib/rules/no-else-return.js +2 -2
  119. package/lib/rules/no-empty-character-class.js +1 -1
  120. package/lib/rules/no-empty-function.js +2 -2
  121. package/lib/rules/no-empty-pattern.js +1 -1
  122. package/lib/rules/no-empty-static-block.js +2 -2
  123. package/lib/rules/no-empty.js +2 -2
  124. package/lib/rules/no-eq-null.js +1 -1
  125. package/lib/rules/no-eval.js +2 -2
  126. package/lib/rules/no-ex-assign.js +2 -2
  127. package/lib/rules/no-extend-native.js +2 -2
  128. package/lib/rules/no-extra-bind.js +2 -2
  129. package/lib/rules/no-extra-boolean-cast.js +2 -2
  130. package/lib/rules/no-extra-label.js +2 -2
  131. package/lib/rules/no-extra-parens.js +2 -2
  132. package/lib/rules/no-extra-semi.js +3 -3
  133. package/lib/rules/no-fallthrough.js +3 -3
  134. package/lib/rules/no-floating-decimal.js +2 -2
  135. package/lib/rules/no-func-assign.js +2 -2
  136. package/lib/rules/no-global-assign.js +2 -2
  137. package/lib/rules/no-implicit-coercion.js +2 -2
  138. package/lib/rules/no-implicit-globals.js +2 -2
  139. package/lib/rules/no-implied-eval.js +2 -2
  140. package/lib/rules/no-import-assign.js +2 -2
  141. package/lib/rules/no-inline-comments.js +2 -2
  142. package/lib/rules/no-inner-declarations.js +1 -1
  143. package/lib/rules/no-invalid-regexp.js +1 -1
  144. package/lib/rules/no-invalid-this.js +2 -2
  145. package/lib/rules/no-irregular-whitespace.js +2 -2
  146. package/lib/rules/no-iterator.js +1 -1
  147. package/lib/rules/no-label-var.js +2 -2
  148. package/lib/rules/no-labels.js +1 -1
  149. package/lib/rules/no-lone-blocks.js +2 -2
  150. package/lib/rules/no-lonely-if.js +2 -2
  151. package/lib/rules/no-loop-func.js +2 -2
  152. package/lib/rules/no-loss-of-precision.js +1 -1
  153. package/lib/rules/no-magic-numbers.js +1 -1
  154. package/lib/rules/no-misleading-character-class.js +2 -2
  155. package/lib/rules/no-mixed-operators.js +2 -2
  156. package/lib/rules/no-mixed-requires.js +1 -1
  157. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
  158. package/lib/rules/no-multi-assign.js +1 -1
  159. package/lib/rules/no-multi-spaces.js +2 -2
  160. package/lib/rules/no-multi-str.js +1 -1
  161. package/lib/rules/no-multiple-empty-lines.js +2 -2
  162. package/lib/rules/no-native-reassign.js +2 -2
  163. package/lib/rules/no-negated-condition.js +1 -1
  164. package/lib/rules/no-negated-in-lhs.js +1 -1
  165. package/lib/rules/no-nested-ternary.js +1 -1
  166. package/lib/rules/no-new-func.js +2 -2
  167. package/lib/rules/no-new-native-nonconstructor.js +2 -2
  168. package/lib/rules/no-new-object.js +2 -2
  169. package/lib/rules/no-new-require.js +1 -1
  170. package/lib/rules/no-new-symbol.js +2 -2
  171. package/lib/rules/no-new-wrappers.js +1 -1
  172. package/lib/rules/no-new.js +1 -1
  173. package/lib/rules/no-nonoctal-decimal-escape.js +2 -2
  174. package/lib/rules/no-obj-calls.js +2 -2
  175. package/lib/rules/no-octal-escape.js +1 -1
  176. package/lib/rules/no-octal.js +1 -1
  177. package/lib/rules/no-param-reassign.js +2 -2
  178. package/lib/rules/no-path-concat.js +1 -1
  179. package/lib/rules/no-plusplus.js +1 -1
  180. package/lib/rules/no-process-env.js +1 -1
  181. package/lib/rules/no-process-exit.js +1 -1
  182. package/lib/rules/no-promise-executor-return.js +2 -2
  183. package/lib/rules/no-proto.js +1 -1
  184. package/lib/rules/no-prototype-builtins.js +1 -1
  185. package/lib/rules/no-redeclare.js +2 -2
  186. package/lib/rules/no-regex-spaces.js +2 -2
  187. package/lib/rules/no-restricted-exports.js +2 -2
  188. package/lib/rules/no-restricted-globals.js +2 -2
  189. package/lib/rules/no-restricted-imports.js +2 -2
  190. package/lib/rules/no-restricted-modules.js +1 -1
  191. package/lib/rules/no-restricted-properties.js +1 -1
  192. package/lib/rules/no-restricted-syntax.js +1 -1
  193. package/lib/rules/no-return-assign.js +2 -2
  194. package/lib/rules/no-return-await.js +3 -3
  195. package/lib/rules/no-script-url.js +1 -1
  196. package/lib/rules/no-self-assign.js +2 -2
  197. package/lib/rules/no-self-compare.js +2 -2
  198. package/lib/rules/no-sequences.js +2 -2
  199. package/lib/rules/no-setter-return.js +2 -2
  200. package/lib/rules/no-shadow-restricted-names.js +2 -2
  201. package/lib/rules/no-shadow.js +2 -2
  202. package/lib/rules/no-spaced-func.js +2 -2
  203. package/lib/rules/no-sparse-arrays.js +1 -1
  204. package/lib/rules/no-sync.js +1 -1
  205. package/lib/rules/no-tabs.js +2 -2
  206. package/lib/rules/no-template-curly-in-string.js +1 -1
  207. package/lib/rules/no-ternary.js +1 -1
  208. package/lib/rules/no-this-before-super.js +1 -1
  209. package/lib/rules/no-throw-literal.js +1 -1
  210. package/lib/rules/no-trailing-spaces.js +2 -2
  211. package/lib/rules/no-undef-init.js +2 -2
  212. package/lib/rules/no-undef.js +2 -2
  213. package/lib/rules/no-undefined.js +2 -2
  214. package/lib/rules/no-underscore-dangle.js +2 -2
  215. package/lib/rules/no-unexpected-multiline.js +2 -2
  216. package/lib/rules/no-unmodified-loop-condition.js +2 -2
  217. package/lib/rules/no-unneeded-ternary.js +2 -2
  218. package/lib/rules/no-unreachable-loop.js +1 -1
  219. package/lib/rules/no-unreachable.js +2 -2
  220. package/lib/rules/no-unsafe-finally.js +1 -1
  221. package/lib/rules/no-unsafe-negation.js +2 -2
  222. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  223. package/lib/rules/no-unused-expressions.js +1 -1
  224. package/lib/rules/no-unused-labels.js +2 -2
  225. package/lib/rules/no-unused-private-class-members.js +1 -1
  226. package/lib/rules/no-unused-vars.js +2 -2
  227. package/lib/rules/no-use-before-define.js +2 -2
  228. package/lib/rules/no-useless-backreference.js +2 -2
  229. package/lib/rules/no-useless-call.js +2 -2
  230. package/lib/rules/no-useless-catch.js +1 -1
  231. package/lib/rules/no-useless-computed-key.js +2 -2
  232. package/lib/rules/no-useless-concat.js +2 -2
  233. package/lib/rules/no-useless-constructor.js +1 -1
  234. package/lib/rules/no-useless-escape.js +2 -2
  235. package/lib/rules/no-useless-rename.js +2 -2
  236. package/lib/rules/no-useless-return.js +2 -2
  237. package/lib/rules/no-var.js +2 -2
  238. package/lib/rules/no-void.js +1 -1
  239. package/lib/rules/no-warning-comments.js +2 -2
  240. package/lib/rules/no-whitespace-before-property.js +2 -2
  241. package/lib/rules/no-with.js +1 -1
  242. package/lib/rules/nonblock-statement-body-position.js +2 -2
  243. package/lib/rules/object-curly-newline.js +2 -2
  244. package/lib/rules/object-curly-spacing.js +4 -4
  245. package/lib/rules/object-property-newline.js +2 -2
  246. package/lib/rules/object-shorthand.js +2 -2
  247. package/lib/rules/one-var-declaration-per-line.js +1 -1
  248. package/lib/rules/one-var.js +2 -2
  249. package/lib/rules/operator-assignment.js +2 -2
  250. package/lib/rules/operator-linebreak.js +2 -2
  251. package/lib/rules/padded-blocks.js +2 -2
  252. package/lib/rules/padding-line-between-statements.js +4 -4
  253. package/lib/rules/prefer-arrow-callback.js +2 -2
  254. package/lib/rules/prefer-const.js +2 -2
  255. package/lib/rules/prefer-destructuring.js +2 -2
  256. package/lib/rules/prefer-exponentiation-operator.js +2 -2
  257. package/lib/rules/prefer-named-capture-group.js +2 -2
  258. package/lib/rules/prefer-numeric-literals.js +2 -2
  259. package/lib/rules/prefer-object-has-own.js +2 -2
  260. package/lib/rules/prefer-object-spread.js +2 -2
  261. package/lib/rules/prefer-promise-reject-errors.js +2 -2
  262. package/lib/rules/prefer-reflect.js +1 -1
  263. package/lib/rules/prefer-regex-literals.js +2 -2
  264. package/lib/rules/prefer-rest-params.js +2 -2
  265. package/lib/rules/prefer-spread.js +2 -2
  266. package/lib/rules/prefer-template.js +2 -2
  267. package/lib/rules/quote-props.js +2 -2
  268. package/lib/rules/quotes.js +2 -2
  269. package/lib/rules/radix.js +2 -2
  270. package/lib/rules/require-atomic-updates.js +2 -2
  271. package/lib/rules/require-await.js +2 -2
  272. package/lib/rules/require-jsdoc.js +2 -2
  273. package/lib/rules/require-unicode-regexp.js +2 -2
  274. package/lib/rules/require-yield.js +1 -1
  275. package/lib/rules/rest-spread-spacing.js +2 -2
  276. package/lib/rules/semi-spacing.js +2 -2
  277. package/lib/rules/semi-style.js +2 -2
  278. package/lib/rules/semi.js +30 -5
  279. package/lib/rules/sort-imports.js +2 -2
  280. package/lib/rules/sort-keys.js +2 -2
  281. package/lib/rules/sort-vars.js +2 -2
  282. package/lib/rules/space-before-blocks.js +2 -2
  283. package/lib/rules/space-before-function-paren.js +2 -2
  284. package/lib/rules/space-in-parens.js +2 -2
  285. package/lib/rules/space-infix-ops.js +2 -2
  286. package/lib/rules/space-unary-ops.js +2 -2
  287. package/lib/rules/spaced-comment.js +2 -2
  288. package/lib/rules/strict.js +1 -1
  289. package/lib/rules/switch-colon-spacing.js +2 -2
  290. package/lib/rules/symbol-description.js +2 -2
  291. package/lib/rules/template-curly-spacing.js +2 -2
  292. package/lib/rules/template-tag-spacing.js +2 -2
  293. package/lib/rules/unicode-bom.js +2 -2
  294. package/lib/rules/use-isnan.js +1 -1
  295. package/lib/rules/valid-jsdoc.js +2 -2
  296. package/lib/rules/valid-typeof.js +2 -2
  297. package/lib/rules/vars-on-top.js +1 -1
  298. package/lib/rules/wrap-iife.js +2 -2
  299. package/lib/rules/wrap-regex.js +2 -2
  300. package/lib/rules/yield-star-spacing.js +2 -2
  301. package/lib/rules/yoda.js +2 -2
  302. package/lib/shared/string-utils.js +39 -1
  303. package/lib/shared/types.js +6 -2
  304. package/lib/unsupported-api.js +2 -1
  305. package/messages/invalid-rule-options.js +17 -0
  306. package/messages/invalid-rule-severity.js +13 -0
  307. package/messages/shared.js +18 -0
  308. package/package.json +6 -7
@@ -364,7 +364,7 @@ function extractDirectiveComment(value) {
364
364
  * @param {ASTNode} ast The top node of the AST.
365
365
  * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
366
366
  * @param {string|null} warnInlineConfig If a string then it should warn directive comments as disabled. The string value is the config name what the setting came from.
367
- * @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: Problem[], disableDirectives: DisableDirective[]}}
367
+ * @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: LintMessage[], disableDirectives: DisableDirective[]}}
368
368
  * A collection of the directive comments that were found, along with any problems that occurred when parsing
369
369
  */
370
370
  function getDirectiveComments(ast, ruleMapper, warnInlineConfig) {
@@ -592,7 +592,7 @@ function findEslintEnv(text) {
592
592
  * Convert "/path/to/<text>" to "<text>".
593
593
  * `CLIEngine#executeOnText()` method gives "/path/to/<text>" if the filename
594
594
  * was omitted because `configArray.extractConfig()` requires an absolute path.
595
- * But the linter should pass `<text>` to `RuleContext#getFilename()` in that
595
+ * But the linter should pass `<text>` to `RuleContext#filename` in that
596
596
  * case.
597
597
  * Also, code blocks can have their virtual filename. If the parent filename was
598
598
  * `<text>`, the virtual filename is `<text>/0_foo.js` or something like (i.e.,
@@ -775,7 +775,7 @@ function analyzeScope(ast, languageOptions, visitorKeys) {
775
775
  * @param {string} text The text to parse.
776
776
  * @param {LanguageOptions} languageOptions Options to pass to the parser
777
777
  * @param {string} filePath The path to the file being parsed.
778
- * @returns {{success: false, error: Problem}|{success: true, sourceCode: SourceCode}}
778
+ * @returns {{success: false, error: LintMessage}|{success: true, sourceCode: SourceCode}}
779
779
  * An object containing the AST and parser services if parsing was successful, or the error if parsing failed
780
780
  * @private
781
781
  */
@@ -851,7 +851,8 @@ function parse(text, languageOptions, filePath) {
851
851
  severity: 2,
852
852
  message,
853
853
  line: ex.lineNumber,
854
- column: ex.column
854
+ column: ex.column,
855
+ nodeType: null
855
856
  }
856
857
  };
857
858
  }
@@ -902,7 +903,7 @@ const BASE_TRAVERSAL_CONTEXT = Object.freeze(
902
903
  (contextInfo, methodName) =>
903
904
  Object.assign(contextInfo, {
904
905
  [methodName](...args) {
905
- return this.getSourceCode()[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]](...args);
906
+ return this.sourceCode[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]](...args);
906
907
  }
907
908
  }),
908
909
  {}
@@ -921,7 +922,7 @@ const BASE_TRAVERSAL_CONTEXT = Object.freeze(
921
922
  * @param {boolean} disableFixes If true, it doesn't make `fix` properties.
922
923
  * @param {string | undefined} cwd cwd of the cli
923
924
  * @param {string} physicalFilename The full path of the file on disk without any code block information
924
- * @returns {Problem[]} An array of reported problems
925
+ * @returns {LintMessage[]} An array of reported problems
925
926
  */
926
927
  function runRules(sourceCode, configuredRules, ruleMapper, parserName, languageOptions, settings, filename, disableFixes, cwd, physicalFilename) {
927
928
  const emitter = createEmitter();
@@ -951,10 +952,14 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserName, languageO
951
952
  getAncestors: () => sourceCode.getAncestors(currentNode),
952
953
  getDeclaredVariables: node => sourceCode.getDeclaredVariables(node),
953
954
  getCwd: () => cwd,
955
+ cwd,
954
956
  getFilename: () => filename,
957
+ filename,
955
958
  getPhysicalFilename: () => physicalFilename || filename,
959
+ physicalFilename: physicalFilename || filename,
956
960
  getScope: () => sourceCode.getScope(currentNode),
957
961
  getSourceCode: () => sourceCode,
962
+ sourceCode,
958
963
  markVariableAsUsed: name => sourceCode.markVariableAsUsed(name, currentNode),
959
964
  parserOptions: {
960
965
  ...languageOptions.parserOptions
@@ -1249,7 +1254,8 @@ class Linter {
1249
1254
  severity: 2,
1250
1255
  message: `Configured parser '${config.parser}' was not found.`,
1251
1256
  line: 0,
1252
- column: 0
1257
+ column: 0,
1258
+ nodeType: null
1253
1259
  }];
1254
1260
  }
1255
1261
  parserName = config.parser;
@@ -1460,7 +1466,8 @@ class Linter {
1460
1466
  severity: 2,
1461
1467
  message,
1462
1468
  line: ex.lineNumber,
1463
- column: ex.column
1469
+ column: ex.column,
1470
+ nodeType: null
1464
1471
  }
1465
1472
  ];
1466
1473
  }
@@ -1725,7 +1732,8 @@ class Linter {
1725
1732
  severity: 1,
1726
1733
  message: `No matching configuration found for ${filename}.`,
1727
1734
  line: 0,
1728
- column: 0
1735
+ column: 0,
1736
+ nodeType: null
1729
1737
  }
1730
1738
  ];
1731
1739
  }
@@ -1790,7 +1798,8 @@ class Linter {
1790
1798
  severity: 2,
1791
1799
  message,
1792
1800
  line: ex.lineNumber,
1793
- column: ex.column
1801
+ column: ex.column,
1802
+ nodeType: null
1794
1803
  }
1795
1804
  ];
1796
1805
  }
@@ -1836,7 +1845,7 @@ class Linter {
1836
1845
  /**
1837
1846
  * Given a list of reported problems, distinguish problems between normal messages and suppressed messages.
1838
1847
  * The normal messages will be returned and the suppressed messages will be stored as lastSuppressedMessages.
1839
- * @param {Problem[]} problems A list of reported problems.
1848
+ * @param {Array<LintMessage|SuppressedLintMessage>} problems A list of reported problems.
1840
1849
  * @returns {LintMessage[]} A list of LintMessage.
1841
1850
  */
1842
1851
  _distinguishSuppressedMessages(problems) {
@@ -17,6 +17,8 @@ const interpolate = require("./interpolate");
17
17
  // Typedefs
18
18
  //------------------------------------------------------------------------------
19
19
 
20
+ /** @typedef {import("../shared/types").LintMessage} LintMessage */
21
+
20
22
  /**
21
23
  * An error message description
22
24
  * @typedef {Object} MessageDescriptor
@@ -29,23 +31,6 @@ const interpolate = require("./interpolate");
29
31
  * @property {Array<{desc?: string, messageId?: string, fix: Function}>} suggest Suggestion descriptions and functions to create a the associated fixes.
30
32
  */
31
33
 
32
- /**
33
- * Information about the report
34
- * @typedef {Object} ReportInfo
35
- * @property {string} ruleId The rule ID
36
- * @property {(0|1|2)} severity Severity of the error
37
- * @property {(string|undefined)} message The message
38
- * @property {(string|undefined)} [messageId] The message ID
39
- * @property {number} line The line number
40
- * @property {number} column The column number
41
- * @property {(number|undefined)} [endLine] The ending line number
42
- * @property {(number|undefined)} [endColumn] The ending column number
43
- * @property {(string|null)} nodeType Type of node
44
- * @property {string} source Source text
45
- * @property {({text: string, range: (number[]|null)}|null)} [fix] The fix object
46
- * @property {Array<{text: string, range: (number[]|null)}|null>} [suggestions] Suggestion info
47
- */
48
-
49
34
  //------------------------------------------------------------------------------
50
35
  // Module Definition
51
36
  //------------------------------------------------------------------------------
@@ -239,7 +224,7 @@ function mapSuggestions(descriptor, sourceCode, messages) {
239
224
  * @param {{start: SourceLocation, end: (SourceLocation|null)}} options.loc Start and end location
240
225
  * @param {{text: string, range: (number[]|null)}} options.fix The fix object
241
226
  * @param {Array<{text: string, range: (number[]|null)}>} options.suggestions The array of suggestions objects
242
- * @returns {function(...args): ReportInfo} Function that returns information about the report
227
+ * @returns {LintMessage} Information about the report
243
228
  */
244
229
  function createProblem(options) {
245
230
  const problem = {
@@ -314,7 +299,7 @@ function validateSuggestions(suggest, messages) {
314
299
  * problem for the Node.js API.
315
300
  * @param {{ruleId: string, severity: number, sourceCode: SourceCode, messageIds: Object, disableFixes: boolean}} metadata Metadata for the reported problem
316
301
  * @param {SourceCode} sourceCode The `SourceCode` instance for the text being linted
317
- * @returns {function(...args): ReportInfo} Function that returns information about the report
302
+ * @returns {function(...args): LintMessage} Function that returns information about the report
318
303
  */
319
304
 
320
305
  module.exports = function createReportTranslator(metadata) {
@@ -142,7 +142,7 @@ module.exports = {
142
142
  docs: {
143
143
  description: "Enforce getter and setter pairs in objects and classes",
144
144
  recommended: false,
145
- url: "https://eslint.org/docs/rules/accessor-pairs"
145
+ url: "https://eslint.org/docs/latest/rules/accessor-pairs"
146
146
  },
147
147
 
148
148
  schema: [{
@@ -178,7 +178,7 @@ module.exports = {
178
178
  const checkGetWithoutSet = config.getWithoutSet === true;
179
179
  const checkSetWithoutGet = config.setWithoutGet !== false;
180
180
  const enforceForClassMembers = config.enforceForClassMembers !== false;
181
- const sourceCode = context.getSourceCode();
181
+ const sourceCode = context.sourceCode;
182
182
 
183
183
  /**
184
184
  * Reports the given node.
@@ -19,7 +19,7 @@ module.exports = {
19
19
  docs: {
20
20
  description: "Enforce linebreaks after opening and before closing array brackets",
21
21
  recommended: false,
22
- url: "https://eslint.org/docs/rules/array-bracket-newline"
22
+ url: "https://eslint.org/docs/latest/rules/array-bracket-newline"
23
23
  },
24
24
 
25
25
  fixable: "whitespace",
@@ -56,7 +56,7 @@ module.exports = {
56
56
  },
57
57
 
58
58
  create(context) {
59
- const sourceCode = context.getSourceCode();
59
+ const sourceCode = context.sourceCode;
60
60
 
61
61
 
62
62
  //----------------------------------------------------------------------
@@ -18,7 +18,7 @@ module.exports = {
18
18
  docs: {
19
19
  description: "Enforce consistent spacing inside array brackets",
20
20
  recommended: false,
21
- url: "https://eslint.org/docs/rules/array-bracket-spacing"
21
+ url: "https://eslint.org/docs/latest/rules/array-bracket-spacing"
22
22
  },
23
23
 
24
24
  fixable: "whitespace",
@@ -53,7 +53,7 @@ module.exports = {
53
53
  },
54
54
  create(context) {
55
55
  const spaced = context.options[0] === "always",
56
- sourceCode = context.getSourceCode();
56
+ sourceCode = context.sourceCode;
57
57
 
58
58
  /**
59
59
  * Determines whether an option is set, relative to the spacing option.
@@ -141,7 +141,7 @@ module.exports = {
141
141
  docs: {
142
142
  description: "Enforce `return` statements in callbacks of array methods",
143
143
  recommended: false,
144
- url: "https://eslint.org/docs/rules/array-callback-return"
144
+ url: "https://eslint.org/docs/latest/rules/array-callback-return"
145
145
  },
146
146
 
147
147
  schema: [
@@ -172,7 +172,7 @@ module.exports = {
172
172
  create(context) {
173
173
 
174
174
  const options = context.options[0] || { allowImplicit: false, checkForEach: false };
175
- const sourceCode = context.getSourceCode();
175
+ const sourceCode = context.sourceCode;
176
176
 
177
177
  let funcInfo = {
178
178
  arrayMethodName: null,
@@ -19,7 +19,7 @@ module.exports = {
19
19
  docs: {
20
20
  description: "Enforce line breaks after each array element",
21
21
  recommended: false,
22
- url: "https://eslint.org/docs/rules/array-element-newline"
22
+ url: "https://eslint.org/docs/latest/rules/array-element-newline"
23
23
  },
24
24
 
25
25
  fixable: "whitespace",
@@ -79,7 +79,7 @@ module.exports = {
79
79
  },
80
80
 
81
81
  create(context) {
82
- const sourceCode = context.getSourceCode();
82
+ const sourceCode = context.sourceCode;
83
83
 
84
84
  //----------------------------------------------------------------------
85
85
  // Helpers
@@ -22,7 +22,7 @@ module.exports = {
22
22
  docs: {
23
23
  description: "Require braces around arrow function bodies",
24
24
  recommended: false,
25
- url: "https://eslint.org/docs/rules/arrow-body-style"
25
+ url: "https://eslint.org/docs/latest/rules/arrow-body-style"
26
26
  },
27
27
 
28
28
  schema: {
@@ -74,7 +74,7 @@ module.exports = {
74
74
  const asNeeded = !options[0] || options[0] === "as-needed";
75
75
  const never = options[0] === "never";
76
76
  const requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral;
77
- const sourceCode = context.getSourceCode();
77
+ const sourceCode = context.sourceCode;
78
78
  let funcInfo = null;
79
79
 
80
80
  /**
@@ -35,7 +35,7 @@ module.exports = {
35
35
  docs: {
36
36
  description: "Require parentheses around arrow function arguments",
37
37
  recommended: false,
38
- url: "https://eslint.org/docs/rules/arrow-parens"
38
+ url: "https://eslint.org/docs/latest/rules/arrow-parens"
39
39
  },
40
40
 
41
41
  fixable: "code",
@@ -69,7 +69,7 @@ module.exports = {
69
69
  const asNeeded = context.options[0] === "as-needed";
70
70
  const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
71
71
 
72
- const sourceCode = context.getSourceCode();
72
+ const sourceCode = context.sourceCode;
73
73
 
74
74
  /**
75
75
  * Finds opening paren of parameters for the given arrow function, if it exists.
@@ -22,7 +22,7 @@ module.exports = {
22
22
  docs: {
23
23
  description: "Enforce consistent spacing before and after the arrow in arrow functions",
24
24
  recommended: false,
25
- url: "https://eslint.org/docs/rules/arrow-spacing"
25
+ url: "https://eslint.org/docs/latest/rules/arrow-spacing"
26
26
  },
27
27
 
28
28
  fixable: "whitespace",
@@ -61,7 +61,7 @@ module.exports = {
61
61
  rule.before = rule.before !== false;
62
62
  rule.after = rule.after !== false;
63
63
 
64
- const sourceCode = context.getSourceCode();
64
+ const sourceCode = context.sourceCode;
65
65
 
66
66
  /**
67
67
  * Get tokens of arrow(`=>`) and before/after arrow.
@@ -16,7 +16,7 @@ module.exports = {
16
16
  docs: {
17
17
  description: "Enforce the use of variables within the scope they are defined",
18
18
  recommended: false,
19
- url: "https://eslint.org/docs/rules/block-scoped-var"
19
+ url: "https://eslint.org/docs/latest/rules/block-scoped-var"
20
20
  },
21
21
 
22
22
  schema: [],
@@ -28,7 +28,7 @@ module.exports = {
28
28
 
29
29
  create(context) {
30
30
  let stack = [];
31
- const sourceCode = context.getSourceCode();
31
+ const sourceCode = context.sourceCode;
32
32
 
33
33
  /**
34
34
  * Makes a block scope.
@@ -19,7 +19,7 @@ module.exports = {
19
19
  docs: {
20
20
  description: "Disallow or enforce spaces inside of blocks after opening block and before closing block",
21
21
  recommended: false,
22
- url: "https://eslint.org/docs/rules/block-spacing"
22
+ url: "https://eslint.org/docs/latest/rules/block-spacing"
23
23
  },
24
24
 
25
25
  fixable: "whitespace",
@@ -37,7 +37,7 @@ module.exports = {
37
37
  create(context) {
38
38
  const always = (context.options[0] !== "never"),
39
39
  messageId = always ? "missing" : "extra",
40
- sourceCode = context.getSourceCode();
40
+ sourceCode = context.sourceCode;
41
41
 
42
42
  /**
43
43
  * Gets the open brace token from a given node.
@@ -19,7 +19,7 @@ module.exports = {
19
19
  docs: {
20
20
  description: "Enforce consistent brace style for blocks",
21
21
  recommended: false,
22
- url: "https://eslint.org/docs/rules/brace-style"
22
+ url: "https://eslint.org/docs/latest/rules/brace-style"
23
23
  },
24
24
 
25
25
  schema: [
@@ -53,7 +53,7 @@ module.exports = {
53
53
  create(context) {
54
54
  const style = context.options[0] || "1tbs",
55
55
  params = context.options[1] || {},
56
- sourceCode = context.getSourceCode();
56
+ sourceCode = context.sourceCode;
57
57
 
58
58
  //--------------------------------------------------------------------------
59
59
  // Helpers
@@ -21,7 +21,7 @@ module.exports = {
21
21
  docs: {
22
22
  description: "Require `return` statements after callbacks",
23
23
  recommended: false,
24
- url: "https://eslint.org/docs/rules/callback-return"
24
+ url: "https://eslint.org/docs/latest/rules/callback-return"
25
25
  },
26
26
 
27
27
  schema: [{
@@ -37,7 +37,7 @@ module.exports = {
37
37
  create(context) {
38
38
 
39
39
  const callbacks = context.options[0] || ["callback", "cb", "next"],
40
- sourceCode = context.getSourceCode();
40
+ sourceCode = context.sourceCode;
41
41
 
42
42
  //--------------------------------------------------------------------------
43
43
  // Helpers
@@ -23,7 +23,7 @@ module.exports = {
23
23
  docs: {
24
24
  description: "Enforce camelcase naming convention",
25
25
  recommended: false,
26
- url: "https://eslint.org/docs/rules/camelcase"
26
+ url: "https://eslint.org/docs/latest/rules/camelcase"
27
27
  },
28
28
 
29
29
  schema: [
@@ -73,7 +73,7 @@ module.exports = {
73
73
  const ignoreImports = options.ignoreImports;
74
74
  const ignoreGlobals = options.ignoreGlobals;
75
75
  const allow = options.allow || [];
76
- const sourceCode = context.getSourceCode();
76
+ const sourceCode = context.sourceCode;
77
77
 
78
78
  //--------------------------------------------------------------------------
79
79
  // Helpers
@@ -107,7 +107,7 @@ module.exports = {
107
107
  docs: {
108
108
  description: "Enforce or disallow capitalization of the first letter of a comment",
109
109
  recommended: false,
110
- url: "https://eslint.org/docs/rules/capitalized-comments"
110
+ url: "https://eslint.org/docs/latest/rules/capitalized-comments"
111
111
  },
112
112
 
113
113
  fixable: "code",
@@ -139,7 +139,7 @@ module.exports = {
139
139
 
140
140
  const capitalize = context.options[0] || "always",
141
141
  normalizedOptions = getAllNormalizedOptions(context.options[1]),
142
- sourceCode = context.getSourceCode();
142
+ sourceCode = context.sourceCode;
143
143
 
144
144
  createRegExpForIgnorePatterns(normalizedOptions);
145
145
 
@@ -23,7 +23,7 @@ module.exports = {
23
23
  docs: {
24
24
  description: "Enforce that class methods utilize `this`",
25
25
  recommended: false,
26
- url: "https://eslint.org/docs/rules/class-methods-use-this"
26
+ url: "https://eslint.org/docs/latest/rules/class-methods-use-this"
27
27
  },
28
28
 
29
29
  schema: [{
@@ -133,7 +133,7 @@ module.exports = {
133
133
  if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
134
134
  context.report({
135
135
  node,
136
- loc: astUtils.getFunctionHeadLoc(node, context.getSourceCode()),
136
+ loc: astUtils.getFunctionHeadLoc(node, context.sourceCode),
137
137
  messageId: "missingThis",
138
138
  data: {
139
139
  name: astUtils.getFunctionNameWithKind(node)
@@ -78,7 +78,7 @@ module.exports = {
78
78
  docs: {
79
79
  description: "Require or disallow trailing commas",
80
80
  recommended: false,
81
- url: "https://eslint.org/docs/rules/comma-dangle"
81
+ url: "https://eslint.org/docs/latest/rules/comma-dangle"
82
82
  },
83
83
 
84
84
  fixable: "code",
@@ -136,7 +136,7 @@ module.exports = {
136
136
  create(context) {
137
137
  const options = normalizeOptions(context.options[0], context.languageOptions.ecmaVersion);
138
138
 
139
- const sourceCode = context.getSourceCode();
139
+ const sourceCode = context.sourceCode;
140
140
 
141
141
  /**
142
142
  * Gets the last item of the given node.
@@ -18,7 +18,7 @@ module.exports = {
18
18
  docs: {
19
19
  description: "Enforce consistent spacing before and after commas",
20
20
  recommended: false,
21
- url: "https://eslint.org/docs/rules/comma-spacing"
21
+ url: "https://eslint.org/docs/latest/rules/comma-spacing"
22
22
  },
23
23
 
24
24
  fixable: "whitespace",
@@ -48,7 +48,7 @@ module.exports = {
48
48
 
49
49
  create(context) {
50
50
 
51
- const sourceCode = context.getSourceCode();
51
+ const sourceCode = context.sourceCode;
52
52
  const tokensAndComments = sourceCode.tokensAndComments;
53
53
 
54
54
  const options = {
@@ -19,7 +19,7 @@ module.exports = {
19
19
  docs: {
20
20
  description: "Enforce consistent comma style",
21
21
  recommended: false,
22
- url: "https://eslint.org/docs/rules/comma-style"
22
+ url: "https://eslint.org/docs/latest/rules/comma-style"
23
23
  },
24
24
 
25
25
  fixable: "code",
@@ -51,7 +51,7 @@ module.exports = {
51
51
 
52
52
  create(context) {
53
53
  const style = context.options[0] || "last",
54
- sourceCode = context.getSourceCode();
54
+ sourceCode = context.sourceCode;
55
55
  const exceptions = {
56
56
  ArrayPattern: true,
57
57
  ArrowFunctionExpression: true,
@@ -25,7 +25,7 @@ module.exports = {
25
25
  docs: {
26
26
  description: "Enforce a maximum cyclomatic complexity allowed in a program",
27
27
  recommended: false,
28
- url: "https://eslint.org/docs/rules/complexity"
28
+ url: "https://eslint.org/docs/latest/rules/complexity"
29
29
  },
30
30
 
31
31
  schema: [
@@ -18,7 +18,7 @@ module.exports = {
18
18
  docs: {
19
19
  description: "Enforce consistent spacing inside computed property brackets",
20
20
  recommended: false,
21
- url: "https://eslint.org/docs/rules/computed-property-spacing"
21
+ url: "https://eslint.org/docs/latest/rules/computed-property-spacing"
22
22
  },
23
23
 
24
24
  fixable: "whitespace",
@@ -49,7 +49,7 @@ module.exports = {
49
49
  },
50
50
 
51
51
  create(context) {
52
- const sourceCode = context.getSourceCode();
52
+ const sourceCode = context.sourceCode;
53
53
  const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
54
54
  const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers;
55
55
 
@@ -48,7 +48,7 @@ module.exports = {
48
48
  docs: {
49
49
  description: "Require `return` statements to either always or never specify values",
50
50
  recommended: false,
51
- url: "https://eslint.org/docs/rules/consistent-return"
51
+ url: "https://eslint.org/docs/latest/rules/consistent-return"
52
52
  },
53
53
 
54
54
  schema: [{
@@ -104,7 +104,7 @@ module.exports = {
104
104
  } else if (node.type === "ArrowFunctionExpression") {
105
105
 
106
106
  // `=>` token
107
- loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc;
107
+ loc = context.sourceCode.getTokenBefore(node.body, astUtils.isArrowToken).loc;
108
108
  } else if (
109
109
  node.parent.type === "MethodDefinition" ||
110
110
  (node.parent.type === "Property" && node.parent.method)
@@ -115,7 +115,7 @@ module.exports = {
115
115
  } else {
116
116
 
117
117
  // Function name or `function` keyword.
118
- loc = (node.id || context.getSourceCode().getFirstToken(node)).loc;
118
+ loc = (node.id || context.sourceCode.getFirstToken(node)).loc;
119
119
  }
120
120
 
121
121
  if (!name) {
@@ -16,7 +16,7 @@ module.exports = {
16
16
  docs: {
17
17
  description: "Enforce consistent naming when capturing the current execution context",
18
18
  recommended: false,
19
- url: "https://eslint.org/docs/rules/consistent-this"
19
+ url: "https://eslint.org/docs/latest/rules/consistent-this"
20
20
  },
21
21
 
22
22
  schema: {
@@ -36,7 +36,7 @@ module.exports = {
36
36
 
37
37
  create(context) {
38
38
  let aliases = [];
39
- const sourceCode = context.getSourceCode();
39
+ const sourceCode = context.sourceCode;
40
40
 
41
41
  if (context.options.length === 0) {
42
42
  aliases.push("that");
@@ -124,7 +124,7 @@ module.exports = {
124
124
  docs: {
125
125
  description: "Require `super()` calls in constructors",
126
126
  recommended: true,
127
- url: "https://eslint.org/docs/rules/constructor-super"
127
+ url: "https://eslint.org/docs/latest/rules/constructor-super"
128
128
  },
129
129
 
130
130
  schema: [],
@@ -22,7 +22,7 @@ module.exports = {
22
22
  docs: {
23
23
  description: "Enforce consistent brace style for all control statements",
24
24
  recommended: false,
25
- url: "https://eslint.org/docs/rules/curly"
25
+ url: "https://eslint.org/docs/latest/rules/curly"
26
26
  },
27
27
 
28
28
  schema: {
@@ -70,7 +70,7 @@ module.exports = {
70
70
  const multiOrNest = (context.options[0] === "multi-or-nest");
71
71
  const consistent = (context.options[1] === "consistent");
72
72
 
73
- const sourceCode = context.getSourceCode();
73
+ const sourceCode = context.sourceCode;
74
74
 
75
75
  //--------------------------------------------------------------------------
76
76
  // Helpers
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Enforce default clauses in switch statements to be last",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/default-case-last"
20
+ url: "https://eslint.org/docs/latest/rules/default-case-last"
21
21
  },
22
22
 
23
23
  schema: [],
@@ -18,7 +18,7 @@ module.exports = {
18
18
  docs: {
19
19
  description: "Require `default` cases in `switch` statements",
20
20
  recommended: false,
21
- url: "https://eslint.org/docs/rules/default-case"
21
+ url: "https://eslint.org/docs/latest/rules/default-case"
22
22
  },
23
23
 
24
24
  schema: [{
@@ -42,7 +42,7 @@ module.exports = {
42
42
  ? new RegExp(options.commentPattern, "u")
43
43
  : DEFAULT_COMMENT_PATTERN;
44
44
 
45
- const sourceCode = context.getSourceCode();
45
+ const sourceCode = context.sourceCode;
46
46
 
47
47
  //--------------------------------------------------------------------------
48
48
  // Helpers
@@ -13,7 +13,7 @@ module.exports = {
13
13
  docs: {
14
14
  description: "Enforce default parameters to be last",
15
15
  recommended: false,
16
- url: "https://eslint.org/docs/rules/default-param-last"
16
+ url: "https://eslint.org/docs/latest/rules/default-param-last"
17
17
  },
18
18
 
19
19
  schema: [],