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