@alexlit/lint-kit 166.1.0 → 167.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 (602) hide show
  1. package/package.json +1 -1
  2. package/packages/config-commitlint/package.json +3 -3
  3. package/packages/config-eslint/package.json +2 -2
  4. package/packages/config-eslint/node_modules/@eslint/js/LICENSE +0 -19
  5. package/packages/config-eslint/node_modules/@eslint/js/README.md +0 -103
  6. package/packages/config-eslint/node_modules/@eslint/js/package.json +0 -36
  7. package/packages/config-eslint/node_modules/@eslint/js/src/configs/eslint-all.js +0 -217
  8. package/packages/config-eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js +0 -79
  9. package/packages/config-eslint/node_modules/@eslint/js/src/index.js +0 -23
  10. package/packages/config-eslint/node_modules/@eslint/js/types/index.d.ts +0 -14
  11. package/packages/config-eslint/node_modules/ajv/.tonic_example.js +0 -20
  12. package/packages/config-eslint/node_modules/ajv/LICENSE +0 -22
  13. package/packages/config-eslint/node_modules/ajv/README.md +0 -1497
  14. package/packages/config-eslint/node_modules/ajv/dist/ajv.bundle.js +0 -7189
  15. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js +0 -3
  16. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js.map +0 -1
  17. package/packages/config-eslint/node_modules/ajv/lib/ajv.d.ts +0 -397
  18. package/packages/config-eslint/node_modules/ajv/lib/ajv.js +0 -506
  19. package/packages/config-eslint/node_modules/ajv/lib/cache.js +0 -26
  20. package/packages/config-eslint/node_modules/ajv/lib/compile/async.js +0 -90
  21. package/packages/config-eslint/node_modules/ajv/lib/compile/equal.js +0 -5
  22. package/packages/config-eslint/node_modules/ajv/lib/compile/error_classes.js +0 -34
  23. package/packages/config-eslint/node_modules/ajv/lib/compile/formats.js +0 -142
  24. package/packages/config-eslint/node_modules/ajv/lib/compile/index.js +0 -387
  25. package/packages/config-eslint/node_modules/ajv/lib/compile/resolve.js +0 -270
  26. package/packages/config-eslint/node_modules/ajv/lib/compile/rules.js +0 -66
  27. package/packages/config-eslint/node_modules/ajv/lib/compile/schema_obj.js +0 -9
  28. package/packages/config-eslint/node_modules/ajv/lib/compile/ucs2length.js +0 -20
  29. package/packages/config-eslint/node_modules/ajv/lib/compile/util.js +0 -239
  30. package/packages/config-eslint/node_modules/ajv/lib/data.js +0 -49
  31. package/packages/config-eslint/node_modules/ajv/lib/definition_schema.js +0 -37
  32. package/packages/config-eslint/node_modules/ajv/lib/dot/_limit.jst +0 -113
  33. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitItems.jst +0 -12
  34. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitLength.jst +0 -12
  35. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitProperties.jst +0 -12
  36. package/packages/config-eslint/node_modules/ajv/lib/dot/allOf.jst +0 -32
  37. package/packages/config-eslint/node_modules/ajv/lib/dot/anyOf.jst +0 -46
  38. package/packages/config-eslint/node_modules/ajv/lib/dot/coerce.def +0 -51
  39. package/packages/config-eslint/node_modules/ajv/lib/dot/comment.jst +0 -9
  40. package/packages/config-eslint/node_modules/ajv/lib/dot/const.jst +0 -11
  41. package/packages/config-eslint/node_modules/ajv/lib/dot/contains.jst +0 -55
  42. package/packages/config-eslint/node_modules/ajv/lib/dot/custom.jst +0 -191
  43. package/packages/config-eslint/node_modules/ajv/lib/dot/defaults.def +0 -47
  44. package/packages/config-eslint/node_modules/ajv/lib/dot/definitions.def +0 -203
  45. package/packages/config-eslint/node_modules/ajv/lib/dot/dependencies.jst +0 -79
  46. package/packages/config-eslint/node_modules/ajv/lib/dot/enum.jst +0 -30
  47. package/packages/config-eslint/node_modules/ajv/lib/dot/errors.def +0 -194
  48. package/packages/config-eslint/node_modules/ajv/lib/dot/format.jst +0 -106
  49. package/packages/config-eslint/node_modules/ajv/lib/dot/if.jst +0 -73
  50. package/packages/config-eslint/node_modules/ajv/lib/dot/items.jst +0 -98
  51. package/packages/config-eslint/node_modules/ajv/lib/dot/missing.def +0 -39
  52. package/packages/config-eslint/node_modules/ajv/lib/dot/multipleOf.jst +0 -22
  53. package/packages/config-eslint/node_modules/ajv/lib/dot/not.jst +0 -43
  54. package/packages/config-eslint/node_modules/ajv/lib/dot/oneOf.jst +0 -54
  55. package/packages/config-eslint/node_modules/ajv/lib/dot/pattern.jst +0 -14
  56. package/packages/config-eslint/node_modules/ajv/lib/dot/properties.jst +0 -245
  57. package/packages/config-eslint/node_modules/ajv/lib/dot/propertyNames.jst +0 -52
  58. package/packages/config-eslint/node_modules/ajv/lib/dot/ref.jst +0 -85
  59. package/packages/config-eslint/node_modules/ajv/lib/dot/required.jst +0 -108
  60. package/packages/config-eslint/node_modules/ajv/lib/dot/uniqueItems.jst +0 -62
  61. package/packages/config-eslint/node_modules/ajv/lib/dot/validate.jst +0 -276
  62. package/packages/config-eslint/node_modules/ajv/lib/dotjs/README.md +0 -3
  63. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limit.js +0 -163
  64. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitItems.js +0 -80
  65. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitLength.js +0 -85
  66. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitProperties.js +0 -80
  67. package/packages/config-eslint/node_modules/ajv/lib/dotjs/allOf.js +0 -42
  68. package/packages/config-eslint/node_modules/ajv/lib/dotjs/anyOf.js +0 -73
  69. package/packages/config-eslint/node_modules/ajv/lib/dotjs/comment.js +0 -14
  70. package/packages/config-eslint/node_modules/ajv/lib/dotjs/const.js +0 -56
  71. package/packages/config-eslint/node_modules/ajv/lib/dotjs/contains.js +0 -81
  72. package/packages/config-eslint/node_modules/ajv/lib/dotjs/custom.js +0 -228
  73. package/packages/config-eslint/node_modules/ajv/lib/dotjs/dependencies.js +0 -168
  74. package/packages/config-eslint/node_modules/ajv/lib/dotjs/enum.js +0 -66
  75. package/packages/config-eslint/node_modules/ajv/lib/dotjs/format.js +0 -150
  76. package/packages/config-eslint/node_modules/ajv/lib/dotjs/if.js +0 -103
  77. package/packages/config-eslint/node_modules/ajv/lib/dotjs/index.js +0 -33
  78. package/packages/config-eslint/node_modules/ajv/lib/dotjs/items.js +0 -140
  79. package/packages/config-eslint/node_modules/ajv/lib/dotjs/multipleOf.js +0 -80
  80. package/packages/config-eslint/node_modules/ajv/lib/dotjs/not.js +0 -84
  81. package/packages/config-eslint/node_modules/ajv/lib/dotjs/oneOf.js +0 -73
  82. package/packages/config-eslint/node_modules/ajv/lib/dotjs/pattern.js +0 -75
  83. package/packages/config-eslint/node_modules/ajv/lib/dotjs/properties.js +0 -335
  84. package/packages/config-eslint/node_modules/ajv/lib/dotjs/propertyNames.js +0 -81
  85. package/packages/config-eslint/node_modules/ajv/lib/dotjs/ref.js +0 -124
  86. package/packages/config-eslint/node_modules/ajv/lib/dotjs/required.js +0 -270
  87. package/packages/config-eslint/node_modules/ajv/lib/dotjs/uniqueItems.js +0 -86
  88. package/packages/config-eslint/node_modules/ajv/lib/dotjs/validate.js +0 -482
  89. package/packages/config-eslint/node_modules/ajv/lib/keyword.js +0 -146
  90. package/packages/config-eslint/node_modules/ajv/lib/refs/data.json +0 -17
  91. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-04.json +0 -149
  92. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-06.json +0 -154
  93. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-07.json +0 -168
  94. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-secure.json +0 -94
  95. package/packages/config-eslint/node_modules/ajv/package.json +0 -106
  96. package/packages/config-eslint/node_modules/ajv/scripts/.eslintrc.yml +0 -3
  97. package/packages/config-eslint/node_modules/ajv/scripts/bundle.js +0 -61
  98. package/packages/config-eslint/node_modules/ajv/scripts/compile-dots.js +0 -73
  99. package/packages/config-eslint/node_modules/ajv/scripts/info +0 -10
  100. package/packages/config-eslint/node_modules/ajv/scripts/prepare-tests +0 -12
  101. package/packages/config-eslint/node_modules/ajv/scripts/publish-built-version +0 -32
  102. package/packages/config-eslint/node_modules/ajv/scripts/travis-gh-pages +0 -23
  103. package/packages/config-eslint/node_modules/ansi-styles/index.d.ts +0 -345
  104. package/packages/config-eslint/node_modules/ansi-styles/index.js +0 -163
  105. package/packages/config-eslint/node_modules/ansi-styles/license +0 -9
  106. package/packages/config-eslint/node_modules/ansi-styles/package.json +0 -56
  107. package/packages/config-eslint/node_modules/ansi-styles/readme.md +0 -152
  108. package/packages/config-eslint/node_modules/chalk/index.d.ts +0 -415
  109. package/packages/config-eslint/node_modules/chalk/license +0 -9
  110. package/packages/config-eslint/node_modules/chalk/package.json +0 -68
  111. package/packages/config-eslint/node_modules/chalk/readme.md +0 -341
  112. package/packages/config-eslint/node_modules/chalk/source/index.js +0 -229
  113. package/packages/config-eslint/node_modules/chalk/source/templates.js +0 -134
  114. package/packages/config-eslint/node_modules/chalk/source/util.js +0 -39
  115. package/packages/config-eslint/node_modules/color-convert/CHANGELOG.md +0 -54
  116. package/packages/config-eslint/node_modules/color-convert/LICENSE +0 -21
  117. package/packages/config-eslint/node_modules/color-convert/README.md +0 -68
  118. package/packages/config-eslint/node_modules/color-convert/conversions.js +0 -839
  119. package/packages/config-eslint/node_modules/color-convert/index.js +0 -81
  120. package/packages/config-eslint/node_modules/color-convert/package.json +0 -48
  121. package/packages/config-eslint/node_modules/color-convert/route.js +0 -97
  122. package/packages/config-eslint/node_modules/color-name/LICENSE +0 -8
  123. package/packages/config-eslint/node_modules/color-name/README.md +0 -11
  124. package/packages/config-eslint/node_modules/color-name/index.js +0 -152
  125. package/packages/config-eslint/node_modules/color-name/package.json +0 -28
  126. package/packages/config-eslint/node_modules/eslint/LICENSE +0 -19
  127. package/packages/config-eslint/node_modules/eslint/README.md +0 -354
  128. package/packages/config-eslint/node_modules/eslint/bin/eslint.js +0 -196
  129. package/packages/config-eslint/node_modules/eslint/conf/default-cli-options.js +0 -32
  130. package/packages/config-eslint/node_modules/eslint/conf/ecma-version.js +0 -16
  131. package/packages/config-eslint/node_modules/eslint/conf/globals.js +0 -169
  132. package/packages/config-eslint/node_modules/eslint/conf/replacements.json +0 -26
  133. package/packages/config-eslint/node_modules/eslint/conf/rule-type-list.json +0 -91
  134. package/packages/config-eslint/node_modules/eslint/lib/api.js +0 -50
  135. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/cli-engine.js +0 -1109
  136. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/file-enumerator.js +0 -541
  137. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json +0 -18
  138. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/html.js +0 -359
  139. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/json-with-metadata.js +0 -16
  140. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/json.js +0 -13
  141. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/stylish.js +0 -122
  142. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/hash.js +0 -35
  143. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/index.js +0 -7
  144. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/lint-result-cache.js +0 -220
  145. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/load-rules.js +0 -46
  146. package/packages/config-eslint/node_modules/eslint/lib/cli.js +0 -553
  147. package/packages/config-eslint/node_modules/eslint/lib/config/config-loader.js +0 -816
  148. package/packages/config-eslint/node_modules/eslint/lib/config/config.js +0 -674
  149. package/packages/config-eslint/node_modules/eslint/lib/config/default-config.js +0 -78
  150. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-array.js +0 -217
  151. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-schema.js +0 -598
  152. package/packages/config-eslint/node_modules/eslint/lib/config-api.js +0 -12
  153. package/packages/config-eslint/node_modules/eslint/lib/eslint/eslint-helpers.js +0 -1465
  154. package/packages/config-eslint/node_modules/eslint/lib/eslint/eslint.js +0 -1362
  155. package/packages/config-eslint/node_modules/eslint/lib/eslint/index.js +0 -9
  156. package/packages/config-eslint/node_modules/eslint/lib/eslint/legacy-eslint.js +0 -786
  157. package/packages/config-eslint/node_modules/eslint/lib/eslint/worker.js +0 -173
  158. package/packages/config-eslint/node_modules/eslint/lib/languages/js/index.js +0 -336
  159. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/index.js +0 -7
  160. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/source-code.js +0 -1364
  161. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js +0 -61
  162. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-cursor.js +0 -57
  163. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursor.js +0 -76
  164. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursors.js +0 -120
  165. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/decorative-cursor.js +0 -38
  166. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/filter-cursor.js +0 -42
  167. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js +0 -65
  168. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-cursor.js +0 -62
  169. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/index.js +0 -721
  170. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/limit-cursor.js +0 -39
  171. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/padded-token-cursor.js +0 -45
  172. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/skip-cursor.js +0 -41
  173. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/utils.js +0 -110
  174. package/packages/config-eslint/node_modules/eslint/lib/languages/js/validate-language-options.js +0 -196
  175. package/packages/config-eslint/node_modules/eslint/lib/linter/apply-disable-directives.js +0 -584
  176. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +0 -828
  177. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js +0 -262
  178. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js +0 -2370
  179. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path.js +0 -332
  180. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js +0 -223
  181. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +0 -374
  182. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/id-generator.js +0 -44
  183. package/packages/config-eslint/node_modules/eslint/lib/linter/esquery.js +0 -332
  184. package/packages/config-eslint/node_modules/eslint/lib/linter/file-context.js +0 -144
  185. package/packages/config-eslint/node_modules/eslint/lib/linter/file-report.js +0 -608
  186. package/packages/config-eslint/node_modules/eslint/lib/linter/index.js +0 -11
  187. package/packages/config-eslint/node_modules/eslint/lib/linter/interpolate.js +0 -50
  188. package/packages/config-eslint/node_modules/eslint/lib/linter/linter.js +0 -2676
  189. package/packages/config-eslint/node_modules/eslint/lib/linter/rule-fixer.js +0 -169
  190. package/packages/config-eslint/node_modules/eslint/lib/linter/rules.js +0 -71
  191. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-fixer.js +0 -154
  192. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-traverser.js +0 -333
  193. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-visitor.js +0 -81
  194. package/packages/config-eslint/node_modules/eslint/lib/linter/timing.js +0 -209
  195. package/packages/config-eslint/node_modules/eslint/lib/linter/vfile.js +0 -115
  196. package/packages/config-eslint/node_modules/eslint/lib/options.js +0 -536
  197. package/packages/config-eslint/node_modules/eslint/lib/rule-tester/index.js +0 -7
  198. package/packages/config-eslint/node_modules/eslint/lib/rule-tester/rule-tester.js +0 -1579
  199. package/packages/config-eslint/node_modules/eslint/lib/rules/accessor-pairs.js +0 -420
  200. package/packages/config-eslint/node_modules/eslint/lib/rules/array-bracket-newline.js +0 -291
  201. package/packages/config-eslint/node_modules/eslint/lib/rules/array-bracket-spacing.js +0 -301
  202. package/packages/config-eslint/node_modules/eslint/lib/rules/array-callback-return.js +0 -493
  203. package/packages/config-eslint/node_modules/eslint/lib/rules/array-element-newline.js +0 -374
  204. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-body-style.js +0 -418
  205. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-parens.js +0 -237
  206. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-spacing.js +0 -188
  207. package/packages/config-eslint/node_modules/eslint/lib/rules/block-scoped-var.js +0 -137
  208. package/packages/config-eslint/node_modules/eslint/lib/rules/block-spacing.js +0 -202
  209. package/packages/config-eslint/node_modules/eslint/lib/rules/brace-style.js +0 -278
  210. package/packages/config-eslint/node_modules/eslint/lib/rules/callback-return.js +0 -216
  211. package/packages/config-eslint/node_modules/eslint/lib/rules/camelcase.js +0 -422
  212. package/packages/config-eslint/node_modules/eslint/lib/rules/capitalized-comments.js +0 -325
  213. package/packages/config-eslint/node_modules/eslint/lib/rules/class-methods-use-this.js +0 -250
  214. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-dangle.js +0 -424
  215. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-spacing.js +0 -208
  216. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-style.js +0 -391
  217. package/packages/config-eslint/node_modules/eslint/lib/rules/complexity.js +0 -201
  218. package/packages/config-eslint/node_modules/eslint/lib/rules/computed-property-spacing.js +0 -251
  219. package/packages/config-eslint/node_modules/eslint/lib/rules/consistent-return.js +0 -221
  220. package/packages/config-eslint/node_modules/eslint/lib/rules/consistent-this.js +0 -179
  221. package/packages/config-eslint/node_modules/eslint/lib/rules/constructor-super.js +0 -453
  222. package/packages/config-eslint/node_modules/eslint/lib/rules/curly.js +0 -425
  223. package/packages/config-eslint/node_modules/eslint/lib/rules/default-case-last.js +0 -51
  224. package/packages/config-eslint/node_modules/eslint/lib/rules/default-case.js +0 -103
  225. package/packages/config-eslint/node_modules/eslint/lib/rules/default-param-last.js +0 -78
  226. package/packages/config-eslint/node_modules/eslint/lib/rules/dot-location.js +0 -138
  227. package/packages/config-eslint/node_modules/eslint/lib/rules/dot-notation.js +0 -216
  228. package/packages/config-eslint/node_modules/eslint/lib/rules/eol-last.js +0 -135
  229. package/packages/config-eslint/node_modules/eslint/lib/rules/eqeqeq.js +0 -210
  230. package/packages/config-eslint/node_modules/eslint/lib/rules/for-direction.js +0 -168
  231. package/packages/config-eslint/node_modules/eslint/lib/rules/func-call-spacing.js +0 -281
  232. package/packages/config-eslint/node_modules/eslint/lib/rules/func-name-matching.js +0 -338
  233. package/packages/config-eslint/node_modules/eslint/lib/rules/func-names.js +0 -192
  234. package/packages/config-eslint/node_modules/eslint/lib/rules/func-style.js +0 -221
  235. package/packages/config-eslint/node_modules/eslint/lib/rules/function-call-argument-newline.js +0 -166
  236. package/packages/config-eslint/node_modules/eslint/lib/rules/function-paren-newline.js +0 -368
  237. package/packages/config-eslint/node_modules/eslint/lib/rules/generator-star-spacing.js +0 -246
  238. package/packages/config-eslint/node_modules/eslint/lib/rules/getter-return.js +0 -242
  239. package/packages/config-eslint/node_modules/eslint/lib/rules/global-require.js +0 -117
  240. package/packages/config-eslint/node_modules/eslint/lib/rules/grouped-accessor-pairs.js +0 -268
  241. package/packages/config-eslint/node_modules/eslint/lib/rules/guard-for-in.js +0 -85
  242. package/packages/config-eslint/node_modules/eslint/lib/rules/handle-callback-err.js +0 -122
  243. package/packages/config-eslint/node_modules/eslint/lib/rules/id-blacklist.js +0 -241
  244. package/packages/config-eslint/node_modules/eslint/lib/rules/id-denylist.js +0 -223
  245. package/packages/config-eslint/node_modules/eslint/lib/rules/id-length.js +0 -217
  246. package/packages/config-eslint/node_modules/eslint/lib/rules/id-match.js +0 -363
  247. package/packages/config-eslint/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js +0 -125
  248. package/packages/config-eslint/node_modules/eslint/lib/rules/indent-legacy.js +0 -1369
  249. package/packages/config-eslint/node_modules/eslint/lib/rules/indent.js +0 -2334
  250. package/packages/config-eslint/node_modules/eslint/lib/rules/index.js +0 -332
  251. package/packages/config-eslint/node_modules/eslint/lib/rules/init-declarations.js +0 -172
  252. package/packages/config-eslint/node_modules/eslint/lib/rules/jsx-quotes.js +0 -128
  253. package/packages/config-eslint/node_modules/eslint/lib/rules/key-spacing.js +0 -822
  254. package/packages/config-eslint/node_modules/eslint/lib/rules/keyword-spacing.js +0 -701
  255. package/packages/config-eslint/node_modules/eslint/lib/rules/line-comment-position.js +0 -157
  256. package/packages/config-eslint/node_modules/eslint/lib/rules/linebreak-style.js +0 -135
  257. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-around-comment.js +0 -581
  258. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-around-directive.js +0 -249
  259. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-between-class-members.js +0 -358
  260. package/packages/config-eslint/node_modules/eslint/lib/rules/logical-assignment-operators.js +0 -688
  261. package/packages/config-eslint/node_modules/eslint/lib/rules/max-classes-per-file.js +0 -90
  262. package/packages/config-eslint/node_modules/eslint/lib/rules/max-depth.js +0 -159
  263. package/packages/config-eslint/node_modules/eslint/lib/rules/max-len.js +0 -497
  264. package/packages/config-eslint/node_modules/eslint/lib/rules/max-lines-per-function.js +0 -238
  265. package/packages/config-eslint/node_modules/eslint/lib/rules/max-lines.js +0 -189
  266. package/packages/config-eslint/node_modules/eslint/lib/rules/max-nested-callbacks.js +0 -115
  267. package/packages/config-eslint/node_modules/eslint/lib/rules/max-params.js +0 -129
  268. package/packages/config-eslint/node_modules/eslint/lib/rules/max-statements-per-line.js +0 -224
  269. package/packages/config-eslint/node_modules/eslint/lib/rules/max-statements.js +0 -188
  270. package/packages/config-eslint/node_modules/eslint/lib/rules/multiline-comment-style.js +0 -652
  271. package/packages/config-eslint/node_modules/eslint/lib/rules/multiline-ternary.js +0 -257
  272. package/packages/config-eslint/node_modules/eslint/lib/rules/new-cap.js +0 -277
  273. package/packages/config-eslint/node_modules/eslint/lib/rules/new-parens.js +0 -120
  274. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-after-var.js +0 -307
  275. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-before-return.js +0 -242
  276. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-per-chained-call.js +0 -159
  277. package/packages/config-eslint/node_modules/eslint/lib/rules/no-alert.js +0 -149
  278. package/packages/config-eslint/node_modules/eslint/lib/rules/no-array-constructor.js +0 -195
  279. package/packages/config-eslint/node_modules/eslint/lib/rules/no-async-promise-executor.js +0 -45
  280. package/packages/config-eslint/node_modules/eslint/lib/rules/no-await-in-loop.js +0 -115
  281. package/packages/config-eslint/node_modules/eslint/lib/rules/no-bitwise.js +0 -145
  282. package/packages/config-eslint/node_modules/eslint/lib/rules/no-buffer-constructor.js +0 -74
  283. package/packages/config-eslint/node_modules/eslint/lib/rules/no-caller.js +0 -52
  284. package/packages/config-eslint/node_modules/eslint/lib/rules/no-case-declarations.js +0 -80
  285. package/packages/config-eslint/node_modules/eslint/lib/rules/no-catch-shadow.js +0 -96
  286. package/packages/config-eslint/node_modules/eslint/lib/rules/no-class-assign.js +0 -66
  287. package/packages/config-eslint/node_modules/eslint/lib/rules/no-compare-neg-zero.js +0 -74
  288. package/packages/config-eslint/node_modules/eslint/lib/rules/no-cond-assign.js +0 -175
  289. package/packages/config-eslint/node_modules/eslint/lib/rules/no-confusing-arrow.js +0 -127
  290. package/packages/config-eslint/node_modules/eslint/lib/rules/no-console.js +0 -221
  291. package/packages/config-eslint/node_modules/eslint/lib/rules/no-const-assign.js +0 -73
  292. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constant-binary-expression.js +0 -603
  293. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constant-condition.js +0 -177
  294. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constructor-return.js +0 -62
  295. package/packages/config-eslint/node_modules/eslint/lib/rules/no-continue.js +0 -38
  296. package/packages/config-eslint/node_modules/eslint/lib/rules/no-control-regex.js +0 -142
  297. package/packages/config-eslint/node_modules/eslint/lib/rules/no-debugger.js +0 -41
  298. package/packages/config-eslint/node_modules/eslint/lib/rules/no-delete-var.js +0 -42
  299. package/packages/config-eslint/node_modules/eslint/lib/rules/no-div-regex.js +0 -60
  300. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-args.js +0 -92
  301. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-class-members.js +0 -117
  302. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-else-if.js +0 -145
  303. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-keys.js +0 -165
  304. package/packages/config-eslint/node_modules/eslint/lib/rules/no-duplicate-case.js +0 -78
  305. package/packages/config-eslint/node_modules/eslint/lib/rules/no-duplicate-imports.js +0 -368
  306. package/packages/config-eslint/node_modules/eslint/lib/rules/no-else-return.js +0 -450
  307. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-character-class.js +0 -83
  308. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-function.js +0 -236
  309. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-pattern.js +0 -85
  310. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-static-block.js +0 -73
  311. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty.js +0 -153
  312. package/packages/config-eslint/node_modules/eslint/lib/rules/no-eq-null.js +0 -51
  313. package/packages/config-eslint/node_modules/eslint/lib/rules/no-eval.js +0 -295
  314. package/packages/config-eslint/node_modules/eslint/lib/rules/no-ex-assign.js +0 -57
  315. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extend-native.js +0 -180
  316. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-bind.js +0 -224
  317. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +0 -420
  318. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-label.js +0 -169
  319. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-parens.js +0 -1669
  320. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-semi.js +0 -167
  321. package/packages/config-eslint/node_modules/eslint/lib/rules/no-fallthrough.js +0 -260
  322. package/packages/config-eslint/node_modules/eslint/lib/rules/no-floating-decimal.js +0 -99
  323. package/packages/config-eslint/node_modules/eslint/lib/rules/no-func-assign.js +0 -77
  324. package/packages/config-eslint/node_modules/eslint/lib/rules/no-global-assign.js +0 -101
  325. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implicit-coercion.js +0 -468
  326. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implicit-globals.js +0 -187
  327. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implied-eval.js +0 -170
  328. package/packages/config-eslint/node_modules/eslint/lib/rules/no-import-assign.js +0 -227
  329. package/packages/config-eslint/node_modules/eslint/lib/rules/no-inline-comments.js +0 -115
  330. package/packages/config-eslint/node_modules/eslint/lib/rules/no-inner-declarations.js +0 -147
  331. package/packages/config-eslint/node_modules/eslint/lib/rules/no-invalid-regexp.js +0 -243
  332. package/packages/config-eslint/node_modules/eslint/lib/rules/no-invalid-this.js +0 -178
  333. package/packages/config-eslint/node_modules/eslint/lib/rules/no-irregular-whitespace.js +0 -292
  334. package/packages/config-eslint/node_modules/eslint/lib/rules/no-iterator.js +0 -48
  335. package/packages/config-eslint/node_modules/eslint/lib/rules/no-label-var.js +0 -78
  336. package/packages/config-eslint/node_modules/eslint/lib/rules/no-labels.js +0 -156
  337. package/packages/config-eslint/node_modules/eslint/lib/rules/no-lone-blocks.js +0 -140
  338. package/packages/config-eslint/node_modules/eslint/lib/rules/no-lonely-if.js +0 -126
  339. package/packages/config-eslint/node_modules/eslint/lib/rules/no-loop-func.js +0 -267
  340. package/packages/config-eslint/node_modules/eslint/lib/rules/no-loss-of-precision.js +0 -249
  341. package/packages/config-eslint/node_modules/eslint/lib/rules/no-magic-numbers.js +0 -365
  342. package/packages/config-eslint/node_modules/eslint/lib/rules/no-misleading-character-class.js +0 -595
  343. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-operators.js +0 -253
  344. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-requires.js +0 -267
  345. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +0 -148
  346. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-assign.js +0 -66
  347. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-spaces.js +0 -179
  348. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-str.js +0 -67
  349. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +0 -210
  350. package/packages/config-eslint/node_modules/eslint/lib/rules/no-native-reassign.js +0 -114
  351. package/packages/config-eslint/node_modules/eslint/lib/rules/no-negated-condition.js +0 -100
  352. package/packages/config-eslint/node_modules/eslint/lib/rules/no-negated-in-lhs.js +0 -59
  353. package/packages/config-eslint/node_modules/eslint/lib/rules/no-nested-ternary.js +0 -46
  354. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-func.js +0 -96
  355. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js +0 -70
  356. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-object.js +0 -76
  357. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-require.js +0 -67
  358. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-symbol.js +0 -74
  359. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-wrappers.js +0 -62
  360. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new.js +0 -42
  361. package/packages/config-eslint/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js +0 -176
  362. package/packages/config-eslint/node_modules/eslint/lib/rules/no-obj-calls.js +0 -99
  363. package/packages/config-eslint/node_modules/eslint/lib/rules/no-object-constructor.js +0 -124
  364. package/packages/config-eslint/node_modules/eslint/lib/rules/no-octal-escape.js +0 -53
  365. package/packages/config-eslint/node_modules/eslint/lib/rules/no-octal.js +0 -42
  366. package/packages/config-eslint/node_modules/eslint/lib/rules/no-param-reassign.js +0 -248
  367. package/packages/config-eslint/node_modules/eslint/lib/rules/no-path-concat.js +0 -79
  368. package/packages/config-eslint/node_modules/eslint/lib/rules/no-plusplus.js +0 -102
  369. package/packages/config-eslint/node_modules/eslint/lib/rules/no-process-env.js +0 -68
  370. package/packages/config-eslint/node_modules/eslint/lib/rules/no-process-exit.js +0 -67
  371. package/packages/config-eslint/node_modules/eslint/lib/rules/no-promise-executor-return.js +0 -264
  372. package/packages/config-eslint/node_modules/eslint/lib/rules/no-proto.js +0 -45
  373. package/packages/config-eslint/node_modules/eslint/lib/rules/no-prototype-builtins.js +0 -181
  374. package/packages/config-eslint/node_modules/eslint/lib/rules/no-redeclare.js +0 -173
  375. package/packages/config-eslint/node_modules/eslint/lib/rules/no-regex-spaces.js +0 -219
  376. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-exports.js +0 -227
  377. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-globals.js +0 -266
  378. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-imports.js +0 -850
  379. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-modules.js +0 -249
  380. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-properties.js +0 -233
  381. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-syntax.js +0 -74
  382. package/packages/config-eslint/node_modules/eslint/lib/rules/no-return-assign.js +0 -87
  383. package/packages/config-eslint/node_modules/eslint/lib/rules/no-return-await.js +0 -162
  384. package/packages/config-eslint/node_modules/eslint/lib/rules/no-script-url.js +0 -68
  385. package/packages/config-eslint/node_modules/eslint/lib/rules/no-self-assign.js +0 -186
  386. package/packages/config-eslint/node_modules/eslint/lib/rules/no-self-compare.js +0 -77
  387. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sequences.js +0 -158
  388. package/packages/config-eslint/node_modules/eslint/lib/rules/no-setter-return.js +0 -224
  389. package/packages/config-eslint/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +0 -113
  390. package/packages/config-eslint/node_modules/eslint/lib/rules/no-shadow.js +0 -624
  391. package/packages/config-eslint/node_modules/eslint/lib/rules/no-spaced-func.js +0 -105
  392. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sparse-arrays.js +0 -68
  393. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sync.js +0 -81
  394. package/packages/config-eslint/node_modules/eslint/lib/rules/no-tabs.js +0 -110
  395. package/packages/config-eslint/node_modules/eslint/lib/rules/no-template-curly-in-string.js +0 -45
  396. package/packages/config-eslint/node_modules/eslint/lib/rules/no-ternary.js +0 -38
  397. package/packages/config-eslint/node_modules/eslint/lib/rules/no-this-before-super.js +0 -365
  398. package/packages/config-eslint/node_modules/eslint/lib/rules/no-throw-literal.js +0 -46
  399. package/packages/config-eslint/node_modules/eslint/lib/rules/no-trailing-spaces.js +0 -227
  400. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unassigned-vars.js +0 -80
  401. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undef-init.js +0 -101
  402. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undef.js +0 -84
  403. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undefined.js +0 -85
  404. package/packages/config-eslint/node_modules/eslint/lib/rules/no-underscore-dangle.js +0 -383
  405. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unexpected-multiline.js +0 -130
  406. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +0 -360
  407. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unneeded-ternary.js +0 -232
  408. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unreachable-loop.js +0 -190
  409. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unreachable.js +0 -300
  410. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-finally.js +0 -119
  411. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-negation.js +0 -152
  412. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js +0 -221
  413. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-expressions.js +0 -227
  414. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-labels.js +0 -158
  415. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-private-class-members.js +0 -219
  416. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-vars.js +0 -1739
  417. package/packages/config-eslint/node_modules/eslint/lib/rules/no-use-before-define.js +0 -446
  418. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-assignment.js +0 -654
  419. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-backreference.js +0 -263
  420. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-call.js +0 -95
  421. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-catch.js +0 -57
  422. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-computed-key.js +0 -204
  423. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-concat.js +0 -121
  424. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-constructor.js +0 -252
  425. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-escape.js +0 -406
  426. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-rename.js +0 -202
  427. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-return.js +0 -401
  428. package/packages/config-eslint/node_modules/eslint/lib/rules/no-var.js +0 -367
  429. package/packages/config-eslint/node_modules/eslint/lib/rules/no-void.js +0 -69
  430. package/packages/config-eslint/node_modules/eslint/lib/rules/no-warning-comments.js +0 -209
  431. package/packages/config-eslint/node_modules/eslint/lib/rules/no-whitespace-before-property.js +0 -150
  432. package/packages/config-eslint/node_modules/eslint/lib/rules/no-with.js +0 -37
  433. package/packages/config-eslint/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +0 -164
  434. package/packages/config-eslint/node_modules/eslint/lib/rules/object-curly-newline.js +0 -383
  435. package/packages/config-eslint/node_modules/eslint/lib/rules/object-curly-spacing.js +0 -375
  436. package/packages/config-eslint/node_modules/eslint/lib/rules/object-property-newline.js +0 -151
  437. package/packages/config-eslint/node_modules/eslint/lib/rules/object-shorthand.js +0 -652
  438. package/packages/config-eslint/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +0 -117
  439. package/packages/config-eslint/node_modules/eslint/lib/rules/one-var.js +0 -717
  440. package/packages/config-eslint/node_modules/eslint/lib/rules/operator-assignment.js +0 -270
  441. package/packages/config-eslint/node_modules/eslint/lib/rules/operator-linebreak.js +0 -315
  442. package/packages/config-eslint/node_modules/eslint/lib/rules/padded-blocks.js +0 -366
  443. package/packages/config-eslint/node_modules/eslint/lib/rules/padding-line-between-statements.js +0 -612
  444. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-arrow-callback.js +0 -437
  445. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-const.js +0 -546
  446. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-destructuring.js +0 -332
  447. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-exponentiation-operator.js +0 -235
  448. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-named-capture-group.js +0 -197
  449. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-numeric-literals.js +0 -157
  450. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-object-has-own.js +0 -148
  451. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-object-spread.js +0 -319
  452. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +0 -154
  453. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-reflect.js +0 -150
  454. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-regex-literals.js +0 -605
  455. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-rest-params.js +0 -117
  456. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-spread.js +0 -91
  457. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-template.js +0 -347
  458. package/packages/config-eslint/node_modules/eslint/lib/rules/preserve-caught-error.js +0 -535
  459. package/packages/config-eslint/node_modules/eslint/lib/rules/quote-props.js +0 -394
  460. package/packages/config-eslint/node_modules/eslint/lib/rules/quotes.js +0 -416
  461. package/packages/config-eslint/node_modules/eslint/lib/rules/radix.js +0 -216
  462. package/packages/config-eslint/node_modules/eslint/lib/rules/require-atomic-updates.js +0 -365
  463. package/packages/config-eslint/node_modules/eslint/lib/rules/require-await.js +0 -184
  464. package/packages/config-eslint/node_modules/eslint/lib/rules/require-unicode-regexp.js +0 -317
  465. package/packages/config-eslint/node_modules/eslint/lib/rules/require-yield.js +0 -76
  466. package/packages/config-eslint/node_modules/eslint/lib/rules/rest-spread-spacing.js +0 -153
  467. package/packages/config-eslint/node_modules/eslint/lib/rules/semi-spacing.js +0 -297
  468. package/packages/config-eslint/node_modules/eslint/lib/rules/semi-style.js +0 -218
  469. package/packages/config-eslint/node_modules/eslint/lib/rules/semi.js +0 -476
  470. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-imports.js +0 -319
  471. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-keys.js +0 -268
  472. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-vars.js +0 -140
  473. package/packages/config-eslint/node_modules/eslint/lib/rules/space-before-blocks.js +0 -232
  474. package/packages/config-eslint/node_modules/eslint/lib/rules/space-before-function-paren.js +0 -205
  475. package/packages/config-eslint/node_modules/eslint/lib/rules/space-in-parens.js +0 -374
  476. package/packages/config-eslint/node_modules/eslint/lib/rules/space-infix-ops.js +0 -252
  477. package/packages/config-eslint/node_modules/eslint/lib/rules/space-unary-ops.js +0 -400
  478. package/packages/config-eslint/node_modules/eslint/lib/rules/spaced-comment.js +0 -447
  479. package/packages/config-eslint/node_modules/eslint/lib/rules/strict.js +0 -314
  480. package/packages/config-eslint/node_modules/eslint/lib/rules/switch-colon-spacing.js +0 -158
  481. package/packages/config-eslint/node_modules/eslint/lib/rules/symbol-description.js +0 -70
  482. package/packages/config-eslint/node_modules/eslint/lib/rules/template-curly-spacing.js +0 -168
  483. package/packages/config-eslint/node_modules/eslint/lib/rules/template-tag-spacing.js +0 -121
  484. package/packages/config-eslint/node_modules/eslint/lib/rules/unicode-bom.js +0 -73
  485. package/packages/config-eslint/node_modules/eslint/lib/rules/use-isnan.js +0 -268
  486. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/ast-utils.js +0 -2733
  487. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/char-source.js +0 -247
  488. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/fix-tracker.js +0 -125
  489. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/keywords.js +0 -67
  490. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js +0 -118
  491. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/regular-expressions.js +0 -58
  492. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/index.js +0 -16
  493. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js +0 -13
  494. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-emoji-modifier.js +0 -13
  495. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-regional-indicator-symbol.js +0 -13
  496. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-surrogate-pair.js +0 -14
  497. package/packages/config-eslint/node_modules/eslint/lib/rules/valid-typeof.js +0 -171
  498. package/packages/config-eslint/node_modules/eslint/lib/rules/vars-on-top.js +0 -165
  499. package/packages/config-eslint/node_modules/eslint/lib/rules/wrap-iife.js +0 -238
  500. package/packages/config-eslint/node_modules/eslint/lib/rules/wrap-regex.js +0 -91
  501. package/packages/config-eslint/node_modules/eslint/lib/rules/yield-star-spacing.js +0 -159
  502. package/packages/config-eslint/node_modules/eslint/lib/rules/yoda.js +0 -362
  503. package/packages/config-eslint/node_modules/eslint/lib/services/parser-service.js +0 -65
  504. package/packages/config-eslint/node_modules/eslint/lib/services/processor-service.js +0 -101
  505. package/packages/config-eslint/node_modules/eslint/lib/services/suppressions-service.js +0 -302
  506. package/packages/config-eslint/node_modules/eslint/lib/services/warning-service.js +0 -111
  507. package/packages/config-eslint/node_modules/eslint/lib/shared/ajv.js +0 -34
  508. package/packages/config-eslint/node_modules/eslint/lib/shared/assert.js +0 -21
  509. package/packages/config-eslint/node_modules/eslint/lib/shared/ast-utils.js +0 -30
  510. package/packages/config-eslint/node_modules/eslint/lib/shared/deep-merge-arrays.js +0 -62
  511. package/packages/config-eslint/node_modules/eslint/lib/shared/directives.js +0 -16
  512. package/packages/config-eslint/node_modules/eslint/lib/shared/flags.js +0 -108
  513. package/packages/config-eslint/node_modules/eslint/lib/shared/logging.js +0 -38
  514. package/packages/config-eslint/node_modules/eslint/lib/shared/naming.js +0 -109
  515. package/packages/config-eslint/node_modules/eslint/lib/shared/option-utils.js +0 -63
  516. package/packages/config-eslint/node_modules/eslint/lib/shared/relative-module-resolver.js +0 -28
  517. package/packages/config-eslint/node_modules/eslint/lib/shared/runtime-info.js +0 -177
  518. package/packages/config-eslint/node_modules/eslint/lib/shared/serialization.js +0 -78
  519. package/packages/config-eslint/node_modules/eslint/lib/shared/severity.js +0 -49
  520. package/packages/config-eslint/node_modules/eslint/lib/shared/stats.js +0 -30
  521. package/packages/config-eslint/node_modules/eslint/lib/shared/string-utils.js +0 -58
  522. package/packages/config-eslint/node_modules/eslint/lib/shared/text-table.js +0 -68
  523. package/packages/config-eslint/node_modules/eslint/lib/shared/translate-cli-options.js +0 -281
  524. package/packages/config-eslint/node_modules/eslint/lib/shared/traverser.js +0 -202
  525. package/packages/config-eslint/node_modules/eslint/lib/types/config-api.d.ts +0 -12
  526. package/packages/config-eslint/node_modules/eslint/lib/types/index.d.ts +0 -1473
  527. package/packages/config-eslint/node_modules/eslint/lib/types/rules.d.ts +0 -5589
  528. package/packages/config-eslint/node_modules/eslint/lib/types/universal.d.ts +0 -6
  529. package/packages/config-eslint/node_modules/eslint/lib/types/use-at-your-own-risk.d.ts +0 -87
  530. package/packages/config-eslint/node_modules/eslint/lib/universal.js +0 -10
  531. package/packages/config-eslint/node_modules/eslint/lib/unsupported-api.js +0 -29
  532. package/packages/config-eslint/node_modules/eslint/messages/all-files-ignored.js +0 -16
  533. package/packages/config-eslint/node_modules/eslint/messages/all-matched-files-ignored.js +0 -21
  534. package/packages/config-eslint/node_modules/eslint/messages/config-file-missing.js +0 -16
  535. package/packages/config-eslint/node_modules/eslint/messages/config-plugin-missing.js +0 -14
  536. package/packages/config-eslint/node_modules/eslint/messages/config-serialize-function.js +0 -30
  537. package/packages/config-eslint/node_modules/eslint/messages/eslintrc-incompat.js +0 -117
  538. package/packages/config-eslint/node_modules/eslint/messages/eslintrc-plugins.js +0 -27
  539. package/packages/config-eslint/node_modules/eslint/messages/extend-config-missing.js +0 -13
  540. package/packages/config-eslint/node_modules/eslint/messages/failed-to-read-json.js +0 -11
  541. package/packages/config-eslint/node_modules/eslint/messages/file-not-found.js +0 -10
  542. package/packages/config-eslint/node_modules/eslint/messages/invalid-rule-options.js +0 -17
  543. package/packages/config-eslint/node_modules/eslint/messages/invalid-rule-severity.js +0 -13
  544. package/packages/config-eslint/node_modules/eslint/messages/no-config-found.js +0 -15
  545. package/packages/config-eslint/node_modules/eslint/messages/plugin-conflict.js +0 -22
  546. package/packages/config-eslint/node_modules/eslint/messages/plugin-invalid.js +0 -16
  547. package/packages/config-eslint/node_modules/eslint/messages/plugin-missing.js +0 -19
  548. package/packages/config-eslint/node_modules/eslint/messages/print-config-with-directory-path.js +0 -8
  549. package/packages/config-eslint/node_modules/eslint/messages/shared.js +0 -23
  550. package/packages/config-eslint/node_modules/eslint/messages/whitespace-found.js +0 -11
  551. package/packages/config-eslint/node_modules/eslint/package.json +0 -226
  552. package/packages/config-eslint/node_modules/find-up/index.d.ts +0 -138
  553. package/packages/config-eslint/node_modules/find-up/index.js +0 -89
  554. package/packages/config-eslint/node_modules/find-up/license +0 -9
  555. package/packages/config-eslint/node_modules/find-up/package.json +0 -54
  556. package/packages/config-eslint/node_modules/find-up/readme.md +0 -151
  557. package/packages/config-eslint/node_modules/globals/globals.json +0 -3970
  558. package/packages/config-eslint/node_modules/globals/index.d.ts +0 -4087
  559. package/packages/config-eslint/node_modules/globals/index.js +0 -2
  560. package/packages/config-eslint/node_modules/globals/license +0 -9
  561. package/packages/config-eslint/node_modules/globals/package.json +0 -122
  562. package/packages/config-eslint/node_modules/globals/readme.md +0 -42
  563. package/packages/config-eslint/node_modules/ignore/LICENSE-MIT +0 -21
  564. package/packages/config-eslint/node_modules/ignore/README.md +0 -412
  565. package/packages/config-eslint/node_modules/ignore/index.d.ts +0 -61
  566. package/packages/config-eslint/node_modules/ignore/index.js +0 -636
  567. package/packages/config-eslint/node_modules/ignore/legacy.js +0 -559
  568. package/packages/config-eslint/node_modules/ignore/package.json +0 -74
  569. package/packages/config-eslint/node_modules/json-schema-traverse/.eslintrc.yml +0 -27
  570. package/packages/config-eslint/node_modules/json-schema-traverse/.travis.yml +0 -8
  571. package/packages/config-eslint/node_modules/json-schema-traverse/LICENSE +0 -21
  572. package/packages/config-eslint/node_modules/json-schema-traverse/README.md +0 -83
  573. package/packages/config-eslint/node_modules/json-schema-traverse/index.js +0 -89
  574. package/packages/config-eslint/node_modules/json-schema-traverse/package.json +0 -43
  575. package/packages/config-eslint/node_modules/json-schema-traverse/spec/.eslintrc.yml +0 -6
  576. package/packages/config-eslint/node_modules/json-schema-traverse/spec/fixtures/schema.js +0 -125
  577. package/packages/config-eslint/node_modules/json-schema-traverse/spec/index.spec.js +0 -171
  578. package/packages/config-eslint/node_modules/locate-path/index.d.ts +0 -83
  579. package/packages/config-eslint/node_modules/locate-path/index.js +0 -68
  580. package/packages/config-eslint/node_modules/locate-path/license +0 -9
  581. package/packages/config-eslint/node_modules/locate-path/package.json +0 -46
  582. package/packages/config-eslint/node_modules/locate-path/readme.md +0 -125
  583. package/packages/config-eslint/node_modules/p-limit/index.d.ts +0 -42
  584. package/packages/config-eslint/node_modules/p-limit/index.js +0 -71
  585. package/packages/config-eslint/node_modules/p-limit/license +0 -9
  586. package/packages/config-eslint/node_modules/p-limit/package.json +0 -52
  587. package/packages/config-eslint/node_modules/p-limit/readme.md +0 -101
  588. package/packages/config-eslint/node_modules/p-locate/index.d.ts +0 -53
  589. package/packages/config-eslint/node_modules/p-locate/index.js +0 -50
  590. package/packages/config-eslint/node_modules/p-locate/license +0 -9
  591. package/packages/config-eslint/node_modules/p-locate/package.json +0 -54
  592. package/packages/config-eslint/node_modules/p-locate/readme.md +0 -93
  593. package/packages/config-eslint/node_modules/path-exists/index.d.ts +0 -28
  594. package/packages/config-eslint/node_modules/path-exists/index.js +0 -23
  595. package/packages/config-eslint/node_modules/path-exists/license +0 -9
  596. package/packages/config-eslint/node_modules/path-exists/package.json +0 -39
  597. package/packages/config-eslint/node_modules/path-exists/readme.md +0 -52
  598. package/packages/config-eslint/node_modules/yocto-queue/index.d.ts +0 -56
  599. package/packages/config-eslint/node_modules/yocto-queue/index.js +0 -68
  600. package/packages/config-eslint/node_modules/yocto-queue/license +0 -9
  601. package/packages/config-eslint/node_modules/yocto-queue/package.json +0 -43
  602. package/packages/config-eslint/node_modules/yocto-queue/readme.md +0 -64
@@ -1,2676 +0,0 @@
1
- /**
2
- * @fileoverview Main Linter Class
3
- * @author Gyandeep Singh
4
- * @author aladdin-add
5
- */
6
-
7
- "use strict";
8
-
9
- //------------------------------------------------------------------------------
10
- // Requirements
11
- //------------------------------------------------------------------------------
12
-
13
- const path = require("node:path"),
14
- eslintScope = require("eslint-scope"),
15
- evk = require("eslint-visitor-keys"),
16
- espree = require("espree"),
17
- merge = require("lodash.merge"),
18
- pkg = require("../../package.json"),
19
- {
20
- Legacy: {
21
- ConfigOps,
22
- ConfigValidator,
23
- environments: BuiltInEnvironments,
24
- },
25
- } = require("@eslint/eslintrc/universal"),
26
- Traverser = require("../shared/traverser"),
27
- { SourceCode } = require("../languages/js/source-code"),
28
- applyDisableDirectives = require("./apply-disable-directives"),
29
- { ConfigCommentParser } = require("@eslint/plugin-kit"),
30
- Rules = require("./rules"),
31
- SourceCodeFixer = require("./source-code-fixer"),
32
- { SourceCodeVisitor } = require("./source-code-visitor"),
33
- timing = require("./timing");
34
- const { FlatConfigArray } = require("../config/flat-config-array");
35
- const { startTime, endTime } = require("../shared/stats");
36
- const { assertIsRuleSeverity } = require("../config/flat-config-schema");
37
- const {
38
- normalizeSeverityToString,
39
- normalizeSeverityToNumber,
40
- } = require("../shared/severity");
41
- const { deepMergeArrays } = require("../shared/deep-merge-arrays");
42
- const jslang = require("../languages/js");
43
- const {
44
- activeFlags,
45
- inactiveFlags,
46
- getInactivityReasonMessage,
47
- } = require("../shared/flags");
48
- const debug = require("debug")("eslint:linter");
49
- const MAX_AUTOFIX_PASSES = 10;
50
- const DEFAULT_PARSER_NAME = "espree";
51
- const DEFAULT_ECMA_VERSION = 5;
52
- const commentParser = new ConfigCommentParser();
53
- const parserSymbol = Symbol.for("eslint.RuleTester.parser");
54
- const { LATEST_ECMA_VERSION } = require("../../conf/ecma-version");
55
- const { VFile } = require("./vfile");
56
- const { ParserService } = require("../services/parser-service");
57
- const { FileContext } = require("./file-context");
58
- const { ProcessorService } = require("../services/processor-service");
59
- const { containsDifferentProperty } = require("../shared/option-utils");
60
- const { Config } = require("../config/config");
61
- const { WarningService } = require("../services/warning-service");
62
- const { SourceCodeTraverser } = require("./source-code-traverser");
63
- const { FileReport, updateLocationInformation } = require("./file-report");
64
-
65
- //------------------------------------------------------------------------------
66
- // Typedefs
67
- //------------------------------------------------------------------------------
68
-
69
- /** @import { Language, LanguageOptions, RuleConfig, RuleDefinition, RuleSeverity } from "@eslint/core" */
70
-
71
- /** @typedef {import("../types").Linter.Config} Config */
72
- /** @typedef {import("../types").ESLint.ConfigData} ConfigData */
73
- /** @typedef {import("../types").ESLint.Environment} Environment */
74
- /** @typedef {import("../types").Linter.GlobalConf} GlobalConf */
75
- /** @typedef {import("../types").Linter.LanguageOptions} JSLanguageOptions */
76
- /** @typedef {import("../types").Linter.LintMessage} LintMessage */
77
- /** @typedef {import("../types").Linter.Parser} Parser */
78
- /** @typedef {import("../types").Linter.ParserOptions} ParserOptions */
79
- /** @typedef {import("../types").Linter.Processor} Processor */
80
- /** @typedef {import("../types").Rule.RuleModule} Rule */
81
- /** @typedef {import("../types").Linter.StringSeverity} StringSeverity */
82
- /** @typedef {import("../types").Linter.SuppressedLintMessage} SuppressedLintMessage */
83
- /** @typedef {import("../types").Linter.TimePass} TimePass */
84
-
85
- /* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */
86
- /**
87
- * @template T
88
- * @typedef {{ [P in keyof T]-?: T[P] }} Required
89
- */
90
- /* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */
91
-
92
- /**
93
- * @typedef {Object} DisableDirective
94
- * @property {("disable"|"enable"|"disable-line"|"disable-next-line")} type Type of directive
95
- * @property {number} line The line number
96
- * @property {number} column The column number
97
- * @property {(string|null)} ruleId The rule ID
98
- * @property {string} justification The justification of directive
99
- */
100
-
101
- /**
102
- * The private data for `Linter` instance.
103
- * @typedef {Object} LinterInternalSlots
104
- * @property {ConfigArray|null} lastConfigArray The `ConfigArray` instance that the last `verify()` call used.
105
- * @property {SourceCode|null} lastSourceCode The `SourceCode` instance that the last `verify()` call used.
106
- * @property {SuppressedLintMessage[]} lastSuppressedMessages The `SuppressedLintMessage[]` instance that the last `verify()` call produced.
107
- * @property {Map<string, Parser>} parserMap The loaded parsers.
108
- * @property {{ passes: TimePass[]; }} times The times spent on applying a rule to a file (see `stats` option).
109
- * @property {Rules} ruleMap The loaded rules.
110
- * @property {WarningService} warningService The warning service.
111
- */
112
-
113
- /**
114
- * @typedef {Object} VerifyOptions
115
- * @property {boolean} [allowInlineConfig] Allow/disallow inline comments' ability
116
- * to change config once it is set. Defaults to true if not supplied.
117
- * Useful if you want to validate JS without comments overriding rules.
118
- * @property {boolean} [disableFixes] if `true` then the linter doesn't make `fix`
119
- * properties into the lint result.
120
- * @property {string} [filename] the filename of the source code.
121
- * @property {boolean | "off" | "warn" | "error"} [reportUnusedDisableDirectives] Adds reported errors for
122
- * unused `eslint-disable` directives.
123
- * @property {Function} [ruleFilter] A predicate function that determines whether a given rule should run.
124
- */
125
-
126
- /**
127
- * @typedef {Object} ProcessorOptions
128
- * @property {(filename:string, text:string) => boolean} [filterCodeBlock] the
129
- * predicate function that selects adopt code blocks.
130
- * @property {Processor.postprocess} [postprocess] postprocessor for report
131
- * messages. If provided, this should accept an array of the message lists
132
- * for each code block returned from the preprocessor, apply a mapping to
133
- * the messages as appropriate, and return a one-dimensional array of
134
- * messages.
135
- * @property {Processor.preprocess} [preprocess] preprocessor for source text.
136
- * If provided, this should accept a string of source text, and return an
137
- * array of code blocks to lint.
138
- */
139
-
140
- /**
141
- * @typedef {Object} FixOptions
142
- * @property {boolean | ((message: LintMessage) => boolean)} [fix] Determines
143
- * whether fixes should be applied.
144
- */
145
-
146
- /**
147
- * @typedef {Object} InternalOptions
148
- * @property {string | null} warnInlineConfig The config name what `noInlineConfig` setting came from. If `noInlineConfig` setting didn't exist, this is null. If this is a config name, then the linter warns directive comments.
149
- * @property {StringSeverity} reportUnusedDisableDirectives Severity to report unused disable directives, if not "off" (boolean values were normalized).
150
- * @property {StringSeverity} reportUnusedInlineConfigs Severity to report unused inline configs, if not "off".
151
- */
152
-
153
- //------------------------------------------------------------------------------
154
- // Helpers
155
- //------------------------------------------------------------------------------
156
-
157
- /**
158
- * Determines if a given object is Espree.
159
- * @param {Object} parser The parser to check.
160
- * @returns {boolean} True if the parser is Espree or false if not.
161
- */
162
- function isEspree(parser) {
163
- return !!(parser === espree || parser[parserSymbol] === espree);
164
- }
165
-
166
- /**
167
- * Ensures that variables representing built-in properties of the Global Object,
168
- * and any globals declared by special block comments, are present in the global
169
- * scope.
170
- * @param {Scope} globalScope The global scope.
171
- * @param {Object} configGlobals The globals declared in configuration
172
- * @param {{exportedVariables: Object, enabledGlobals: Object}} commentDirectives Directives from comment configuration
173
- * @returns {void}
174
- */
175
- function addDeclaredGlobals(
176
- globalScope,
177
- configGlobals,
178
- { exportedVariables, enabledGlobals },
179
- ) {
180
- // Define configured global variables.
181
- for (const id of new Set([
182
- ...Object.keys(configGlobals),
183
- ...Object.keys(enabledGlobals),
184
- ])) {
185
- /*
186
- * `ConfigOps.normalizeConfigGlobal` will throw an error if a configured global value is invalid. However, these errors would
187
- * typically be caught when validating a config anyway (validity for inline global comments is checked separately).
188
- */
189
- const configValue =
190
- configGlobals[id] === void 0
191
- ? void 0
192
- : ConfigOps.normalizeConfigGlobal(configGlobals[id]);
193
- const commentValue = enabledGlobals[id] && enabledGlobals[id].value;
194
- const value = commentValue || configValue;
195
- const sourceComments =
196
- enabledGlobals[id] && enabledGlobals[id].comments;
197
-
198
- if (value === "off") {
199
- continue;
200
- }
201
-
202
- let variable = globalScope.set.get(id);
203
-
204
- if (!variable) {
205
- variable = new eslintScope.Variable(id, globalScope);
206
-
207
- globalScope.variables.push(variable);
208
- globalScope.set.set(id, variable);
209
- }
210
-
211
- variable.eslintImplicitGlobalSetting = configValue;
212
- variable.eslintExplicitGlobal = sourceComments !== void 0;
213
- variable.eslintExplicitGlobalComments = sourceComments;
214
- variable.writeable = value === "writable";
215
- }
216
-
217
- // mark all exported variables as such
218
- Object.keys(exportedVariables).forEach(name => {
219
- const variable = globalScope.set.get(name);
220
-
221
- if (variable) {
222
- variable.eslintUsed = true;
223
- variable.eslintExported = true;
224
- }
225
- });
226
-
227
- /*
228
- * "through" contains all references which definitions cannot be found.
229
- * Since we augment the global scope using configuration, we need to update
230
- * references and remove the ones that were added by configuration.
231
- */
232
- globalScope.through = globalScope.through.filter(reference => {
233
- const name = reference.identifier.name;
234
- const variable = globalScope.set.get(name);
235
-
236
- if (variable) {
237
- /*
238
- * Links the variable and the reference.
239
- * And this reference is removed from `Scope#through`.
240
- */
241
- reference.resolved = variable;
242
- variable.references.push(reference);
243
-
244
- return false;
245
- }
246
-
247
- return true;
248
- });
249
- }
250
-
251
- /**
252
- * Wraps the value in an Array if it isn't already one.
253
- * @template T
254
- * @param {T|T[]} value Value to be wrapped.
255
- * @returns {Array} The value as an array.
256
- */
257
- function asArray(value) {
258
- return Array.isArray(value) ? value : [value];
259
- }
260
-
261
- /**
262
- * Pushes a problem to inlineConfigProblems if ruleOptions are redundant.
263
- * @param {Config} config Provided config.
264
- * @param {Object} loc A line/column location
265
- * @param {FileReport} report Report that may be added to.
266
- * @param {string} ruleId The rule ID.
267
- * @param {Array} ruleOptions The rule options, merged with the config's.
268
- * @param {Array} ruleOptionsInline The rule options from the comment.
269
- * @param {"error"|"warn"} severity The severity to report.
270
- * @returns {void}
271
- */
272
- function addProblemIfSameSeverityAndOptions(
273
- config,
274
- loc,
275
- report,
276
- ruleId,
277
- ruleOptions,
278
- ruleOptionsInline,
279
- severity,
280
- ) {
281
- const existingConfigRaw = config.rules?.[ruleId];
282
- const existingConfig = existingConfigRaw
283
- ? asArray(existingConfigRaw)
284
- : ["off"];
285
- const existingSeverity = normalizeSeverityToString(existingConfig[0]);
286
- const inlineSeverity = normalizeSeverityToString(ruleOptions[0]);
287
- const sameSeverity = existingSeverity === inlineSeverity;
288
-
289
- if (!sameSeverity) {
290
- return;
291
- }
292
-
293
- const alreadyConfigured = existingConfigRaw
294
- ? `is already configured to '${existingSeverity}'`
295
- : "is not enabled so can't be turned off";
296
- let message;
297
-
298
- if (
299
- (existingConfig.length === 1 && ruleOptions.length === 1) ||
300
- existingSeverity === "off"
301
- ) {
302
- message = `Unused inline config ('${ruleId}' ${alreadyConfigured}).`;
303
- } else if (
304
- !containsDifferentProperty(
305
- ruleOptions.slice(1),
306
- existingConfig.slice(1),
307
- )
308
- ) {
309
- message =
310
- ruleOptionsInline.length === 1
311
- ? `Unused inline config ('${ruleId}' ${alreadyConfigured}).`
312
- : `Unused inline config ('${ruleId}' ${alreadyConfigured} with the same options).`;
313
- }
314
-
315
- if (message) {
316
- const numericSeverity = normalizeSeverityToNumber(severity);
317
- const descriptor = {
318
- message,
319
- loc,
320
- };
321
-
322
- if (numericSeverity === 1) {
323
- report.addWarning(descriptor);
324
- } else if (numericSeverity === 2) {
325
- report.addError(descriptor);
326
- }
327
- }
328
- }
329
-
330
- /**
331
- * Creates a collection of disable directives from a comment
332
- * @param {Object} options to create disable directives
333
- * @param {("disable"|"enable"|"disable-line"|"disable-next-line")} options.type The type of directive comment
334
- * @param {string} options.value The value after the directive in the comment
335
- * comment specified no specific rules, so it applies to all rules (e.g. `eslint-disable`)
336
- * @param {string} options.justification The justification of the directive
337
- * @param {ASTNode|token} options.node The Comment node/token.
338
- * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
339
- * @param {Language} language The language to use to adjust the location information.
340
- * @param {SourceCode} sourceCode The SourceCode object to get comments from.
341
- * @param {FileReport} report The report to add problems to.
342
- * @returns {Object[]} Directives from the comment
343
- */
344
- function createDisableDirectives(
345
- { type, value, justification, node },
346
- ruleMapper,
347
- language,
348
- sourceCode,
349
- report,
350
- ) {
351
- const ruleIds = Object.keys(commentParser.parseListConfig(value));
352
- const directiveRules = ruleIds.length ? ruleIds : [null];
353
- const directives = []; // valid disable directives
354
- const parentDirective = { node, value, ruleIds };
355
-
356
- for (const ruleId of directiveRules) {
357
- const loc = sourceCode.getLoc(node);
358
-
359
- // push to directives, if the rule is defined(including null, e.g. /*eslint enable*/)
360
- if (ruleId === null || !!ruleMapper(ruleId)) {
361
- if (type === "disable-next-line") {
362
- const { line, column } = updateLocationInformation(
363
- loc.end,
364
- language,
365
- );
366
-
367
- directives.push({
368
- parentDirective,
369
- type,
370
- line,
371
- column,
372
- ruleId,
373
- justification,
374
- });
375
- } else {
376
- const { line, column } = updateLocationInformation(
377
- loc.start,
378
- language,
379
- );
380
-
381
- directives.push({
382
- parentDirective,
383
- type,
384
- line,
385
- column,
386
- ruleId,
387
- justification,
388
- });
389
- }
390
- } else {
391
- report.addError({ ruleId, loc });
392
- }
393
- }
394
-
395
- return directives;
396
- }
397
-
398
- /**
399
- * Parses comments in file to extract file-specific config of rules, globals
400
- * and environments and merges them with global config; also code blocks
401
- * where reporting is disabled or enabled and merges them with reporting config.
402
- * @param {SourceCode} sourceCode The SourceCode object to get comments from.
403
- * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
404
- * @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.
405
- * @param {ConfigData} config Provided config.
406
- * @param {FileReport} report The report to add problems to.
407
- * @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, disableDirectives: DisableDirective[]}}
408
- * A collection of the directive comments that were found, along with any problems that occurred when parsing
409
- */
410
- function getDirectiveComments(
411
- sourceCode,
412
- ruleMapper,
413
- warnInlineConfig,
414
- config,
415
- report,
416
- ) {
417
- const configuredRules = {};
418
- const enabledGlobals = Object.create(null);
419
- const exportedVariables = {};
420
- const disableDirectives = [];
421
- const validator = new ConfigValidator({
422
- builtInRules: Rules,
423
- });
424
-
425
- sourceCode
426
- .getInlineConfigNodes()
427
- .filter(token => token.type !== "Shebang")
428
- .forEach(comment => {
429
- const directive = commentParser.parseDirective(comment.value);
430
-
431
- if (!directive) {
432
- return;
433
- }
434
-
435
- const {
436
- label,
437
- value,
438
- justification: justificationPart,
439
- } = directive;
440
-
441
- const lineCommentSupported =
442
- /^eslint-disable-(?:next-)?line$/u.test(label);
443
-
444
- if (comment.type === "Line" && !lineCommentSupported) {
445
- return;
446
- }
447
-
448
- const loc = sourceCode.getLoc(comment);
449
-
450
- if (warnInlineConfig) {
451
- const kind =
452
- comment.type === "Block" ? `/*${label}*/` : `//${label}`;
453
-
454
- report.addWarning({
455
- ruleId: null,
456
- message: `'${kind}' has no effect because you have 'noInlineConfig' setting in ${warnInlineConfig}.`,
457
- loc,
458
- });
459
- return;
460
- }
461
-
462
- if (
463
- label === "eslint-disable-line" &&
464
- loc.start.line !== loc.end.line
465
- ) {
466
- const message = `${label} comment should not span multiple lines.`;
467
-
468
- report.addError({
469
- message,
470
- loc,
471
- });
472
- return;
473
- }
474
-
475
- switch (label) {
476
- case "eslint-disable":
477
- case "eslint-enable":
478
- case "eslint-disable-next-line":
479
- case "eslint-disable-line": {
480
- const directiveType = label.slice("eslint-".length);
481
- const directives = createDisableDirectives(
482
- {
483
- type: directiveType,
484
- value,
485
- justification: justificationPart,
486
- node: comment,
487
- },
488
- ruleMapper,
489
- jslang,
490
- sourceCode,
491
- report,
492
- );
493
-
494
- disableDirectives.push(...directives);
495
- break;
496
- }
497
-
498
- case "exported":
499
- Object.assign(
500
- exportedVariables,
501
- commentParser.parseListConfig(value),
502
- );
503
- break;
504
-
505
- case "globals":
506
- case "global":
507
- for (const [id, idSetting] of Object.entries(
508
- commentParser.parseStringConfig(value),
509
- )) {
510
- let normalizedValue;
511
-
512
- try {
513
- normalizedValue =
514
- ConfigOps.normalizeConfigGlobal(idSetting);
515
- } catch (err) {
516
- report.addError({
517
- loc,
518
- message: err.message,
519
- });
520
- continue;
521
- }
522
-
523
- if (enabledGlobals[id]) {
524
- enabledGlobals[id].comments.push(comment);
525
- enabledGlobals[id].value = normalizedValue;
526
- } else {
527
- enabledGlobals[id] = {
528
- comments: [comment],
529
- value: normalizedValue,
530
- };
531
- }
532
- }
533
- break;
534
-
535
- case "eslint": {
536
- const parseResult =
537
- commentParser.parseJSONLikeConfig(value);
538
-
539
- if (parseResult.ok) {
540
- Object.keys(parseResult.config).forEach(name => {
541
- const rule = ruleMapper(name);
542
- const ruleValue = parseResult.config[name];
543
-
544
- if (!rule) {
545
- report.addError({ ruleId: name, loc });
546
- return;
547
- }
548
-
549
- if (Object.hasOwn(configuredRules, name)) {
550
- report.addError({
551
- message: `Rule "${name}" is already configured by another configuration comment in the preceding code. This configuration is ignored.`,
552
- loc,
553
- });
554
- return;
555
- }
556
-
557
- let ruleOptions = asArray(ruleValue);
558
-
559
- /*
560
- * If the rule was already configured, inline rule configuration that
561
- * only has severity should retain options from the config and just override the severity.
562
- *
563
- * Example:
564
- *
565
- * {
566
- * rules: {
567
- * curly: ["error", "multi"]
568
- * }
569
- * }
570
- *
571
- * /* eslint curly: ["warn"] * /
572
- *
573
- * Results in:
574
- *
575
- * curly: ["warn", "multi"]
576
- */
577
- if (
578
- /*
579
- * If inline config for the rule has only severity
580
- */
581
- ruleOptions.length === 1 &&
582
- /*
583
- * And the rule was already configured
584
- */
585
- config.rules &&
586
- Object.hasOwn(config.rules, name)
587
- ) {
588
- /*
589
- * Then use severity from the inline config and options from the provided config
590
- */
591
- ruleOptions = [
592
- ruleOptions[0], // severity from the inline config
593
- ...asArray(config.rules[name]).slice(1), // options from the provided config
594
- ];
595
- }
596
-
597
- try {
598
- validator.validateRuleOptions(
599
- rule,
600
- name,
601
- ruleOptions,
602
- );
603
- } catch (err) {
604
- /*
605
- * If the rule has invalid `meta.schema`, throw the error because
606
- * this is not an invalid inline configuration but an invalid rule.
607
- */
608
- if (
609
- err.code ===
610
- "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
611
- ) {
612
- throw err;
613
- }
614
-
615
- report.addError({
616
- ruleId: name,
617
- message: err.message,
618
- loc,
619
- });
620
-
621
- // do not apply the config, if found invalid options.
622
- return;
623
- }
624
-
625
- configuredRules[name] = ruleOptions;
626
- });
627
- } else {
628
- report.addFatal({
629
- loc,
630
- message: parseResult.error.message,
631
- });
632
- }
633
-
634
- break;
635
- }
636
-
637
- // no default
638
- }
639
- });
640
-
641
- return {
642
- configuredRules,
643
- enabledGlobals,
644
- exportedVariables,
645
- disableDirectives,
646
- };
647
- }
648
-
649
- /**
650
- * Parses comments in file to extract disable directives.
651
- * @param {SourceCode} sourceCode The SourceCode object to get comments from.
652
- * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
653
- * @param {Language} language The language to use to adjust the location information
654
- * @param {FileReport} report The report to add problems to.
655
- * @returns {DisableDirective[]}
656
- * A collection of the directive comments that were found, along with any problems that occurred when parsing
657
- */
658
- function getDirectiveCommentsForFlatConfig(
659
- sourceCode,
660
- ruleMapper,
661
- language,
662
- report,
663
- ) {
664
- const disableDirectives = [];
665
-
666
- if (sourceCode.getDisableDirectives) {
667
- const { directives: directivesSources, problems: directivesProblems } =
668
- sourceCode.getDisableDirectives();
669
-
670
- if (Array.isArray(directivesProblems)) {
671
- directivesProblems.forEach(problem => report.addError(problem));
672
- }
673
-
674
- directivesSources.forEach(directive => {
675
- const directives = createDisableDirectives(
676
- directive,
677
- ruleMapper,
678
- language,
679
- sourceCode,
680
- report,
681
- );
682
-
683
- disableDirectives.push(...directives);
684
- });
685
- }
686
-
687
- return disableDirectives;
688
- }
689
-
690
- /**
691
- * Normalize ECMAScript version from the initial config
692
- * @param {Parser} parser The parser which uses this options.
693
- * @param {number} ecmaVersion ECMAScript version from the initial config
694
- * @returns {number} normalized ECMAScript version
695
- */
696
- function normalizeEcmaVersion(parser, ecmaVersion) {
697
- if (isEspree(parser)) {
698
- if (ecmaVersion === "latest") {
699
- return espree.latestEcmaVersion;
700
- }
701
- }
702
-
703
- /*
704
- * Calculate ECMAScript edition number from official year version starting with
705
- * ES2015, which corresponds with ES6 (or a difference of 2009).
706
- */
707
- return ecmaVersion >= 2015 ? ecmaVersion - 2009 : ecmaVersion;
708
- }
709
-
710
- /**
711
- * Normalize ECMAScript version from the initial config into languageOptions (year)
712
- * format.
713
- * @param {any} [ecmaVersion] ECMAScript version from the initial config
714
- * @returns {number} normalized ECMAScript version
715
- */
716
- function normalizeEcmaVersionForLanguageOptions(ecmaVersion) {
717
- switch (ecmaVersion) {
718
- case 3:
719
- return 3;
720
-
721
- // void 0 = no ecmaVersion specified so use the default
722
- case 5:
723
- case void 0:
724
- return 5;
725
-
726
- default:
727
- if (typeof ecmaVersion === "number") {
728
- return ecmaVersion >= 2015 ? ecmaVersion : ecmaVersion + 2009;
729
- }
730
- }
731
-
732
- /*
733
- * We default to the latest supported ecmaVersion for everything else.
734
- * Remember, this is for languageOptions.ecmaVersion, which sets the version
735
- * that is used for a number of processes inside of ESLint. It's normally
736
- * safe to assume people want the latest unless otherwise specified.
737
- */
738
- return LATEST_ECMA_VERSION;
739
- }
740
-
741
- const eslintEnvPattern = /\/\*\s*eslint-env\s.+?(?:\*\/|$)/gsu;
742
-
743
- /**
744
- * Checks whether or not there is a comment which has "eslint-env *" in a given text.
745
- * @param {string} text A source code text to check.
746
- * @returns {Object|null} A result of parseListConfig() with "eslint-env *" comment.
747
- */
748
- function findEslintEnv(text) {
749
- let match, retv;
750
-
751
- eslintEnvPattern.lastIndex = 0;
752
-
753
- while ((match = eslintEnvPattern.exec(text)) !== null) {
754
- if (match[0].endsWith("*/")) {
755
- retv = Object.assign(
756
- retv || {},
757
- commentParser.parseListConfig(
758
- commentParser.parseDirective(match[0].slice(2, -2)).value,
759
- ),
760
- );
761
- }
762
- }
763
-
764
- return retv;
765
- }
766
-
767
- /**
768
- * Convert "/path/to/<text>" to "<text>".
769
- * `CLIEngine#executeOnText()` method gives "/path/to/<text>" if the filename
770
- * was omitted because `configArray.extractConfig()` requires an absolute path.
771
- * But the linter should pass `<text>` to `RuleContext#filename` in that
772
- * case.
773
- * Also, code blocks can have their virtual filename. If the parent filename was
774
- * `<text>`, the virtual filename is `<text>/0_foo.js` or something like (i.e.,
775
- * it's not an absolute path).
776
- * @param {string} filename The filename to normalize.
777
- * @returns {string} The normalized filename.
778
- */
779
- function normalizeFilename(filename) {
780
- const parts = filename.split(path.sep);
781
- const index = parts.lastIndexOf("<text>");
782
-
783
- return index === -1 ? filename : parts.slice(index).join(path.sep);
784
- }
785
-
786
- /**
787
- * Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a
788
- * consistent shape.
789
- * @param {VerifyOptions} providedOptions Options
790
- * @param {Config|ConfigData} config Config.
791
- * @returns {Required<VerifyOptions> & InternalOptions} Normalized options
792
- */
793
- function normalizeVerifyOptions(providedOptions, config) {
794
- const linterOptions = config.linterOptions || config;
795
-
796
- // .noInlineConfig for eslintrc, .linterOptions.noInlineConfig for flat
797
- const disableInlineConfig = linterOptions.noInlineConfig === true;
798
- const ignoreInlineConfig = providedOptions.allowInlineConfig === false;
799
- const configNameOfNoInlineConfig = config.configNameOfNoInlineConfig
800
- ? ` (${config.configNameOfNoInlineConfig})`
801
- : "";
802
-
803
- let reportUnusedDisableDirectives =
804
- providedOptions.reportUnusedDisableDirectives;
805
-
806
- if (typeof reportUnusedDisableDirectives === "boolean") {
807
- reportUnusedDisableDirectives = reportUnusedDisableDirectives
808
- ? "error"
809
- : "off";
810
- }
811
- if (typeof reportUnusedDisableDirectives !== "string") {
812
- if (typeof linterOptions.reportUnusedDisableDirectives === "boolean") {
813
- reportUnusedDisableDirectives =
814
- linterOptions.reportUnusedDisableDirectives ? "warn" : "off";
815
- } else {
816
- reportUnusedDisableDirectives =
817
- linterOptions.reportUnusedDisableDirectives === void 0
818
- ? "off"
819
- : normalizeSeverityToString(
820
- linterOptions.reportUnusedDisableDirectives,
821
- );
822
- }
823
- }
824
-
825
- const reportUnusedInlineConfigs =
826
- linterOptions.reportUnusedInlineConfigs === void 0
827
- ? "off"
828
- : normalizeSeverityToString(
829
- linterOptions.reportUnusedInlineConfigs,
830
- );
831
-
832
- let ruleFilter = providedOptions.ruleFilter;
833
-
834
- if (typeof ruleFilter !== "function") {
835
- ruleFilter = () => true;
836
- }
837
-
838
- return {
839
- filename: normalizeFilename(providedOptions.filename || "<input>"),
840
- allowInlineConfig: !ignoreInlineConfig,
841
- warnInlineConfig:
842
- disableInlineConfig && !ignoreInlineConfig
843
- ? `your config${configNameOfNoInlineConfig}`
844
- : null,
845
- reportUnusedDisableDirectives,
846
- reportUnusedInlineConfigs,
847
- disableFixes: Boolean(providedOptions.disableFixes),
848
- stats: providedOptions.stats,
849
- ruleFilter,
850
- };
851
- }
852
-
853
- /**
854
- * Combines the provided parserOptions with the options from environments
855
- * @param {Parser} parser The parser which uses this options.
856
- * @param {ParserOptions} providedOptions The provided 'parserOptions' key in a config
857
- * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
858
- * @returns {ParserOptions} Resulting parser options after merge
859
- */
860
- function resolveParserOptions(parser, providedOptions, enabledEnvironments) {
861
- const parserOptionsFromEnv = enabledEnvironments
862
- .filter(env => env.parserOptions)
863
- .reduce(
864
- (parserOptions, env) => merge(parserOptions, env.parserOptions),
865
- {},
866
- );
867
- const mergedParserOptions = merge(
868
- parserOptionsFromEnv,
869
- providedOptions || {},
870
- );
871
- const isModule = mergedParserOptions.sourceType === "module";
872
-
873
- if (isModule) {
874
- /*
875
- * can't have global return inside of modules
876
- * TODO: espree validate parserOptions.globalReturn when sourceType is setting to module.(@aladdin-add)
877
- */
878
- mergedParserOptions.ecmaFeatures = Object.assign(
879
- {},
880
- mergedParserOptions.ecmaFeatures,
881
- { globalReturn: false },
882
- );
883
- }
884
-
885
- mergedParserOptions.ecmaVersion = normalizeEcmaVersion(
886
- parser,
887
- mergedParserOptions.ecmaVersion,
888
- );
889
-
890
- return mergedParserOptions;
891
- }
892
-
893
- /**
894
- * Converts parserOptions to languageOptions for backwards compatibility with eslintrc.
895
- * @param {ConfigData} config Config object.
896
- * @param {Object} config.globals Global variable definitions.
897
- * @param {Parser} config.parser The parser to use.
898
- * @param {ParserOptions} config.parserOptions The parserOptions to use.
899
- * @returns {JSLanguageOptions} The languageOptions equivalent.
900
- */
901
- function createLanguageOptions({
902
- globals: configuredGlobals,
903
- parser,
904
- parserOptions,
905
- }) {
906
- const { ecmaVersion, sourceType } = parserOptions;
907
-
908
- return {
909
- globals: configuredGlobals,
910
- ecmaVersion: normalizeEcmaVersionForLanguageOptions(ecmaVersion),
911
- sourceType,
912
- parser,
913
- parserOptions,
914
- };
915
- }
916
-
917
- /**
918
- * Combines the provided globals object with the globals from environments
919
- * @param {Record<string, GlobalConf>} providedGlobals The 'globals' key in a config
920
- * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
921
- * @returns {Record<string, GlobalConf>} The resolved globals object
922
- */
923
- function resolveGlobals(providedGlobals, enabledEnvironments) {
924
- return Object.assign(
925
- Object.create(null),
926
- ...enabledEnvironments
927
- .filter(env => env.globals)
928
- .map(env => env.globals),
929
- providedGlobals,
930
- );
931
- }
932
-
933
- /**
934
- * Store time measurements in map
935
- * @param {number} time Time measurement
936
- * @param {Object} timeOpts Options relating which time was measured
937
- * @param {WeakMap<Linter, LinterInternalSlots>} slots Linter internal slots map
938
- * @returns {void}
939
- */
940
- function storeTime(time, timeOpts, slots) {
941
- const { type, key } = timeOpts;
942
-
943
- if (!slots.times) {
944
- slots.times = { passes: [{}] };
945
- }
946
-
947
- const passIndex = slots.fixPasses;
948
-
949
- if (passIndex > slots.times.passes.length - 1) {
950
- slots.times.passes.push({});
951
- }
952
-
953
- if (key) {
954
- slots.times.passes[passIndex][type] ??= {};
955
- slots.times.passes[passIndex][type][key] ??= { total: 0 };
956
- slots.times.passes[passIndex][type][key].total += time;
957
- } else {
958
- slots.times.passes[passIndex][type] ??= { total: 0 };
959
- slots.times.passes[passIndex][type].total += time;
960
- }
961
- }
962
-
963
- /**
964
- * Get the options for a rule (not including severity), if any
965
- * @param {RuleConfig} ruleConfig rule configuration
966
- * @param {Object|undefined} defaultOptions rule.meta.defaultOptions
967
- * @returns {Array} of rule options, empty Array if none
968
- */
969
- function getRuleOptions(ruleConfig, defaultOptions) {
970
- if (Array.isArray(ruleConfig)) {
971
- return deepMergeArrays(defaultOptions, ruleConfig.slice(1));
972
- }
973
- return defaultOptions ?? [];
974
- }
975
-
976
- /**
977
- * Analyze scope of the given AST.
978
- * @param {ASTNode} ast The `Program` node to analyze.
979
- * @param {JSLanguageOptions} languageOptions The language options.
980
- * @param {Record<string, string[]>} visitorKeys The visitor keys.
981
- * @returns {ScopeManager} The analysis result.
982
- */
983
- function analyzeScope(ast, languageOptions, visitorKeys) {
984
- const parserOptions = languageOptions.parserOptions;
985
- const ecmaFeatures = parserOptions.ecmaFeatures || {};
986
- const ecmaVersion = languageOptions.ecmaVersion || DEFAULT_ECMA_VERSION;
987
-
988
- return eslintScope.analyze(ast, {
989
- ignoreEval: true,
990
- nodejsScope: ecmaFeatures.globalReturn,
991
- impliedStrict: ecmaFeatures.impliedStrict,
992
- ecmaVersion: typeof ecmaVersion === "number" ? ecmaVersion : 6,
993
- sourceType: languageOptions.sourceType || "script",
994
- childVisitorKeys: visitorKeys || evk.KEYS,
995
- fallback: Traverser.getKeys,
996
- });
997
- }
998
-
999
- /**
1000
- * Runs a rule, and gets its listeners
1001
- * @param {RuleDefinition} rule A rule object
1002
- * @param {Context} ruleContext The context that should be passed to the rule
1003
- * @throws {TypeError} If `rule` is not an object with a `create` method
1004
- * @throws {any} Any error during the rule's `create`
1005
- * @returns {Object} A map of selector listeners provided by the rule
1006
- */
1007
- function createRuleListeners(rule, ruleContext) {
1008
- if (
1009
- !rule ||
1010
- typeof rule !== "object" ||
1011
- typeof rule.create !== "function"
1012
- ) {
1013
- throw new TypeError(
1014
- `Error while loading rule '${ruleContext.id}': Rule must be an object with a \`create\` method`,
1015
- );
1016
- }
1017
-
1018
- try {
1019
- return rule.create(ruleContext);
1020
- } catch (ex) {
1021
- ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`;
1022
- throw ex;
1023
- }
1024
- }
1025
-
1026
- /**
1027
- * Runs the given rules on the given SourceCode object
1028
- * @param {SourceCode} sourceCode A SourceCode object for the given text
1029
- * @param {Object} configuredRules The rules configuration
1030
- * @param {function(string): RuleDefinition} ruleMapper A mapper function from rule names to rules
1031
- * @param {string | undefined} parserName The name of the parser in the config
1032
- * @param {Language} language The language object used for parsing.
1033
- * @param {LanguageOptions} languageOptions The options for parsing the code.
1034
- * @param {Object} settings The settings that were enabled in the config
1035
- * @param {string} filename The reported filename of the code
1036
- * @param {boolean} applyDefaultOptions If true, apply rules' meta.defaultOptions in computing their config options.
1037
- * @param {string | undefined} cwd cwd of the cli
1038
- * @param {string} physicalFilename The full path of the file on disk without any code block information
1039
- * @param {Function} ruleFilter A predicate function to filter which rules should be executed.
1040
- * @param {boolean} stats If true, stats are collected appended to the result
1041
- * @param {WeakMap<Linter, LinterInternalSlots>} slots InternalSlotsMap of linter
1042
- * @param {FileReport} report The report to add problems to
1043
- * @returns {FileReport} report The report with added problems
1044
- * @throws {Error} If traversal into a node fails.
1045
- */
1046
- function runRules(
1047
- sourceCode,
1048
- configuredRules,
1049
- ruleMapper,
1050
- parserName,
1051
- language,
1052
- languageOptions,
1053
- settings,
1054
- filename,
1055
- applyDefaultOptions,
1056
- cwd,
1057
- physicalFilename,
1058
- ruleFilter,
1059
- stats,
1060
- slots,
1061
- report,
1062
- ) {
1063
- const visitor = new SourceCodeVisitor();
1064
-
1065
- /*
1066
- * Create a frozen object with the ruleContext properties and methods that are shared by all rules.
1067
- * All rule contexts will inherit from this object. This avoids the performance penalty of copying all the
1068
- * properties once for each rule.
1069
- */
1070
- const fileContext = new FileContext({
1071
- cwd,
1072
- filename,
1073
- physicalFilename: physicalFilename || filename,
1074
- sourceCode,
1075
- parserOptions: {
1076
- ...languageOptions.parserOptions,
1077
- },
1078
- parserPath: parserName,
1079
- languageOptions,
1080
- settings,
1081
- });
1082
-
1083
- const steps = sourceCode.traverse();
1084
-
1085
- Object.keys(configuredRules).forEach(ruleId => {
1086
- const severity = Config.getRuleNumericSeverity(configuredRules[ruleId]);
1087
-
1088
- // not load disabled rules
1089
- if (severity === 0) {
1090
- return;
1091
- }
1092
-
1093
- if (ruleFilter && !ruleFilter({ ruleId, severity })) {
1094
- return;
1095
- }
1096
-
1097
- const rule = ruleMapper(ruleId);
1098
-
1099
- if (!rule) {
1100
- report.addError({ ruleId });
1101
- return;
1102
- }
1103
-
1104
- const ruleContext = fileContext.extend({
1105
- id: ruleId,
1106
- options: getRuleOptions(
1107
- configuredRules[ruleId],
1108
- applyDefaultOptions ? rule.meta?.defaultOptions : void 0,
1109
- ),
1110
- report(...args) {
1111
- const problem = report.addRuleMessage(
1112
- ruleId,
1113
- severity,
1114
- ...args,
1115
- );
1116
-
1117
- if (problem.fix && !(rule.meta && rule.meta.fixable)) {
1118
- throw new Error(
1119
- 'Fixable rules must set the `meta.fixable` property to "code" or "whitespace".',
1120
- );
1121
- }
1122
-
1123
- if (
1124
- problem.suggestions &&
1125
- !(rule.meta && rule.meta.hasSuggestions === true)
1126
- ) {
1127
- if (
1128
- rule.meta &&
1129
- rule.meta.docs &&
1130
- typeof rule.meta.docs.suggestion !== "undefined"
1131
- ) {
1132
- // Encourage migration from the former property name.
1133
- throw new Error(
1134
- "Rules with suggestions must set the `meta.hasSuggestions` property to `true`. `meta.docs.suggestion` is ignored by ESLint.",
1135
- );
1136
- }
1137
- throw new Error(
1138
- "Rules with suggestions must set the `meta.hasSuggestions` property to `true`.",
1139
- );
1140
- }
1141
- },
1142
- });
1143
-
1144
- const ruleListenersReturn =
1145
- timing.enabled || stats
1146
- ? timing.time(
1147
- ruleId,
1148
- createRuleListeners,
1149
- stats,
1150
- )(rule, ruleContext)
1151
- : createRuleListeners(rule, ruleContext);
1152
-
1153
- const ruleListeners = stats
1154
- ? ruleListenersReturn.result
1155
- : ruleListenersReturn;
1156
-
1157
- if (stats) {
1158
- storeTime(
1159
- ruleListenersReturn.tdiff,
1160
- { type: "rules", key: ruleId },
1161
- slots,
1162
- );
1163
- }
1164
-
1165
- /**
1166
- * Include `ruleId` in error logs
1167
- * @param {Function} ruleListener A rule method that listens for a node.
1168
- * @returns {Function} ruleListener wrapped in error handler
1169
- */
1170
- function addRuleErrorHandler(ruleListener) {
1171
- return function ruleErrorHandler(...listenerArgs) {
1172
- try {
1173
- const ruleListenerReturn = ruleListener(...listenerArgs);
1174
-
1175
- const ruleListenerResult = stats
1176
- ? ruleListenerReturn.result
1177
- : ruleListenerReturn;
1178
-
1179
- if (stats) {
1180
- storeTime(
1181
- ruleListenerReturn.tdiff,
1182
- { type: "rules", key: ruleId },
1183
- slots,
1184
- );
1185
- }
1186
-
1187
- return ruleListenerResult;
1188
- } catch (e) {
1189
- e.ruleId = ruleId;
1190
- throw e;
1191
- }
1192
- };
1193
- }
1194
-
1195
- if (typeof ruleListeners === "undefined" || ruleListeners === null) {
1196
- throw new Error(
1197
- `The create() function for rule '${ruleId}' did not return an object.`,
1198
- );
1199
- }
1200
-
1201
- // add all the selectors from the rule as listeners
1202
- Object.keys(ruleListeners).forEach(selector => {
1203
- const ruleListener =
1204
- timing.enabled || stats
1205
- ? timing.time(ruleId, ruleListeners[selector], stats)
1206
- : ruleListeners[selector];
1207
-
1208
- visitor.add(selector, addRuleErrorHandler(ruleListener));
1209
- });
1210
- });
1211
-
1212
- const traverser = SourceCodeTraverser.getInstance(language);
1213
-
1214
- traverser.traverseSync(sourceCode, visitor, { steps });
1215
-
1216
- return report;
1217
- }
1218
-
1219
- /**
1220
- * Ensure the source code to be a string.
1221
- * @param {string|SourceCode} textOrSourceCode The text or source code object.
1222
- * @returns {string} The source code text.
1223
- */
1224
- function ensureText(textOrSourceCode) {
1225
- if (typeof textOrSourceCode === "object") {
1226
- const { hasBOM, text } = textOrSourceCode;
1227
- const bom = hasBOM ? "\uFEFF" : "";
1228
-
1229
- return bom + text;
1230
- }
1231
-
1232
- return String(textOrSourceCode);
1233
- }
1234
-
1235
- /**
1236
- * Get an environment.
1237
- * @param {LinterInternalSlots} slots The internal slots of Linter.
1238
- * @param {string} envId The environment ID to get.
1239
- * @returns {Environment|null} The environment.
1240
- */
1241
- function getEnv(slots, envId) {
1242
- return (
1243
- (slots.lastConfigArray &&
1244
- slots.lastConfigArray.pluginEnvironments.get(envId)) ||
1245
- BuiltInEnvironments.get(envId) ||
1246
- null
1247
- );
1248
- }
1249
-
1250
- /**
1251
- * Get a rule.
1252
- * @param {LinterInternalSlots} slots The internal slots of Linter.
1253
- * @param {string} ruleId The rule ID to get.
1254
- * @returns {Rule|null} The rule.
1255
- */
1256
- function getRule(slots, ruleId) {
1257
- return (
1258
- (slots.lastConfigArray &&
1259
- slots.lastConfigArray.pluginRules.get(ruleId)) ||
1260
- slots.ruleMap.get(ruleId)
1261
- );
1262
- }
1263
-
1264
- /**
1265
- * Normalize the value of the cwd
1266
- * @param {string | undefined} cwd raw value of the cwd, path to a directory that should be considered as the current working directory, can be undefined.
1267
- * @returns {string | undefined} normalized cwd
1268
- */
1269
- function normalizeCwd(cwd) {
1270
- if (cwd) {
1271
- return cwd;
1272
- }
1273
- if (typeof process === "object") {
1274
- return process.cwd();
1275
- }
1276
-
1277
- // It's more explicit to assign the undefined
1278
- // eslint-disable-next-line no-undefined -- Consistently returning a value
1279
- return undefined;
1280
- }
1281
-
1282
- /**
1283
- * The map to store private data.
1284
- * @type {WeakMap<Linter, LinterInternalSlots>}
1285
- */
1286
- const internalSlotsMap = new WeakMap();
1287
-
1288
- /**
1289
- * Throws an error when the given linter is in flat config mode.
1290
- * @param {Linter} linter The linter to check.
1291
- * @returns {void}
1292
- * @throws {Error} If the linter is in flat config mode.
1293
- */
1294
- function assertEslintrcConfig(linter) {
1295
- const { configType } = internalSlotsMap.get(linter);
1296
-
1297
- if (configType === "flat") {
1298
- throw new Error(
1299
- "This method cannot be used with flat config. Add your entries directly into the config array.",
1300
- );
1301
- }
1302
- }
1303
-
1304
- //------------------------------------------------------------------------------
1305
- // Public Interface
1306
- //------------------------------------------------------------------------------
1307
-
1308
- /**
1309
- * Object that is responsible for verifying JavaScript text
1310
- * @name Linter
1311
- */
1312
- class Linter {
1313
- /**
1314
- * Initialize the Linter.
1315
- * @param {Object} [config] the config object
1316
- * @param {string} [config.cwd] path to a directory that should be considered as the current working directory, can be undefined.
1317
- * @param {Array<string>} [config.flags] the feature flags to enable.
1318
- * @param {"flat"|"eslintrc"} [config.configType="flat"] the type of config used.
1319
- * @param {WarningService} [config.warningService] The warning service to use.
1320
- */
1321
- constructor({
1322
- cwd,
1323
- configType = "flat",
1324
- flags = [],
1325
- warningService = new WarningService(),
1326
- } = {}) {
1327
- const processedFlags = [];
1328
-
1329
- flags.forEach(flag => {
1330
- if (inactiveFlags.has(flag)) {
1331
- const inactiveFlagData = inactiveFlags.get(flag);
1332
- const inactivityReason =
1333
- getInactivityReasonMessage(inactiveFlagData);
1334
- const message = `The flag '${flag}' is inactive: ${inactivityReason}`;
1335
-
1336
- if (typeof inactiveFlagData.replacedBy === "undefined") {
1337
- throw new Error(message);
1338
- }
1339
-
1340
- // if there's a replacement, enable it instead of original
1341
- if (typeof inactiveFlagData.replacedBy === "string") {
1342
- processedFlags.push(inactiveFlagData.replacedBy);
1343
- }
1344
-
1345
- warningService.emitInactiveFlagWarning(flag, message);
1346
-
1347
- return;
1348
- }
1349
-
1350
- if (!activeFlags.has(flag)) {
1351
- throw new Error(`Unknown flag '${flag}'.`);
1352
- }
1353
-
1354
- processedFlags.push(flag);
1355
- });
1356
-
1357
- internalSlotsMap.set(this, {
1358
- cwd: normalizeCwd(cwd),
1359
- flags: processedFlags,
1360
- lastConfigArray: null,
1361
- lastSourceCode: null,
1362
- lastSuppressedMessages: [],
1363
- configType, // TODO: Remove after flat config conversion
1364
- parserMap: new Map([["espree", espree]]),
1365
- ruleMap: new Rules(),
1366
- warningService,
1367
- });
1368
-
1369
- this.version = pkg.version;
1370
- }
1371
-
1372
- /**
1373
- * Getter for package version.
1374
- * @static
1375
- * @returns {string} The version from package.json.
1376
- */
1377
- static get version() {
1378
- return pkg.version;
1379
- }
1380
-
1381
- /**
1382
- * Indicates if the given feature flag is enabled for this instance.
1383
- * @param {string} flag The feature flag to check.
1384
- * @returns {boolean} `true` if the feature flag is enabled, `false` if not.
1385
- */
1386
- hasFlag(flag) {
1387
- return internalSlotsMap.get(this).flags.includes(flag);
1388
- }
1389
-
1390
- /**
1391
- * Lint using eslintrc and without processors.
1392
- * @param {VFile} file The file to lint.
1393
- * @param {ConfigData} providedConfig An ESLintConfig instance to configure everything.
1394
- * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
1395
- * @throws {Error} If during rule execution.
1396
- * @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages.
1397
- */
1398
- #eslintrcVerifyWithoutProcessors(file, providedConfig, providedOptions) {
1399
- const slots = internalSlotsMap.get(this);
1400
- const config = providedConfig || {};
1401
- const options = normalizeVerifyOptions(providedOptions, config);
1402
-
1403
- // Resolve parser.
1404
- let parserName = DEFAULT_PARSER_NAME;
1405
- let parser = espree;
1406
-
1407
- if (typeof config.parser === "object" && config.parser !== null) {
1408
- parserName = config.parser.filePath;
1409
- parser = config.parser.definition;
1410
- } else if (typeof config.parser === "string") {
1411
- if (!slots.parserMap.has(config.parser)) {
1412
- return [
1413
- {
1414
- ruleId: null,
1415
- fatal: true,
1416
- severity: 2,
1417
- message: `Configured parser '${config.parser}' was not found.`,
1418
- line: 0,
1419
- column: 0,
1420
- nodeType: null,
1421
- },
1422
- ];
1423
- }
1424
- parserName = config.parser;
1425
- parser = slots.parserMap.get(config.parser);
1426
- }
1427
-
1428
- // search and apply "eslint-env *".
1429
- const envInFile =
1430
- options.allowInlineConfig && !options.warnInlineConfig
1431
- ? findEslintEnv(file.body)
1432
- : {};
1433
- const resolvedEnvConfig = Object.assign(
1434
- { builtin: true },
1435
- config.env,
1436
- envInFile,
1437
- );
1438
- const enabledEnvs = Object.keys(resolvedEnvConfig)
1439
- .filter(envName => resolvedEnvConfig[envName])
1440
- .map(envName => getEnv(slots, envName))
1441
- .filter(env => env);
1442
-
1443
- const parserOptions = resolveParserOptions(
1444
- parser,
1445
- config.parserOptions || {},
1446
- enabledEnvs,
1447
- );
1448
- const configuredGlobals = resolveGlobals(
1449
- config.globals || {},
1450
- enabledEnvs,
1451
- );
1452
- const settings = config.settings || {};
1453
- const languageOptions = createLanguageOptions({
1454
- globals: config.globals,
1455
- parser,
1456
- parserOptions,
1457
- });
1458
-
1459
- if (!slots.lastSourceCode) {
1460
- let t;
1461
-
1462
- if (options.stats) {
1463
- t = startTime();
1464
- }
1465
-
1466
- const parserService = new ParserService();
1467
- const parseResult = parserService.parseSync(file, {
1468
- language: jslang,
1469
- languageOptions,
1470
- });
1471
-
1472
- if (options.stats) {
1473
- const time = endTime(t);
1474
- const timeOpts = { type: "parse" };
1475
-
1476
- storeTime(time, timeOpts, slots);
1477
- }
1478
-
1479
- if (!parseResult.ok) {
1480
- return parseResult.errors;
1481
- }
1482
-
1483
- slots.lastSourceCode = parseResult.sourceCode;
1484
- } else {
1485
- /*
1486
- * If the given source code object as the first argument does not have scopeManager, analyze the scope.
1487
- * This is for backward compatibility (SourceCode is frozen so it cannot rebind).
1488
- */
1489
- if (!slots.lastSourceCode.scopeManager) {
1490
- slots.lastSourceCode = new SourceCode({
1491
- text: slots.lastSourceCode.text,
1492
- ast: slots.lastSourceCode.ast,
1493
- hasBOM: slots.lastSourceCode.hasBOM,
1494
- parserServices: slots.lastSourceCode.parserServices,
1495
- visitorKeys: slots.lastSourceCode.visitorKeys,
1496
- scopeManager: analyzeScope(
1497
- slots.lastSourceCode.ast,
1498
- languageOptions,
1499
- ),
1500
- });
1501
- }
1502
- }
1503
-
1504
- const sourceCode = slots.lastSourceCode;
1505
- const report = new FileReport({
1506
- ruleMapper: ruleId => getRule(slots, ruleId),
1507
- language: jslang,
1508
- sourceCode,
1509
- disableFixes: options.disableFixes,
1510
- });
1511
-
1512
- const commentDirectives = options.allowInlineConfig
1513
- ? getDirectiveComments(
1514
- sourceCode,
1515
- ruleId => getRule(slots, ruleId),
1516
- options.warnInlineConfig,
1517
- config,
1518
- report,
1519
- )
1520
- : {
1521
- configuredRules: {},
1522
- enabledGlobals: {},
1523
- exportedVariables: {},
1524
- disableDirectives: [],
1525
- };
1526
-
1527
- addDeclaredGlobals(
1528
- sourceCode.scopeManager.scopes[0],
1529
- configuredGlobals,
1530
- {
1531
- exportedVariables: commentDirectives.exportedVariables,
1532
- enabledGlobals: commentDirectives.enabledGlobals,
1533
- },
1534
- );
1535
-
1536
- const configuredRules = Object.assign(
1537
- {},
1538
- config.rules,
1539
- commentDirectives.configuredRules,
1540
- );
1541
-
1542
- try {
1543
- runRules(
1544
- sourceCode,
1545
- configuredRules,
1546
- ruleId => getRule(slots, ruleId),
1547
- parserName,
1548
- jslang,
1549
- languageOptions,
1550
- settings,
1551
- options.filename,
1552
- true,
1553
- slots.cwd,
1554
- providedOptions.physicalFilename,
1555
- null,
1556
- options.stats,
1557
- slots,
1558
- report,
1559
- );
1560
- } catch (err) {
1561
- err.message += `\nOccurred while linting ${options.filename}`;
1562
- debug("An error occurred while traversing");
1563
- debug("Filename:", options.filename);
1564
- if (err.currentNode) {
1565
- const { line } = sourceCode.getLoc(err.currentNode).start;
1566
-
1567
- debug("Line:", line);
1568
- err.message += `:${line}`;
1569
- }
1570
- debug("Parser Options:", parserOptions);
1571
- debug("Parser Path:", parserName);
1572
- debug("Settings:", settings);
1573
-
1574
- if (err.ruleId) {
1575
- err.message += `\nRule: "${err.ruleId}"`;
1576
- }
1577
-
1578
- throw err;
1579
- }
1580
-
1581
- return applyDisableDirectives({
1582
- language: jslang,
1583
- sourceCode,
1584
- directives: commentDirectives.disableDirectives,
1585
- disableFixes: options.disableFixes,
1586
- problems: report.messages.sort(
1587
- (problemA, problemB) =>
1588
- problemA.line - problemB.line ||
1589
- problemA.column - problemB.column,
1590
- ),
1591
- reportUnusedDisableDirectives:
1592
- options.reportUnusedDisableDirectives,
1593
- });
1594
- }
1595
-
1596
- /**
1597
- * Same as linter.verify, except without support for processors.
1598
- * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
1599
- * @param {ConfigData} providedConfig An ESLintConfig instance to configure everything.
1600
- * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
1601
- * @throws {Error} If during rule execution.
1602
- * @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages.
1603
- */
1604
- _verifyWithoutProcessors(
1605
- textOrSourceCode,
1606
- providedConfig,
1607
- providedOptions,
1608
- ) {
1609
- const slots = internalSlotsMap.get(this);
1610
- const filename = normalizeFilename(
1611
- providedOptions.filename || "<input>",
1612
- );
1613
- let text;
1614
-
1615
- // evaluate arguments
1616
- if (typeof textOrSourceCode === "string") {
1617
- slots.lastSourceCode = null;
1618
- text = textOrSourceCode;
1619
- } else {
1620
- slots.lastSourceCode = textOrSourceCode;
1621
- text = textOrSourceCode.text;
1622
- }
1623
-
1624
- const file = new VFile(filename, text, {
1625
- physicalPath: providedOptions.physicalFilename,
1626
- });
1627
-
1628
- return this.#eslintrcVerifyWithoutProcessors(
1629
- file,
1630
- providedConfig,
1631
- providedOptions,
1632
- );
1633
- }
1634
-
1635
- /**
1636
- * Verifies the text against the rules specified by the second argument.
1637
- * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
1638
- * @param {ConfigData|ConfigArray} config An ESLintConfig instance to configure everything.
1639
- * @param {(string|(VerifyOptions&ProcessorOptions))} [filenameOrOptions] The optional filename of the file being checked.
1640
- * If this is not set, the filename will default to '<input>' in the rule context. If
1641
- * an object, then it has "filename", "allowInlineConfig", and some properties.
1642
- * @returns {LintMessage[]} The results as an array of messages or an empty array if no messages.
1643
- */
1644
- verify(textOrSourceCode, config, filenameOrOptions) {
1645
- debug("Verify");
1646
-
1647
- const { configType, cwd } = internalSlotsMap.get(this);
1648
-
1649
- const options =
1650
- typeof filenameOrOptions === "string"
1651
- ? { filename: filenameOrOptions }
1652
- : filenameOrOptions || {};
1653
-
1654
- const configToUse = config ?? {};
1655
-
1656
- if (configType !== "eslintrc") {
1657
- /*
1658
- * Because of how Webpack packages up the files, we can't
1659
- * compare directly to `FlatConfigArray` using `instanceof`
1660
- * because it's not the same `FlatConfigArray` as in the tests.
1661
- * So, we work around it by assuming an array is, in fact, a
1662
- * `FlatConfigArray` if it has a `getConfig()` method.
1663
- */
1664
- let configArray = configToUse;
1665
-
1666
- if (
1667
- !Array.isArray(configToUse) ||
1668
- typeof configToUse.getConfig !== "function"
1669
- ) {
1670
- configArray = new FlatConfigArray(configToUse, {
1671
- basePath: cwd,
1672
- });
1673
- configArray.normalizeSync();
1674
- }
1675
-
1676
- return this._distinguishSuppressedMessages(
1677
- this._verifyWithFlatConfigArray(
1678
- textOrSourceCode,
1679
- configArray,
1680
- options,
1681
- true,
1682
- ),
1683
- );
1684
- }
1685
-
1686
- if (typeof configToUse.extractConfig === "function") {
1687
- return this._distinguishSuppressedMessages(
1688
- this._verifyWithConfigArray(
1689
- textOrSourceCode,
1690
- configToUse,
1691
- options,
1692
- ),
1693
- );
1694
- }
1695
-
1696
- /*
1697
- * If we get to here, it means `config` is just an object rather
1698
- * than a config array so we can go right into linting.
1699
- */
1700
-
1701
- /*
1702
- * `Linter` doesn't support `overrides` property in configuration.
1703
- * So we cannot apply multiple processors.
1704
- */
1705
- if (options.preprocess || options.postprocess) {
1706
- return this._distinguishSuppressedMessages(
1707
- this._verifyWithProcessor(
1708
- textOrSourceCode,
1709
- configToUse,
1710
- options,
1711
- ),
1712
- );
1713
- }
1714
- return this._distinguishSuppressedMessages(
1715
- this._verifyWithoutProcessors(
1716
- textOrSourceCode,
1717
- configToUse,
1718
- options,
1719
- ),
1720
- );
1721
- }
1722
-
1723
- /**
1724
- * Verify with a processor.
1725
- * @param {string|SourceCode} textOrSourceCode The source code.
1726
- * @param {Config} config The config array.
1727
- * @param {VerifyOptions&ProcessorOptions} options The options.
1728
- * @param {FlatConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively.
1729
- * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems.
1730
- */
1731
- _verifyWithFlatConfigArrayAndProcessor(
1732
- textOrSourceCode,
1733
- config,
1734
- options,
1735
- configForRecursive,
1736
- ) {
1737
- const slots = internalSlotsMap.get(this);
1738
- const filename = options.filename || "<input>";
1739
- const filenameToExpose = normalizeFilename(filename);
1740
- const physicalFilename = options.physicalFilename || filenameToExpose;
1741
- const text = ensureText(textOrSourceCode);
1742
- const file = new VFile(filenameToExpose, text, {
1743
- physicalPath: physicalFilename,
1744
- });
1745
-
1746
- const preprocess = options.preprocess || (rawText => [rawText]);
1747
- const postprocess =
1748
- options.postprocess || (messagesList => messagesList.flat());
1749
-
1750
- const processorService = new ProcessorService();
1751
- const preprocessResult = processorService.preprocessSync(file, {
1752
- processor: {
1753
- preprocess,
1754
- postprocess,
1755
- },
1756
- });
1757
-
1758
- if (!preprocessResult.ok) {
1759
- return preprocessResult.errors;
1760
- }
1761
-
1762
- const filterCodeBlock =
1763
- options.filterCodeBlock ||
1764
- (blockFilename => blockFilename.endsWith(".js"));
1765
- const originalExtname = path.extname(filename);
1766
- const { files } = preprocessResult;
1767
-
1768
- const messageLists = files.map(block => {
1769
- debug("A code block was found: %o", block.path || "(unnamed)");
1770
-
1771
- // Keep the legacy behavior.
1772
- if (typeof block === "string") {
1773
- return this._verifyWithFlatConfigArrayAndWithoutProcessors(
1774
- block,
1775
- config,
1776
- options,
1777
- );
1778
- }
1779
-
1780
- // Skip this block if filtered.
1781
- if (!filterCodeBlock(block.path, block.body)) {
1782
- debug("This code block was skipped.");
1783
- return [];
1784
- }
1785
-
1786
- // Resolve configuration again if the file content or extension was changed.
1787
- if (
1788
- configForRecursive &&
1789
- (text !== block.rawBody ||
1790
- path.extname(block.path) !== originalExtname)
1791
- ) {
1792
- debug(
1793
- "Resolving configuration again because the file content or extension was changed.",
1794
- );
1795
- return this._verifyWithFlatConfigArray(
1796
- block.rawBody,
1797
- configForRecursive,
1798
- {
1799
- ...options,
1800
- filename: block.path,
1801
- physicalFilename: block.physicalPath,
1802
- },
1803
- );
1804
- }
1805
-
1806
- slots.lastSourceCode = null;
1807
-
1808
- // Does lint.
1809
- return this.#flatVerifyWithoutProcessors(block, config, {
1810
- ...options,
1811
- filename: block.path,
1812
- physicalFilename: block.physicalPath,
1813
- });
1814
- });
1815
-
1816
- return processorService.postprocessSync(file, messageLists, {
1817
- processor: {
1818
- preprocess,
1819
- postprocess,
1820
- },
1821
- });
1822
- }
1823
-
1824
- /**
1825
- * Verify using flat config and without any processors.
1826
- * @param {VFile} file The file to lint.
1827
- * @param {Config} providedConfig An ESLintConfig instance to configure everything.
1828
- * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
1829
- * @throws {Error} If during rule execution.
1830
- * @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages.
1831
- */
1832
- #flatVerifyWithoutProcessors(file, providedConfig, providedOptions) {
1833
- const slots = internalSlotsMap.get(this);
1834
- const config = providedConfig || {};
1835
- const { settings = {}, languageOptions } = config;
1836
- const options = normalizeVerifyOptions(providedOptions, config);
1837
-
1838
- if (!slots.lastSourceCode) {
1839
- let t;
1840
-
1841
- if (options.stats) {
1842
- t = startTime();
1843
- }
1844
-
1845
- const parserService = new ParserService();
1846
- const parseResult = parserService.parseSync(file, config);
1847
-
1848
- if (options.stats) {
1849
- const time = endTime(t);
1850
-
1851
- storeTime(time, { type: "parse" }, slots);
1852
- }
1853
-
1854
- if (!parseResult.ok) {
1855
- return parseResult.errors;
1856
- }
1857
-
1858
- slots.lastSourceCode = parseResult.sourceCode;
1859
- } else {
1860
- /*
1861
- * If the given source code object as the first argument does not have scopeManager, analyze the scope.
1862
- * This is for backward compatibility (SourceCode is frozen so it cannot rebind).
1863
- *
1864
- * We check explicitly for `null` to ensure that this is a JS-flavored language.
1865
- * For non-JS languages we don't want to do this.
1866
- *
1867
- * TODO: Remove this check when we stop exporting the `SourceCode` object.
1868
- */
1869
- if (slots.lastSourceCode.scopeManager === null) {
1870
- slots.lastSourceCode = new SourceCode({
1871
- text: slots.lastSourceCode.text,
1872
- ast: slots.lastSourceCode.ast,
1873
- hasBOM: slots.lastSourceCode.hasBOM,
1874
- parserServices: slots.lastSourceCode.parserServices,
1875
- visitorKeys: slots.lastSourceCode.visitorKeys,
1876
- scopeManager: analyzeScope(
1877
- slots.lastSourceCode.ast,
1878
- languageOptions,
1879
- ),
1880
- });
1881
- }
1882
- }
1883
-
1884
- const sourceCode = slots.lastSourceCode;
1885
- const report = new FileReport({
1886
- ruleMapper: ruleId => config.getRuleDefinition(ruleId),
1887
- language: config.language,
1888
- sourceCode,
1889
- disableFixes: options.disableFixes,
1890
- });
1891
-
1892
- /*
1893
- * Make adjustments based on the language options. For JavaScript,
1894
- * this is primarily about adding variables into the global scope
1895
- * to account for ecmaVersion and configured globals.
1896
- */
1897
- sourceCode.applyLanguageOptions?.(languageOptions);
1898
-
1899
- const mergedInlineConfig = {
1900
- rules: {},
1901
- };
1902
-
1903
- /*
1904
- * Inline config can be either enabled or disabled. If disabled, it's possible
1905
- * to detect the inline config and emit a warning (though this is not required).
1906
- * So we first check to see if inline config is allowed at all, and if so, we
1907
- * need to check if it's a warning or not.
1908
- */
1909
- if (options.allowInlineConfig) {
1910
- // if inline config should warn then add the warnings
1911
- if (options.warnInlineConfig) {
1912
- if (sourceCode.getInlineConfigNodes) {
1913
- sourceCode.getInlineConfigNodes().forEach(node => {
1914
- const loc = sourceCode.getLoc(node);
1915
- const range = sourceCode.getRange(node);
1916
-
1917
- report.addWarning({
1918
- message: `'${sourceCode.text.slice(range[0], range[1])}' has no effect because you have 'noInlineConfig' setting in ${options.warnInlineConfig}.`,
1919
- loc,
1920
- });
1921
- });
1922
- }
1923
- } else {
1924
- if (config.language === jslang) {
1925
- for (const comment of sourceCode.getInlineConfigNodes()) {
1926
- const { label } = commentParser.parseDirective(
1927
- comment.value,
1928
- );
1929
- if (label === "eslint-env") {
1930
- slots.warningService.emitESLintEnvWarning(
1931
- options.filename,
1932
- comment.loc.start.line,
1933
- );
1934
- }
1935
- }
1936
- }
1937
-
1938
- const inlineConfigResult = sourceCode.applyInlineConfig?.();
1939
-
1940
- if (inlineConfigResult) {
1941
- inlineConfigResult.problems.forEach(problem => {
1942
- report.addFatal(problem);
1943
- });
1944
-
1945
- for (const {
1946
- config: inlineConfig,
1947
- loc,
1948
- } of inlineConfigResult.configs) {
1949
- Object.keys(inlineConfig.rules).forEach(ruleId => {
1950
- const rule = config.getRuleDefinition(ruleId);
1951
- const ruleValue = inlineConfig.rules[ruleId];
1952
-
1953
- if (!rule) {
1954
- report.addError({
1955
- ruleId,
1956
- loc,
1957
- });
1958
- return;
1959
- }
1960
-
1961
- if (
1962
- Object.hasOwn(mergedInlineConfig.rules, ruleId)
1963
- ) {
1964
- report.addError({
1965
- message: `Rule "${ruleId}" is already configured by another configuration comment in the preceding code. This configuration is ignored.`,
1966
- loc,
1967
- });
1968
- return;
1969
- }
1970
-
1971
- try {
1972
- const ruleOptionsInline = asArray(ruleValue);
1973
- let ruleOptions = ruleOptionsInline;
1974
-
1975
- assertIsRuleSeverity(ruleId, ruleOptions[0]);
1976
-
1977
- /*
1978
- * If the rule was already configured, inline rule configuration that
1979
- * only has severity should retain options from the config and just override the severity.
1980
- *
1981
- * Example:
1982
- *
1983
- * {
1984
- * rules: {
1985
- * curly: ["error", "multi"]
1986
- * }
1987
- * }
1988
- *
1989
- * /* eslint curly: ["warn"] * /
1990
- *
1991
- * Results in:
1992
- *
1993
- * curly: ["warn", "multi"]
1994
- */
1995
-
1996
- let shouldValidateOptions = true;
1997
-
1998
- if (
1999
- /*
2000
- * If inline config for the rule has only severity
2001
- */
2002
- ruleOptions.length === 1 &&
2003
- /*
2004
- * And the rule was already configured
2005
- */
2006
- config.rules &&
2007
- Object.hasOwn(config.rules, ruleId)
2008
- ) {
2009
- /*
2010
- * Then use severity from the inline config and options from the provided config
2011
- */
2012
- ruleOptions = [
2013
- ruleOptions[0], // severity from the inline config
2014
- ...config.rules[ruleId].slice(1), // options from the provided config
2015
- ];
2016
-
2017
- // if the rule was enabled, the options have already been validated
2018
- if (config.rules[ruleId][0] > 0) {
2019
- shouldValidateOptions = false;
2020
- }
2021
- } else {
2022
- /**
2023
- * Since we know the user provided options, apply defaults on top of them
2024
- */
2025
- const slicedOptions = ruleOptions.slice(1);
2026
- const mergedOptions = deepMergeArrays(
2027
- rule.meta?.defaultOptions,
2028
- slicedOptions,
2029
- );
2030
-
2031
- if (mergedOptions.length) {
2032
- ruleOptions = [
2033
- ruleOptions[0],
2034
- ...mergedOptions,
2035
- ];
2036
- }
2037
- }
2038
-
2039
- if (
2040
- options.reportUnusedInlineConfigs !== "off"
2041
- ) {
2042
- addProblemIfSameSeverityAndOptions(
2043
- config,
2044
- loc,
2045
- report,
2046
- ruleId,
2047
- ruleOptions,
2048
- ruleOptionsInline,
2049
- options.reportUnusedInlineConfigs,
2050
- );
2051
- }
2052
-
2053
- if (shouldValidateOptions) {
2054
- config.validateRulesConfig({
2055
- [ruleId]: ruleOptions,
2056
- });
2057
- }
2058
-
2059
- mergedInlineConfig.rules[ruleId] = ruleOptions;
2060
- } catch (err) {
2061
- /*
2062
- * If the rule has invalid `meta.schema`, throw the error because
2063
- * this is not an invalid inline configuration but an invalid rule.
2064
- */
2065
- if (
2066
- err.code ===
2067
- "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
2068
- ) {
2069
- throw err;
2070
- }
2071
-
2072
- let baseMessage = err.message
2073
- .slice(
2074
- err.message.startsWith('Key "rules":')
2075
- ? err.message.indexOf(":", 12) + 1
2076
- : err.message.indexOf(":") + 1,
2077
- )
2078
- .trim();
2079
-
2080
- if (err.messageTemplate) {
2081
- baseMessage += ` You passed "${ruleValue}".`;
2082
- }
2083
-
2084
- report.addError({
2085
- ruleId,
2086
- message: `Inline configuration for rule "${ruleId}" is invalid:\n\t${baseMessage}\n`,
2087
- loc,
2088
- });
2089
- }
2090
- });
2091
- }
2092
- }
2093
- }
2094
- }
2095
-
2096
- const commentDirectives =
2097
- options.allowInlineConfig && !options.warnInlineConfig
2098
- ? getDirectiveCommentsForFlatConfig(
2099
- sourceCode,
2100
- ruleId => config.getRuleDefinition(ruleId),
2101
- config.language,
2102
- report,
2103
- )
2104
- : [];
2105
-
2106
- const configuredRules = Object.assign(
2107
- {},
2108
- config.rules,
2109
- mergedInlineConfig.rules,
2110
- );
2111
-
2112
- sourceCode.finalize?.();
2113
-
2114
- try {
2115
- runRules(
2116
- sourceCode,
2117
- configuredRules,
2118
- ruleId => config.getRuleDefinition(ruleId),
2119
- void 0,
2120
- config.language,
2121
- languageOptions,
2122
- settings,
2123
- options.filename,
2124
- false,
2125
- slots.cwd,
2126
- providedOptions.physicalFilename,
2127
- options.ruleFilter,
2128
- options.stats,
2129
- slots,
2130
- report,
2131
- );
2132
- } catch (err) {
2133
- err.message += `\nOccurred while linting ${options.filename}`;
2134
- debug("An error occurred while traversing");
2135
- debug("Filename:", options.filename);
2136
- if (err.currentNode) {
2137
- const { line } = sourceCode.getLoc(err.currentNode).start;
2138
-
2139
- debug("Line:", line);
2140
- err.message += `:${line}`;
2141
- }
2142
- debug("Parser Options:", languageOptions.parserOptions);
2143
-
2144
- // debug("Parser Path:", parserName);
2145
- debug("Settings:", settings);
2146
-
2147
- if (err.ruleId) {
2148
- err.message += `\nRule: "${err.ruleId}"`;
2149
- }
2150
-
2151
- throw err;
2152
- }
2153
-
2154
- return applyDisableDirectives({
2155
- language: config.language,
2156
- sourceCode,
2157
- directives: commentDirectives,
2158
- disableFixes: options.disableFixes,
2159
- problems: report.messages.sort(
2160
- (problemA, problemB) =>
2161
- problemA.line - problemB.line ||
2162
- problemA.column - problemB.column,
2163
- ),
2164
- reportUnusedDisableDirectives:
2165
- options.reportUnusedDisableDirectives,
2166
- ruleFilter: options.ruleFilter,
2167
- configuredRules,
2168
- });
2169
- }
2170
-
2171
- /**
2172
- * Same as linter.verify, except without support for processors.
2173
- * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
2174
- * @param {Config} providedConfig An ESLintConfig instance to configure everything.
2175
- * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
2176
- * @throws {Error} If during rule execution.
2177
- * @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages.
2178
- */
2179
- _verifyWithFlatConfigArrayAndWithoutProcessors(
2180
- textOrSourceCode,
2181
- providedConfig,
2182
- providedOptions,
2183
- ) {
2184
- const slots = internalSlotsMap.get(this);
2185
- const filename = normalizeFilename(
2186
- providedOptions.filename || "<input>",
2187
- );
2188
- let text;
2189
-
2190
- // evaluate arguments
2191
- if (typeof textOrSourceCode === "string") {
2192
- slots.lastSourceCode = null;
2193
- text = textOrSourceCode;
2194
- } else {
2195
- slots.lastSourceCode = textOrSourceCode;
2196
- text = textOrSourceCode.text;
2197
- }
2198
-
2199
- const file = new VFile(filename, text, {
2200
- physicalPath: providedOptions.physicalFilename,
2201
- });
2202
-
2203
- return this.#flatVerifyWithoutProcessors(
2204
- file,
2205
- providedConfig,
2206
- providedOptions,
2207
- );
2208
- }
2209
-
2210
- /**
2211
- * Verify a given code with `ConfigArray`.
2212
- * @param {string|SourceCode} textOrSourceCode The source code.
2213
- * @param {ConfigArray} configArray The config array.
2214
- * @param {VerifyOptions&ProcessorOptions} options The options.
2215
- * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems.
2216
- */
2217
- _verifyWithConfigArray(textOrSourceCode, configArray, options) {
2218
- debug("With ConfigArray: %s", options.filename);
2219
-
2220
- // Store the config array in order to get plugin envs and rules later.
2221
- internalSlotsMap.get(this).lastConfigArray = configArray;
2222
-
2223
- // Extract the final config for this file.
2224
- const config = configArray.extractConfig(options.filename);
2225
- const processor =
2226
- config.processor &&
2227
- configArray.pluginProcessors.get(config.processor);
2228
-
2229
- // Verify.
2230
- if (processor) {
2231
- debug("Apply the processor: %o", config.processor);
2232
- const { preprocess, postprocess, supportsAutofix } = processor;
2233
- const disableFixes = options.disableFixes || !supportsAutofix;
2234
-
2235
- return this._verifyWithProcessor(
2236
- textOrSourceCode,
2237
- config,
2238
- { ...options, disableFixes, postprocess, preprocess },
2239
- configArray,
2240
- );
2241
- }
2242
- return this._verifyWithoutProcessors(textOrSourceCode, config, options);
2243
- }
2244
-
2245
- /**
2246
- * Verify a given code with a flat config.
2247
- * @param {string|SourceCode} textOrSourceCode The source code.
2248
- * @param {FlatConfigArray} configArray The config array.
2249
- * @param {VerifyOptions&ProcessorOptions} options The options.
2250
- * @param {boolean} [firstCall=false] Indicates if this is being called directly
2251
- * from verify(). (TODO: Remove once eslintrc is removed.)
2252
- * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems.
2253
- */
2254
- _verifyWithFlatConfigArray(
2255
- textOrSourceCode,
2256
- configArray,
2257
- options,
2258
- firstCall = false,
2259
- ) {
2260
- debug("With flat config: %s", options.filename);
2261
-
2262
- // we need a filename to match configs against
2263
- const filename = options.filename || "__placeholder__.js";
2264
-
2265
- // Store the config array in order to get plugin envs and rules later.
2266
- internalSlotsMap.get(this).lastConfigArray = configArray;
2267
- const config = configArray.getConfig(filename);
2268
-
2269
- if (!config) {
2270
- return [
2271
- {
2272
- ruleId: null,
2273
- severity: 1,
2274
- message: `No matching configuration found for ${filename}.`,
2275
- line: 0,
2276
- column: 0,
2277
- nodeType: null,
2278
- },
2279
- ];
2280
- }
2281
-
2282
- // Verify.
2283
- if (config.processor) {
2284
- debug("Apply the processor: %o", config.processor);
2285
- const { preprocess, postprocess, supportsAutofix } =
2286
- config.processor;
2287
- const disableFixes = options.disableFixes || !supportsAutofix;
2288
-
2289
- return this._verifyWithFlatConfigArrayAndProcessor(
2290
- textOrSourceCode,
2291
- config,
2292
- { ...options, filename, disableFixes, postprocess, preprocess },
2293
- configArray,
2294
- );
2295
- }
2296
-
2297
- // check for options-based processing
2298
- if (firstCall && (options.preprocess || options.postprocess)) {
2299
- return this._verifyWithFlatConfigArrayAndProcessor(
2300
- textOrSourceCode,
2301
- config,
2302
- options,
2303
- );
2304
- }
2305
-
2306
- return this._verifyWithFlatConfigArrayAndWithoutProcessors(
2307
- textOrSourceCode,
2308
- config,
2309
- options,
2310
- );
2311
- }
2312
-
2313
- /**
2314
- * Verify with a processor.
2315
- * @param {string|SourceCode} textOrSourceCode The source code.
2316
- * @param {ConfigData|ExtractedConfig} config The config array.
2317
- * @param {VerifyOptions&ProcessorOptions} options The options.
2318
- * @param {ConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively.
2319
- * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems.
2320
- */
2321
- _verifyWithProcessor(
2322
- textOrSourceCode,
2323
- config,
2324
- options,
2325
- configForRecursive,
2326
- ) {
2327
- const slots = internalSlotsMap.get(this);
2328
- const filename = options.filename || "<input>";
2329
- const filenameToExpose = normalizeFilename(filename);
2330
- const physicalFilename = options.physicalFilename || filenameToExpose;
2331
- const text = ensureText(textOrSourceCode);
2332
- const file = new VFile(filenameToExpose, text, {
2333
- physicalPath: physicalFilename,
2334
- });
2335
-
2336
- const preprocess = options.preprocess || (rawText => [rawText]);
2337
- const postprocess =
2338
- options.postprocess || (messagesList => messagesList.flat());
2339
-
2340
- const processorService = new ProcessorService();
2341
- const preprocessResult = processorService.preprocessSync(file, {
2342
- processor: {
2343
- preprocess,
2344
- postprocess,
2345
- },
2346
- });
2347
-
2348
- if (!preprocessResult.ok) {
2349
- return preprocessResult.errors;
2350
- }
2351
-
2352
- const filterCodeBlock =
2353
- options.filterCodeBlock ||
2354
- (blockFilePath => blockFilePath.endsWith(".js"));
2355
- const originalExtname = path.extname(filename);
2356
-
2357
- const { files } = preprocessResult;
2358
-
2359
- const messageLists = files.map(block => {
2360
- debug("A code block was found: %o", block.path ?? "(unnamed)");
2361
-
2362
- // Keep the legacy behavior.
2363
- if (typeof block === "string") {
2364
- return this._verifyWithoutProcessors(block, config, options);
2365
- }
2366
-
2367
- // Skip this block if filtered.
2368
- if (!filterCodeBlock(block.path, block.body)) {
2369
- debug("This code block was skipped.");
2370
- return [];
2371
- }
2372
-
2373
- // Resolve configuration again if the file content or extension was changed.
2374
- if (
2375
- configForRecursive &&
2376
- (text !== block.rawBody ||
2377
- path.extname(block.path) !== originalExtname)
2378
- ) {
2379
- debug(
2380
- "Resolving configuration again because the file content or extension was changed.",
2381
- );
2382
- return this._verifyWithConfigArray(
2383
- block.rawBody,
2384
- configForRecursive,
2385
- {
2386
- ...options,
2387
- filename: block.path,
2388
- physicalFilename: block.physicalPath,
2389
- },
2390
- );
2391
- }
2392
-
2393
- slots.lastSourceCode = null;
2394
-
2395
- // Does lint.
2396
- return this.#eslintrcVerifyWithoutProcessors(block, config, {
2397
- ...options,
2398
- filename: block.path,
2399
- physicalFilename: block.physicalPath,
2400
- });
2401
- });
2402
-
2403
- return processorService.postprocessSync(file, messageLists, {
2404
- processor: {
2405
- preprocess,
2406
- postprocess,
2407
- },
2408
- });
2409
- }
2410
-
2411
- /**
2412
- * Given a list of reported problems, distinguish problems between normal messages and suppressed messages.
2413
- * The normal messages will be returned and the suppressed messages will be stored as lastSuppressedMessages.
2414
- * @param {Array<LintMessage|SuppressedLintMessage>} problems A list of reported problems.
2415
- * @returns {LintMessage[]} A list of LintMessage.
2416
- */
2417
- _distinguishSuppressedMessages(problems) {
2418
- const messages = [];
2419
- const suppressedMessages = [];
2420
- const slots = internalSlotsMap.get(this);
2421
-
2422
- for (const problem of problems) {
2423
- if (problem.suppressions) {
2424
- suppressedMessages.push(problem);
2425
- } else {
2426
- messages.push(problem);
2427
- }
2428
- }
2429
-
2430
- slots.lastSuppressedMessages = suppressedMessages;
2431
-
2432
- return messages;
2433
- }
2434
-
2435
- /**
2436
- * Gets the SourceCode object representing the parsed source.
2437
- * @returns {SourceCode} The SourceCode object.
2438
- */
2439
- getSourceCode() {
2440
- return internalSlotsMap.get(this).lastSourceCode;
2441
- }
2442
-
2443
- /**
2444
- * Gets the times spent on (parsing, fixing, linting) a file.
2445
- * @returns {{ passes: TimePass[]; }} The times.
2446
- */
2447
- getTimes() {
2448
- return internalSlotsMap.get(this).times ?? { passes: [] };
2449
- }
2450
-
2451
- /**
2452
- * Gets the number of autofix passes that were made in the last run.
2453
- * @returns {number} The number of autofix passes.
2454
- */
2455
- getFixPassCount() {
2456
- return internalSlotsMap.get(this).fixPasses ?? 0;
2457
- }
2458
-
2459
- /**
2460
- * Gets the list of SuppressedLintMessage produced in the last running.
2461
- * @returns {SuppressedLintMessage[]} The list of SuppressedLintMessage
2462
- */
2463
- getSuppressedMessages() {
2464
- return internalSlotsMap.get(this).lastSuppressedMessages;
2465
- }
2466
-
2467
- /**
2468
- * Defines a new linting rule.
2469
- * @param {string} ruleId A unique rule identifier
2470
- * @param {Rule} rule A rule object
2471
- * @returns {void}
2472
- */
2473
- defineRule(ruleId, rule) {
2474
- assertEslintrcConfig(this);
2475
- internalSlotsMap.get(this).ruleMap.define(ruleId, rule);
2476
- }
2477
-
2478
- /**
2479
- * Defines many new linting rules.
2480
- * @param {Record<string, Rule>} rulesToDefine map from unique rule identifier to rule
2481
- * @returns {void}
2482
- */
2483
- defineRules(rulesToDefine) {
2484
- assertEslintrcConfig(this);
2485
- Object.getOwnPropertyNames(rulesToDefine).forEach(ruleId => {
2486
- this.defineRule(ruleId, rulesToDefine[ruleId]);
2487
- });
2488
- }
2489
-
2490
- /**
2491
- * Gets an object with all loaded rules.
2492
- * @returns {Map<string, Rule>} All loaded rules
2493
- */
2494
- getRules() {
2495
- assertEslintrcConfig(this);
2496
- const { lastConfigArray, ruleMap } = internalSlotsMap.get(this);
2497
-
2498
- return new Map(
2499
- (function* () {
2500
- yield* ruleMap;
2501
-
2502
- if (lastConfigArray) {
2503
- yield* lastConfigArray.pluginRules;
2504
- }
2505
- })(),
2506
- );
2507
- }
2508
-
2509
- /**
2510
- * Define a new parser module
2511
- * @param {string} parserId Name of the parser
2512
- * @param {Parser} parserModule The parser object
2513
- * @returns {void}
2514
- */
2515
- defineParser(parserId, parserModule) {
2516
- assertEslintrcConfig(this);
2517
- internalSlotsMap.get(this).parserMap.set(parserId, parserModule);
2518
- }
2519
-
2520
- /**
2521
- * Performs multiple autofix passes over the text until as many fixes as possible
2522
- * have been applied.
2523
- * @param {string} text The source text to apply fixes to.
2524
- * @param {ConfigData|ConfigArray|FlatConfigArray} config The ESLint config object to use.
2525
- * @param {VerifyOptions&ProcessorOptions&FixOptions} options The ESLint options object to use.
2526
- * @returns {{fixed:boolean,messages:LintMessage[],output:string}} The result of the fix operation as returned from the
2527
- * SourceCodeFixer.
2528
- */
2529
- verifyAndFix(text, config, options) {
2530
- let messages,
2531
- fixedResult,
2532
- fixed = false,
2533
- passNumber = 0,
2534
- currentText = text,
2535
- secondPreviousText,
2536
- previousText;
2537
- const debugTextDescription =
2538
- (options && options.filename) || `${text.slice(0, 10)}...`;
2539
- const shouldFix =
2540
- options && typeof options.fix !== "undefined" ? options.fix : true;
2541
- const stats = options?.stats;
2542
-
2543
- const slots = internalSlotsMap.get(this);
2544
-
2545
- // Remove lint times from the last run.
2546
- if (stats) {
2547
- delete slots.times;
2548
- slots.fixPasses = 0;
2549
- }
2550
-
2551
- /**
2552
- * This loop continues until one of the following is true:
2553
- *
2554
- * 1. No more fixes have been applied.
2555
- * 2. Ten passes have been made.
2556
- *
2557
- * That means anytime a fix is successfully applied, there will be another pass.
2558
- * Essentially, guaranteeing a minimum of two passes.
2559
- */
2560
- do {
2561
- passNumber++;
2562
- let tTotal;
2563
-
2564
- if (stats) {
2565
- tTotal = startTime();
2566
- }
2567
-
2568
- debug(
2569
- `Linting code for ${debugTextDescription} (pass ${passNumber})`,
2570
- );
2571
- messages = this.verify(currentText, config, options);
2572
-
2573
- debug(
2574
- `Generating fixed text for ${debugTextDescription} (pass ${passNumber})`,
2575
- );
2576
- let t;
2577
-
2578
- if (stats) {
2579
- t = startTime();
2580
- }
2581
-
2582
- fixedResult = SourceCodeFixer.applyFixes(
2583
- currentText,
2584
- messages,
2585
- shouldFix,
2586
- );
2587
-
2588
- if (stats) {
2589
- if (fixedResult.fixed) {
2590
- const time = endTime(t);
2591
-
2592
- storeTime(time, { type: "fix" }, slots);
2593
- slots.fixPasses++;
2594
- } else {
2595
- storeTime(0, { type: "fix" }, slots);
2596
- }
2597
- }
2598
-
2599
- /*
2600
- * stop if there are any syntax errors.
2601
- * 'fixedResult.output' is a empty string.
2602
- */
2603
- if (messages.length === 1 && messages[0].fatal) {
2604
- break;
2605
- }
2606
-
2607
- // keep track if any fixes were ever applied - important for return value
2608
- fixed = fixed || fixedResult.fixed;
2609
-
2610
- // update to use the fixed output instead of the original text
2611
- secondPreviousText = previousText;
2612
- previousText = currentText;
2613
- currentText = fixedResult.output;
2614
-
2615
- if (stats) {
2616
- tTotal = endTime(tTotal);
2617
- const passIndex = slots.times.passes.length - 1;
2618
-
2619
- slots.times.passes[passIndex].total = tTotal;
2620
- }
2621
-
2622
- // Stop if we've made a circular fix
2623
- if (
2624
- passNumber > 1 &&
2625
- currentText.length === secondPreviousText.length &&
2626
- currentText === secondPreviousText
2627
- ) {
2628
- debug(
2629
- `Circular fixes detected after pass ${passNumber}. Exiting fix loop.`,
2630
- );
2631
- slots.warningService.emitCircularFixesWarning(
2632
- options?.filename ?? "text",
2633
- );
2634
- break;
2635
- }
2636
- } while (fixedResult.fixed && passNumber < MAX_AUTOFIX_PASSES);
2637
-
2638
- /*
2639
- * If the last result had fixes, we need to lint again to be sure we have
2640
- * the most up-to-date information.
2641
- */
2642
- if (fixedResult.fixed) {
2643
- let tTotal;
2644
-
2645
- if (stats) {
2646
- tTotal = startTime();
2647
- }
2648
-
2649
- fixedResult.messages = this.verify(currentText, config, options);
2650
-
2651
- if (stats) {
2652
- storeTime(0, { type: "fix" }, slots);
2653
- slots.times.passes.at(-1).total = endTime(tTotal);
2654
- }
2655
- }
2656
-
2657
- // ensure the last result properly reflects if fixes were done
2658
- fixedResult.fixed = fixed;
2659
- fixedResult.output = currentText;
2660
-
2661
- return fixedResult;
2662
- }
2663
- }
2664
-
2665
- module.exports = {
2666
- Linter,
2667
-
2668
- /**
2669
- * Get the internal slots of a given Linter instance for tests.
2670
- * @param {Linter} instance The Linter instance to get.
2671
- * @returns {LinterInternalSlots} The internal slots.
2672
- */
2673
- getLinterInternalSlots(instance) {
2674
- return internalSlotsMap.get(instance);
2675
- },
2676
- };