@alexlit/lint-kit 126.6.0 → 126.7.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 (597) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/node_modules/ajv/.tonic_example.js +20 -0
  3. package/packages/config-eslint/node_modules/ajv/LICENSE +22 -0
  4. package/packages/config-eslint/node_modules/ajv/README.md +1497 -0
  5. package/packages/config-eslint/node_modules/ajv/dist/ajv.bundle.js +7189 -0
  6. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js +3 -0
  7. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js.map +1 -0
  8. package/packages/config-eslint/node_modules/ajv/lib/ajv.d.ts +397 -0
  9. package/packages/config-eslint/node_modules/ajv/lib/ajv.js +506 -0
  10. package/packages/config-eslint/node_modules/ajv/lib/cache.js +26 -0
  11. package/packages/config-eslint/node_modules/ajv/lib/compile/async.js +90 -0
  12. package/packages/config-eslint/node_modules/ajv/lib/compile/equal.js +5 -0
  13. package/packages/config-eslint/node_modules/ajv/lib/compile/error_classes.js +34 -0
  14. package/packages/config-eslint/node_modules/ajv/lib/compile/formats.js +142 -0
  15. package/packages/config-eslint/node_modules/ajv/lib/compile/index.js +387 -0
  16. package/packages/config-eslint/node_modules/ajv/lib/compile/resolve.js +270 -0
  17. package/packages/config-eslint/node_modules/ajv/lib/compile/rules.js +66 -0
  18. package/packages/config-eslint/node_modules/ajv/lib/compile/schema_obj.js +9 -0
  19. package/packages/config-eslint/node_modules/ajv/lib/compile/ucs2length.js +20 -0
  20. package/packages/config-eslint/node_modules/ajv/lib/compile/util.js +239 -0
  21. package/packages/config-eslint/node_modules/ajv/lib/data.js +49 -0
  22. package/packages/config-eslint/node_modules/ajv/lib/definition_schema.js +37 -0
  23. package/packages/config-eslint/node_modules/ajv/lib/dot/_limit.jst +113 -0
  24. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitItems.jst +12 -0
  25. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitLength.jst +12 -0
  26. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitProperties.jst +12 -0
  27. package/packages/config-eslint/node_modules/ajv/lib/dot/allOf.jst +32 -0
  28. package/packages/config-eslint/node_modules/ajv/lib/dot/anyOf.jst +46 -0
  29. package/packages/config-eslint/node_modules/ajv/lib/dot/coerce.def +51 -0
  30. package/packages/config-eslint/node_modules/ajv/lib/dot/comment.jst +9 -0
  31. package/packages/config-eslint/node_modules/ajv/lib/dot/const.jst +11 -0
  32. package/packages/config-eslint/node_modules/ajv/lib/dot/contains.jst +55 -0
  33. package/packages/config-eslint/node_modules/ajv/lib/dot/custom.jst +191 -0
  34. package/packages/config-eslint/node_modules/ajv/lib/dot/defaults.def +47 -0
  35. package/packages/config-eslint/node_modules/ajv/lib/dot/definitions.def +203 -0
  36. package/packages/config-eslint/node_modules/ajv/lib/dot/dependencies.jst +79 -0
  37. package/packages/config-eslint/node_modules/ajv/lib/dot/enum.jst +30 -0
  38. package/packages/config-eslint/node_modules/ajv/lib/dot/errors.def +194 -0
  39. package/packages/config-eslint/node_modules/ajv/lib/dot/format.jst +106 -0
  40. package/packages/config-eslint/node_modules/ajv/lib/dot/if.jst +73 -0
  41. package/packages/config-eslint/node_modules/ajv/lib/dot/items.jst +98 -0
  42. package/packages/config-eslint/node_modules/ajv/lib/dot/missing.def +39 -0
  43. package/packages/config-eslint/node_modules/ajv/lib/dot/multipleOf.jst +22 -0
  44. package/packages/config-eslint/node_modules/ajv/lib/dot/not.jst +43 -0
  45. package/packages/config-eslint/node_modules/ajv/lib/dot/oneOf.jst +54 -0
  46. package/packages/config-eslint/node_modules/ajv/lib/dot/pattern.jst +14 -0
  47. package/packages/config-eslint/node_modules/ajv/lib/dot/properties.jst +245 -0
  48. package/packages/config-eslint/node_modules/ajv/lib/dot/propertyNames.jst +52 -0
  49. package/packages/config-eslint/node_modules/ajv/lib/dot/ref.jst +85 -0
  50. package/packages/config-eslint/node_modules/ajv/lib/dot/required.jst +108 -0
  51. package/packages/config-eslint/node_modules/ajv/lib/dot/uniqueItems.jst +62 -0
  52. package/packages/config-eslint/node_modules/ajv/lib/dot/validate.jst +276 -0
  53. package/packages/config-eslint/node_modules/ajv/lib/dotjs/README.md +3 -0
  54. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limit.js +163 -0
  55. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitItems.js +80 -0
  56. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitLength.js +85 -0
  57. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitProperties.js +80 -0
  58. package/packages/config-eslint/node_modules/ajv/lib/dotjs/allOf.js +42 -0
  59. package/packages/config-eslint/node_modules/ajv/lib/dotjs/anyOf.js +73 -0
  60. package/packages/config-eslint/node_modules/ajv/lib/dotjs/comment.js +14 -0
  61. package/packages/config-eslint/node_modules/ajv/lib/dotjs/const.js +56 -0
  62. package/packages/config-eslint/node_modules/ajv/lib/dotjs/contains.js +81 -0
  63. package/packages/config-eslint/node_modules/ajv/lib/dotjs/custom.js +228 -0
  64. package/packages/config-eslint/node_modules/ajv/lib/dotjs/dependencies.js +168 -0
  65. package/packages/config-eslint/node_modules/ajv/lib/dotjs/enum.js +66 -0
  66. package/packages/config-eslint/node_modules/ajv/lib/dotjs/format.js +150 -0
  67. package/packages/config-eslint/node_modules/ajv/lib/dotjs/if.js +103 -0
  68. package/packages/config-eslint/node_modules/ajv/lib/dotjs/index.js +33 -0
  69. package/packages/config-eslint/node_modules/ajv/lib/dotjs/items.js +140 -0
  70. package/packages/config-eslint/node_modules/ajv/lib/dotjs/multipleOf.js +80 -0
  71. package/packages/config-eslint/node_modules/ajv/lib/dotjs/not.js +84 -0
  72. package/packages/config-eslint/node_modules/ajv/lib/dotjs/oneOf.js +73 -0
  73. package/packages/config-eslint/node_modules/ajv/lib/dotjs/pattern.js +75 -0
  74. package/packages/config-eslint/node_modules/ajv/lib/dotjs/properties.js +335 -0
  75. package/packages/config-eslint/node_modules/ajv/lib/dotjs/propertyNames.js +81 -0
  76. package/packages/config-eslint/node_modules/ajv/lib/dotjs/ref.js +124 -0
  77. package/packages/config-eslint/node_modules/ajv/lib/dotjs/required.js +270 -0
  78. package/packages/config-eslint/node_modules/ajv/lib/dotjs/uniqueItems.js +86 -0
  79. package/packages/config-eslint/node_modules/ajv/lib/dotjs/validate.js +482 -0
  80. package/packages/config-eslint/node_modules/ajv/lib/keyword.js +146 -0
  81. package/packages/config-eslint/node_modules/ajv/lib/refs/data.json +17 -0
  82. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-04.json +149 -0
  83. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-06.json +154 -0
  84. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-07.json +168 -0
  85. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-secure.json +94 -0
  86. package/packages/config-eslint/node_modules/ajv/package.json +106 -0
  87. package/packages/config-eslint/node_modules/ajv/scripts/.eslintrc.yml +3 -0
  88. package/packages/config-eslint/node_modules/ajv/scripts/bundle.js +61 -0
  89. package/packages/config-eslint/node_modules/ajv/scripts/compile-dots.js +73 -0
  90. package/packages/config-eslint/node_modules/ajv/scripts/info +10 -0
  91. package/packages/config-eslint/node_modules/ajv/scripts/prepare-tests +12 -0
  92. package/packages/config-eslint/node_modules/ajv/scripts/publish-built-version +32 -0
  93. package/packages/config-eslint/node_modules/ajv/scripts/travis-gh-pages +23 -0
  94. package/packages/config-eslint/node_modules/ansi-styles/index.d.ts +345 -0
  95. package/packages/config-eslint/node_modules/ansi-styles/index.js +163 -0
  96. package/packages/config-eslint/node_modules/ansi-styles/license +9 -0
  97. package/packages/config-eslint/node_modules/ansi-styles/package.json +56 -0
  98. package/packages/config-eslint/node_modules/ansi-styles/readme.md +152 -0
  99. package/packages/config-eslint/node_modules/chalk/index.d.ts +415 -0
  100. package/packages/config-eslint/node_modules/chalk/license +9 -0
  101. package/packages/config-eslint/node_modules/chalk/package.json +68 -0
  102. package/packages/config-eslint/node_modules/chalk/readme.md +341 -0
  103. package/packages/config-eslint/node_modules/chalk/source/index.js +229 -0
  104. package/packages/config-eslint/node_modules/chalk/source/templates.js +134 -0
  105. package/packages/config-eslint/node_modules/chalk/source/util.js +39 -0
  106. package/packages/config-eslint/node_modules/color-convert/CHANGELOG.md +54 -0
  107. package/packages/config-eslint/node_modules/color-convert/LICENSE +21 -0
  108. package/packages/config-eslint/node_modules/color-convert/README.md +68 -0
  109. package/packages/config-eslint/node_modules/color-convert/conversions.js +839 -0
  110. package/packages/config-eslint/node_modules/color-convert/index.js +81 -0
  111. package/packages/config-eslint/node_modules/color-convert/package.json +48 -0
  112. package/packages/config-eslint/node_modules/color-convert/route.js +97 -0
  113. package/packages/config-eslint/node_modules/color-name/LICENSE +8 -0
  114. package/packages/config-eslint/node_modules/color-name/README.md +11 -0
  115. package/packages/config-eslint/node_modules/color-name/index.js +152 -0
  116. package/packages/config-eslint/node_modules/color-name/package.json +28 -0
  117. package/packages/config-eslint/node_modules/eslint/LICENSE +19 -0
  118. package/packages/config-eslint/node_modules/eslint/README.md +306 -0
  119. package/packages/config-eslint/node_modules/eslint/bin/eslint.js +174 -0
  120. package/packages/config-eslint/node_modules/eslint/conf/default-cli-options.js +32 -0
  121. package/packages/config-eslint/node_modules/eslint/conf/ecma-version.js +16 -0
  122. package/packages/config-eslint/node_modules/eslint/conf/globals.js +160 -0
  123. package/packages/config-eslint/node_modules/eslint/conf/replacements.json +22 -0
  124. package/packages/config-eslint/node_modules/eslint/conf/rule-type-list.json +30 -0
  125. package/packages/config-eslint/node_modules/eslint/lib/api.js +50 -0
  126. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/cli-engine.js +1089 -0
  127. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/file-enumerator.js +547 -0
  128. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json +18 -0
  129. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/html.js +351 -0
  130. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/json-with-metadata.js +16 -0
  131. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/json.js +13 -0
  132. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/stylish.js +101 -0
  133. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/hash.js +35 -0
  134. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/index.js +7 -0
  135. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/lint-result-cache.js +203 -0
  136. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/load-rules.js +46 -0
  137. package/packages/config-eslint/node_modules/eslint/lib/cli.js +552 -0
  138. package/packages/config-eslint/node_modules/eslint/lib/config/default-config.js +75 -0
  139. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-array.js +423 -0
  140. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-helpers.js +132 -0
  141. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-schema.js +576 -0
  142. package/packages/config-eslint/node_modules/eslint/lib/config/rule-validator.js +194 -0
  143. package/packages/config-eslint/node_modules/eslint/lib/eslint/eslint-helpers.js +975 -0
  144. package/packages/config-eslint/node_modules/eslint/lib/eslint/eslint.js +1307 -0
  145. package/packages/config-eslint/node_modules/eslint/lib/eslint/index.js +9 -0
  146. package/packages/config-eslint/node_modules/eslint/lib/eslint/legacy-eslint.js +742 -0
  147. package/packages/config-eslint/node_modules/eslint/lib/languages/js/index.js +252 -0
  148. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/index.js +7 -0
  149. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/source-code.js +1318 -0
  150. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js +57 -0
  151. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-cursor.js +58 -0
  152. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursor.js +76 -0
  153. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursors.js +92 -0
  154. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/decorative-cursor.js +39 -0
  155. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/filter-cursor.js +43 -0
  156. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js +57 -0
  157. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-cursor.js +63 -0
  158. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/index.js +627 -0
  159. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/limit-cursor.js +40 -0
  160. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/padded-token-cursor.js +38 -0
  161. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/skip-cursor.js +42 -0
  162. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/utils.js +107 -0
  163. package/packages/config-eslint/node_modules/eslint/lib/languages/js/validate-language-options.js +181 -0
  164. package/packages/config-eslint/node_modules/eslint/lib/linter/apply-disable-directives.js +513 -0
  165. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +851 -0
  166. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js +263 -0
  167. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js +2348 -0
  168. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path.js +344 -0
  169. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js +203 -0
  170. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +349 -0
  171. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/id-generator.js +45 -0
  172. package/packages/config-eslint/node_modules/eslint/lib/linter/config-comment-parser.js +169 -0
  173. package/packages/config-eslint/node_modules/eslint/lib/linter/index.js +11 -0
  174. package/packages/config-eslint/node_modules/eslint/lib/linter/interpolate.js +50 -0
  175. package/packages/config-eslint/node_modules/eslint/lib/linter/linter.js +2410 -0
  176. package/packages/config-eslint/node_modules/eslint/lib/linter/node-event-generator.js +352 -0
  177. package/packages/config-eslint/node_modules/eslint/lib/linter/report-translator.js +376 -0
  178. package/packages/config-eslint/node_modules/eslint/lib/linter/rule-fixer.js +163 -0
  179. package/packages/config-eslint/node_modules/eslint/lib/linter/rules.js +71 -0
  180. package/packages/config-eslint/node_modules/eslint/lib/linter/safe-emitter.js +52 -0
  181. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-fixer.js +152 -0
  182. package/packages/config-eslint/node_modules/eslint/lib/linter/timing.js +169 -0
  183. package/packages/config-eslint/node_modules/eslint/lib/linter/vfile.js +111 -0
  184. package/packages/config-eslint/node_modules/eslint/lib/options.js +442 -0
  185. package/packages/config-eslint/node_modules/eslint/lib/rule-tester/index.js +7 -0
  186. package/packages/config-eslint/node_modules/eslint/lib/rule-tester/rule-tester.js +1286 -0
  187. package/packages/config-eslint/node_modules/eslint/lib/rules/accessor-pairs.js +346 -0
  188. package/packages/config-eslint/node_modules/eslint/lib/rules/array-bracket-newline.js +261 -0
  189. package/packages/config-eslint/node_modules/eslint/lib/rules/array-bracket-spacing.js +244 -0
  190. package/packages/config-eslint/node_modules/eslint/lib/rules/array-callback-return.js +446 -0
  191. package/packages/config-eslint/node_modules/eslint/lib/rules/array-element-newline.js +311 -0
  192. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-body-style.js +296 -0
  193. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-parens.js +186 -0
  194. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-spacing.js +164 -0
  195. package/packages/config-eslint/node_modules/eslint/lib/rules/block-scoped-var.js +135 -0
  196. package/packages/config-eslint/node_modules/eslint/lib/rules/block-spacing.js +174 -0
  197. package/packages/config-eslint/node_modules/eslint/lib/rules/brace-style.js +197 -0
  198. package/packages/config-eslint/node_modules/eslint/lib/rules/callback-return.js +187 -0
  199. package/packages/config-eslint/node_modules/eslint/lib/rules/camelcase.js +397 -0
  200. package/packages/config-eslint/node_modules/eslint/lib/rules/capitalized-comments.js +303 -0
  201. package/packages/config-eslint/node_modules/eslint/lib/rules/class-methods-use-this.js +187 -0
  202. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-dangle.js +373 -0
  203. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-spacing.js +192 -0
  204. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-style.js +314 -0
  205. package/packages/config-eslint/node_modules/eslint/lib/rules/complexity.js +178 -0
  206. package/packages/config-eslint/node_modules/eslint/lib/rules/computed-property-spacing.js +208 -0
  207. package/packages/config-eslint/node_modules/eslint/lib/rules/consistent-return.js +210 -0
  208. package/packages/config-eslint/node_modules/eslint/lib/rules/consistent-this.js +153 -0
  209. package/packages/config-eslint/node_modules/eslint/lib/rules/constructor-super.js +445 -0
  210. package/packages/config-eslint/node_modules/eslint/lib/rules/curly.js +486 -0
  211. package/packages/config-eslint/node_modules/eslint/lib/rules/default-case-last.js +44 -0
  212. package/packages/config-eslint/node_modules/eslint/lib/rules/default-case.js +97 -0
  213. package/packages/config-eslint/node_modules/eslint/lib/rules/default-param-last.js +62 -0
  214. package/packages/config-eslint/node_modules/eslint/lib/rules/dot-location.js +108 -0
  215. package/packages/config-eslint/node_modules/eslint/lib/rules/dot-notation.js +176 -0
  216. package/packages/config-eslint/node_modules/eslint/lib/rules/eol-last.js +115 -0
  217. package/packages/config-eslint/node_modules/eslint/lib/rules/eqeqeq.js +174 -0
  218. package/packages/config-eslint/node_modules/eslint/lib/rules/for-direction.js +140 -0
  219. package/packages/config-eslint/node_modules/eslint/lib/rules/func-call-spacing.js +233 -0
  220. package/packages/config-eslint/node_modules/eslint/lib/rules/func-name-matching.js +253 -0
  221. package/packages/config-eslint/node_modules/eslint/lib/rules/func-names.js +191 -0
  222. package/packages/config-eslint/node_modules/eslint/lib/rules/func-style.js +136 -0
  223. package/packages/config-eslint/node_modules/eslint/lib/rules/function-call-argument-newline.js +125 -0
  224. package/packages/config-eslint/node_modules/eslint/lib/rules/function-paren-newline.js +292 -0
  225. package/packages/config-eslint/node_modules/eslint/lib/rules/generator-star-spacing.js +209 -0
  226. package/packages/config-eslint/node_modules/eslint/lib/rules/getter-return.js +204 -0
  227. package/packages/config-eslint/node_modules/eslint/lib/rules/global-require.js +90 -0
  228. package/packages/config-eslint/node_modules/eslint/lib/rules/grouped-accessor-pairs.js +215 -0
  229. package/packages/config-eslint/node_modules/eslint/lib/rules/guard-for-in.js +76 -0
  230. package/packages/config-eslint/node_modules/eslint/lib/rules/handle-callback-err.js +101 -0
  231. package/packages/config-eslint/node_modules/eslint/lib/rules/id-blacklist.js +246 -0
  232. package/packages/config-eslint/node_modules/eslint/lib/rules/id-denylist.js +228 -0
  233. package/packages/config-eslint/node_modules/eslint/lib/rules/id-length.js +177 -0
  234. package/packages/config-eslint/node_modules/eslint/lib/rules/id-match.js +299 -0
  235. package/packages/config-eslint/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js +84 -0
  236. package/packages/config-eslint/node_modules/eslint/lib/rules/indent-legacy.js +1126 -0
  237. package/packages/config-eslint/node_modules/eslint/lib/rules/indent.js +1803 -0
  238. package/packages/config-eslint/node_modules/eslint/lib/rules/index.js +305 -0
  239. package/packages/config-eslint/node_modules/eslint/lib/rules/init-declarations.js +139 -0
  240. package/packages/config-eslint/node_modules/eslint/lib/rules/jsx-quotes.js +98 -0
  241. package/packages/config-eslint/node_modules/eslint/lib/rules/key-spacing.js +687 -0
  242. package/packages/config-eslint/node_modules/eslint/lib/rules/keyword-spacing.js +640 -0
  243. package/packages/config-eslint/node_modules/eslint/lib/rules/line-comment-position.js +125 -0
  244. package/packages/config-eslint/node_modules/eslint/lib/rules/linebreak-style.js +108 -0
  245. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-around-comment.js +471 -0
  246. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-around-directive.js +201 -0
  247. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-between-class-members.js +269 -0
  248. package/packages/config-eslint/node_modules/eslint/lib/rules/logical-assignment-operators.js +504 -0
  249. package/packages/config-eslint/node_modules/eslint/lib/rules/max-classes-per-file.js +89 -0
  250. package/packages/config-eslint/node_modules/eslint/lib/rules/max-depth.js +156 -0
  251. package/packages/config-eslint/node_modules/eslint/lib/rules/max-len.js +440 -0
  252. package/packages/config-eslint/node_modules/eslint/lib/rules/max-lines-per-function.js +213 -0
  253. package/packages/config-eslint/node_modules/eslint/lib/rules/max-lines.js +193 -0
  254. package/packages/config-eslint/node_modules/eslint/lib/rules/max-nested-callbacks.js +117 -0
  255. package/packages/config-eslint/node_modules/eslint/lib/rules/max-params.js +102 -0
  256. package/packages/config-eslint/node_modules/eslint/lib/rules/max-statements-per-line.js +199 -0
  257. package/packages/config-eslint/node_modules/eslint/lib/rules/max-statements.js +184 -0
  258. package/packages/config-eslint/node_modules/eslint/lib/rules/multiline-comment-style.js +476 -0
  259. package/packages/config-eslint/node_modules/eslint/lib/rules/multiline-ternary.js +174 -0
  260. package/packages/config-eslint/node_modules/eslint/lib/rules/new-cap.js +276 -0
  261. package/packages/config-eslint/node_modules/eslint/lib/rules/new-parens.js +93 -0
  262. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-after-var.js +253 -0
  263. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-before-return.js +217 -0
  264. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-per-chained-call.js +126 -0
  265. package/packages/config-eslint/node_modules/eslint/lib/rules/no-alert.js +138 -0
  266. package/packages/config-eslint/node_modules/eslint/lib/rules/no-array-constructor.js +133 -0
  267. package/packages/config-eslint/node_modules/eslint/lib/rules/no-async-promise-executor.js +39 -0
  268. package/packages/config-eslint/node_modules/eslint/lib/rules/no-await-in-loop.js +106 -0
  269. package/packages/config-eslint/node_modules/eslint/lib/rules/no-bitwise.js +119 -0
  270. package/packages/config-eslint/node_modules/eslint/lib/rules/no-buffer-constructor.js +50 -0
  271. package/packages/config-eslint/node_modules/eslint/lib/rules/no-caller.js +46 -0
  272. package/packages/config-eslint/node_modules/eslint/lib/rules/no-case-declarations.js +76 -0
  273. package/packages/config-eslint/node_modules/eslint/lib/rules/no-catch-shadow.js +82 -0
  274. package/packages/config-eslint/node_modules/eslint/lib/rules/no-class-assign.js +63 -0
  275. package/packages/config-eslint/node_modules/eslint/lib/rules/no-compare-neg-zero.js +60 -0
  276. package/packages/config-eslint/node_modules/eslint/lib/rules/no-cond-assign.js +159 -0
  277. package/packages/config-eslint/node_modules/eslint/lib/rules/no-confusing-arrow.js +92 -0
  278. package/packages/config-eslint/node_modules/eslint/lib/rules/no-console.js +207 -0
  279. package/packages/config-eslint/node_modules/eslint/lib/rules/no-const-assign.js +56 -0
  280. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constant-binary-expression.js +508 -0
  281. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constant-condition.js +161 -0
  282. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constructor-return.js +62 -0
  283. package/packages/config-eslint/node_modules/eslint/lib/rules/no-continue.js +39 -0
  284. package/packages/config-eslint/node_modules/eslint/lib/rules/no-control-regex.js +138 -0
  285. package/packages/config-eslint/node_modules/eslint/lib/rules/no-debugger.js +43 -0
  286. package/packages/config-eslint/node_modules/eslint/lib/rules/no-delete-var.js +42 -0
  287. package/packages/config-eslint/node_modules/eslint/lib/rules/no-div-regex.js +53 -0
  288. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-args.js +82 -0
  289. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-class-members.js +104 -0
  290. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-else-if.js +122 -0
  291. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-keys.js +142 -0
  292. package/packages/config-eslint/node_modules/eslint/lib/rules/no-duplicate-case.js +71 -0
  293. package/packages/config-eslint/node_modules/eslint/lib/rules/no-duplicate-imports.js +290 -0
  294. package/packages/config-eslint/node_modules/eslint/lib/rules/no-else-return.js +405 -0
  295. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-character-class.js +76 -0
  296. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-function.js +167 -0
  297. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-pattern.js +78 -0
  298. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-static-block.js +47 -0
  299. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty.js +103 -0
  300. package/packages/config-eslint/node_modules/eslint/lib/rules/no-eq-null.js +46 -0
  301. package/packages/config-eslint/node_modules/eslint/lib/rules/no-eval.js +286 -0
  302. package/packages/config-eslint/node_modules/eslint/lib/rules/no-ex-assign.js +54 -0
  303. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extend-native.js +178 -0
  304. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-bind.js +213 -0
  305. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +369 -0
  306. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-label.js +149 -0
  307. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-parens.js +1322 -0
  308. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-semi.js +147 -0
  309. package/packages/config-eslint/node_modules/eslint/lib/rules/no-fallthrough.js +221 -0
  310. package/packages/config-eslint/node_modules/eslint/lib/rules/no-floating-decimal.js +73 -0
  311. package/packages/config-eslint/node_modules/eslint/lib/rules/no-func-assign.js +78 -0
  312. package/packages/config-eslint/node_modules/eslint/lib/rules/no-global-assign.js +95 -0
  313. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implicit-coercion.js +422 -0
  314. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implicit-globals.js +146 -0
  315. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implied-eval.js +132 -0
  316. package/packages/config-eslint/node_modules/eslint/lib/rules/no-import-assign.js +241 -0
  317. package/packages/config-eslint/node_modules/eslint/lib/rules/no-inline-comments.js +110 -0
  318. package/packages/config-eslint/node_modules/eslint/lib/rules/no-inner-declarations.js +131 -0
  319. package/packages/config-eslint/node_modules/eslint/lib/rules/no-invalid-regexp.js +194 -0
  320. package/packages/config-eslint/node_modules/eslint/lib/rules/no-invalid-this.js +150 -0
  321. package/packages/config-eslint/node_modules/eslint/lib/rules/no-irregular-whitespace.js +276 -0
  322. package/packages/config-eslint/node_modules/eslint/lib/rules/no-iterator.js +52 -0
  323. package/packages/config-eslint/node_modules/eslint/lib/rules/no-label-var.js +80 -0
  324. package/packages/config-eslint/node_modules/eslint/lib/rules/no-labels.js +149 -0
  325. package/packages/config-eslint/node_modules/eslint/lib/rules/no-lone-blocks.js +136 -0
  326. package/packages/config-eslint/node_modules/eslint/lib/rules/no-lonely-if.js +88 -0
  327. package/packages/config-eslint/node_modules/eslint/lib/rules/no-loop-func.js +238 -0
  328. package/packages/config-eslint/node_modules/eslint/lib/rules/no-loss-of-precision.js +214 -0
  329. package/packages/config-eslint/node_modules/eslint/lib/rules/no-magic-numbers.js +243 -0
  330. package/packages/config-eslint/node_modules/eslint/lib/rules/no-misleading-character-class.js +537 -0
  331. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-operators.js +229 -0
  332. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-requires.js +238 -0
  333. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +116 -0
  334. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-assign.js +67 -0
  335. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-spaces.js +141 -0
  336. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-str.js +65 -0
  337. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +154 -0
  338. package/packages/config-eslint/node_modules/eslint/lib/rules/no-native-reassign.js +98 -0
  339. package/packages/config-eslint/node_modules/eslint/lib/rules/no-negated-condition.js +95 -0
  340. package/packages/config-eslint/node_modules/eslint/lib/rules/no-negated-in-lhs.js +46 -0
  341. package/packages/config-eslint/node_modules/eslint/lib/rules/no-nested-ternary.js +44 -0
  342. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-func.js +87 -0
  343. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js +66 -0
  344. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-object.js +67 -0
  345. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-require.js +50 -0
  346. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-symbol.js +63 -0
  347. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-wrappers.js +60 -0
  348. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new.js +43 -0
  349. package/packages/config-eslint/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js +148 -0
  350. package/packages/config-eslint/node_modules/eslint/lib/rules/no-obj-calls.js +86 -0
  351. package/packages/config-eslint/node_modules/eslint/lib/rules/no-object-constructor.js +117 -0
  352. package/packages/config-eslint/node_modules/eslint/lib/rules/no-octal-escape.js +56 -0
  353. package/packages/config-eslint/node_modules/eslint/lib/rules/no-octal.js +45 -0
  354. package/packages/config-eslint/node_modules/eslint/lib/rules/no-param-reassign.js +230 -0
  355. package/packages/config-eslint/node_modules/eslint/lib/rules/no-path-concat.js +64 -0
  356. package/packages/config-eslint/node_modules/eslint/lib/rules/no-plusplus.js +105 -0
  357. package/packages/config-eslint/node_modules/eslint/lib/rules/no-process-env.js +51 -0
  358. package/packages/config-eslint/node_modules/eslint/lib/rules/no-process-exit.js +47 -0
  359. package/packages/config-eslint/node_modules/eslint/lib/rules/no-promise-executor-return.js +263 -0
  360. package/packages/config-eslint/node_modules/eslint/lib/rules/no-proto.js +48 -0
  361. package/packages/config-eslint/node_modules/eslint/lib/rules/no-prototype-builtins.js +159 -0
  362. package/packages/config-eslint/node_modules/eslint/lib/rules/no-redeclare.js +174 -0
  363. package/packages/config-eslint/node_modules/eslint/lib/rules/no-regex-spaces.js +197 -0
  364. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-exports.js +204 -0
  365. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-globals.js +124 -0
  366. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-imports.js +563 -0
  367. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-modules.js +213 -0
  368. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-properties.js +168 -0
  369. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-syntax.js +70 -0
  370. package/packages/config-eslint/node_modules/eslint/lib/rules/no-return-assign.js +80 -0
  371. package/packages/config-eslint/node_modules/eslint/lib/rules/no-return-await.js +135 -0
  372. package/packages/config-eslint/node_modules/eslint/lib/rules/no-script-url.js +61 -0
  373. package/packages/config-eslint/node_modules/eslint/lib/rules/no-self-assign.js +183 -0
  374. package/packages/config-eslint/node_modules/eslint/lib/rules/no-self-compare.js +60 -0
  375. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sequences.js +139 -0
  376. package/packages/config-eslint/node_modules/eslint/lib/rules/no-setter-return.js +226 -0
  377. package/packages/config-eslint/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +65 -0
  378. package/packages/config-eslint/node_modules/eslint/lib/rules/no-shadow.js +336 -0
  379. package/packages/config-eslint/node_modules/eslint/lib/rules/no-spaced-func.js +83 -0
  380. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sparse-arrays.js +73 -0
  381. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sync.js +64 -0
  382. package/packages/config-eslint/node_modules/eslint/lib/rules/no-tabs.js +81 -0
  383. package/packages/config-eslint/node_modules/eslint/lib/rules/no-template-curly-in-string.js +44 -0
  384. package/packages/config-eslint/node_modules/eslint/lib/rules/no-ternary.js +41 -0
  385. package/packages/config-eslint/node_modules/eslint/lib/rules/no-this-before-super.js +363 -0
  386. package/packages/config-eslint/node_modules/eslint/lib/rules/no-throw-literal.js +51 -0
  387. package/packages/config-eslint/node_modules/eslint/lib/rules/no-trailing-spaces.js +192 -0
  388. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undef-init.js +75 -0
  389. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undef.js +79 -0
  390. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undefined.js +86 -0
  391. package/packages/config-eslint/node_modules/eslint/lib/rules/no-underscore-dangle.js +335 -0
  392. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unexpected-multiline.js +120 -0
  393. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +360 -0
  394. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unneeded-ternary.js +166 -0
  395. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unreachable-loop.js +185 -0
  396. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unreachable.js +293 -0
  397. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-finally.js +111 -0
  398. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-negation.js +128 -0
  399. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js +205 -0
  400. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-expressions.js +186 -0
  401. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-labels.js +143 -0
  402. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-private-class-members.js +195 -0
  403. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-vars.js +881 -0
  404. package/packages/config-eslint/node_modules/eslint/lib/rules/no-use-before-define.js +348 -0
  405. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-assignment.js +566 -0
  406. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-backreference.js +244 -0
  407. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-call.js +90 -0
  408. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-catch.js +57 -0
  409. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-computed-key.js +168 -0
  410. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-concat.js +115 -0
  411. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-constructor.js +189 -0
  412. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-escape.js +333 -0
  413. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-rename.js +172 -0
  414. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-return.js +369 -0
  415. package/packages/config-eslint/node_modules/eslint/lib/rules/no-var.js +334 -0
  416. package/packages/config-eslint/node_modules/eslint/lib/rules/no-void.js +64 -0
  417. package/packages/config-eslint/node_modules/eslint/lib/rules/no-warning-comments.js +201 -0
  418. package/packages/config-eslint/node_modules/eslint/lib/rules/no-whitespace-before-property.js +116 -0
  419. package/packages/config-eslint/node_modules/eslint/lib/rules/no-with.js +39 -0
  420. package/packages/config-eslint/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +127 -0
  421. package/packages/config-eslint/node_modules/eslint/lib/rules/object-curly-newline.js +324 -0
  422. package/packages/config-eslint/node_modules/eslint/lib/rules/object-curly-spacing.js +311 -0
  423. package/packages/config-eslint/node_modules/eslint/lib/rules/object-property-newline.js +102 -0
  424. package/packages/config-eslint/node_modules/eslint/lib/rules/object-shorthand.js +521 -0
  425. package/packages/config-eslint/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +95 -0
  426. package/packages/config-eslint/node_modules/eslint/lib/rules/one-var.js +567 -0
  427. package/packages/config-eslint/node_modules/eslint/lib/rules/operator-assignment.js +209 -0
  428. package/packages/config-eslint/node_modules/eslint/lib/rules/operator-linebreak.js +253 -0
  429. package/packages/config-eslint/node_modules/eslint/lib/rules/padded-blocks.js +310 -0
  430. package/packages/config-eslint/node_modules/eslint/lib/rules/padding-line-between-statements.js +590 -0
  431. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-arrow-callback.js +381 -0
  432. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-const.js +501 -0
  433. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-destructuring.js +301 -0
  434. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-exponentiation-operator.js +191 -0
  435. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-named-capture-group.js +178 -0
  436. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-numeric-literals.js +148 -0
  437. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-object-has-own.js +114 -0
  438. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-object-spread.js +298 -0
  439. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +132 -0
  440. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-reflect.js +127 -0
  441. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-regex-literals.js +507 -0
  442. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-rest-params.js +118 -0
  443. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-spread.js +87 -0
  444. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-template.js +275 -0
  445. package/packages/config-eslint/node_modules/eslint/lib/rules/quote-props.js +310 -0
  446. package/packages/config-eslint/node_modules/eslint/lib/rules/quotes.js +350 -0
  447. package/packages/config-eslint/node_modules/eslint/lib/rules/radix.js +198 -0
  448. package/packages/config-eslint/node_modules/eslint/lib/rules/require-atomic-updates.js +331 -0
  449. package/packages/config-eslint/node_modules/eslint/lib/rules/require-await.js +147 -0
  450. package/packages/config-eslint/node_modules/eslint/lib/rules/require-unicode-regexp.js +129 -0
  451. package/packages/config-eslint/node_modules/eslint/lib/rules/require-yield.js +77 -0
  452. package/packages/config-eslint/node_modules/eslint/lib/rules/rest-spread-spacing.js +123 -0
  453. package/packages/config-eslint/node_modules/eslint/lib/rules/semi-spacing.js +248 -0
  454. package/packages/config-eslint/node_modules/eslint/lib/rules/semi-style.js +158 -0
  455. package/packages/config-eslint/node_modules/eslint/lib/rules/semi.js +438 -0
  456. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-imports.js +241 -0
  457. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-keys.js +230 -0
  458. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-vars.js +104 -0
  459. package/packages/config-eslint/node_modules/eslint/lib/rules/space-before-blocks.js +204 -0
  460. package/packages/config-eslint/node_modules/eslint/lib/rules/space-before-function-paren.js +167 -0
  461. package/packages/config-eslint/node_modules/eslint/lib/rules/space-in-parens.js +285 -0
  462. package/packages/config-eslint/node_modules/eslint/lib/rules/space-infix-ops.js +198 -0
  463. package/packages/config-eslint/node_modules/eslint/lib/rules/space-unary-ops.js +324 -0
  464. package/packages/config-eslint/node_modules/eslint/lib/rules/spaced-comment.js +385 -0
  465. package/packages/config-eslint/node_modules/eslint/lib/rules/strict.js +277 -0
  466. package/packages/config-eslint/node_modules/eslint/lib/rules/switch-colon-spacing.js +132 -0
  467. package/packages/config-eslint/node_modules/eslint/lib/rules/symbol-description.js +73 -0
  468. package/packages/config-eslint/node_modules/eslint/lib/rules/template-curly-spacing.js +144 -0
  469. package/packages/config-eslint/node_modules/eslint/lib/rules/template-tag-spacing.js +93 -0
  470. package/packages/config-eslint/node_modules/eslint/lib/rules/unicode-bom.js +73 -0
  471. package/packages/config-eslint/node_modules/eslint/lib/rules/use-isnan.js +235 -0
  472. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/ast-utils.js +2292 -0
  473. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/char-source.js +240 -0
  474. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/fix-tracker.js +114 -0
  475. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/keywords.js +67 -0
  476. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js +115 -0
  477. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/regular-expressions.js +42 -0
  478. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/index.js +16 -0
  479. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js +13 -0
  480. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-emoji-modifier.js +13 -0
  481. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-regional-indicator-symbol.js +13 -0
  482. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-surrogate-pair.js +14 -0
  483. package/packages/config-eslint/node_modules/eslint/lib/rules/valid-typeof.js +127 -0
  484. package/packages/config-eslint/node_modules/eslint/lib/rules/vars-on-top.js +157 -0
  485. package/packages/config-eslint/node_modules/eslint/lib/rules/wrap-iife.js +207 -0
  486. package/packages/config-eslint/node_modules/eslint/lib/rules/wrap-regex.js +61 -0
  487. package/packages/config-eslint/node_modules/eslint/lib/rules/yield-star-spacing.js +130 -0
  488. package/packages/config-eslint/node_modules/eslint/lib/rules/yoda.js +353 -0
  489. package/packages/config-eslint/node_modules/eslint/lib/shared/ajv.js +34 -0
  490. package/packages/config-eslint/node_modules/eslint/lib/shared/ast-utils.js +29 -0
  491. package/packages/config-eslint/node_modules/eslint/lib/shared/directives.js +15 -0
  492. package/packages/config-eslint/node_modules/eslint/lib/shared/flags.js +27 -0
  493. package/packages/config-eslint/node_modules/eslint/lib/shared/logging.js +39 -0
  494. package/packages/config-eslint/node_modules/eslint/lib/shared/runtime-info.js +168 -0
  495. package/packages/config-eslint/node_modules/eslint/lib/shared/serialization.js +55 -0
  496. package/packages/config-eslint/node_modules/eslint/lib/shared/severity.js +49 -0
  497. package/packages/config-eslint/node_modules/eslint/lib/shared/stats.js +30 -0
  498. package/packages/config-eslint/node_modules/eslint/lib/shared/string-utils.js +58 -0
  499. package/packages/config-eslint/node_modules/eslint/lib/shared/traverser.js +195 -0
  500. package/packages/config-eslint/node_modules/eslint/lib/shared/types.js +250 -0
  501. package/packages/config-eslint/node_modules/eslint/lib/unsupported-api.js +28 -0
  502. package/packages/config-eslint/node_modules/eslint/messages/all-files-ignored.js +16 -0
  503. package/packages/config-eslint/node_modules/eslint/messages/all-matched-files-ignored.js +21 -0
  504. package/packages/config-eslint/node_modules/eslint/messages/config-file-missing.js +16 -0
  505. package/packages/config-eslint/node_modules/eslint/messages/eslintrc-incompat.js +119 -0
  506. package/packages/config-eslint/node_modules/eslint/messages/eslintrc-plugins.js +24 -0
  507. package/packages/config-eslint/node_modules/eslint/messages/extend-config-missing.js +13 -0
  508. package/packages/config-eslint/node_modules/eslint/messages/failed-to-read-json.js +11 -0
  509. package/packages/config-eslint/node_modules/eslint/messages/file-not-found.js +10 -0
  510. package/packages/config-eslint/node_modules/eslint/messages/invalid-rule-options.js +17 -0
  511. package/packages/config-eslint/node_modules/eslint/messages/invalid-rule-severity.js +13 -0
  512. package/packages/config-eslint/node_modules/eslint/messages/no-config-found.js +15 -0
  513. package/packages/config-eslint/node_modules/eslint/messages/plugin-conflict.js +22 -0
  514. package/packages/config-eslint/node_modules/eslint/messages/plugin-invalid.js +16 -0
  515. package/packages/config-eslint/node_modules/eslint/messages/plugin-missing.js +19 -0
  516. package/packages/config-eslint/node_modules/eslint/messages/print-config-with-directory-path.js +8 -0
  517. package/packages/config-eslint/node_modules/eslint/messages/shared.js +18 -0
  518. package/packages/config-eslint/node_modules/eslint/messages/whitespace-found.js +11 -0
  519. package/packages/config-eslint/node_modules/eslint/package.json +188 -0
  520. package/packages/config-eslint/node_modules/eslint-scope/LICENSE +22 -0
  521. package/packages/config-eslint/node_modules/eslint-scope/README.md +91 -0
  522. package/packages/config-eslint/node_modules/eslint-scope/dist/eslint-scope.cjs +2266 -0
  523. package/packages/config-eslint/node_modules/eslint-scope/lib/definition.js +85 -0
  524. package/packages/config-eslint/node_modules/eslint-scope/lib/index.js +169 -0
  525. package/packages/config-eslint/node_modules/eslint-scope/lib/pattern-visitor.js +154 -0
  526. package/packages/config-eslint/node_modules/eslint-scope/lib/reference.js +166 -0
  527. package/packages/config-eslint/node_modules/eslint-scope/lib/referencer.js +656 -0
  528. package/packages/config-eslint/node_modules/eslint-scope/lib/scope-manager.js +249 -0
  529. package/packages/config-eslint/node_modules/eslint-scope/lib/scope.js +793 -0
  530. package/packages/config-eslint/node_modules/eslint-scope/lib/variable.js +87 -0
  531. package/packages/config-eslint/node_modules/eslint-scope/lib/version.js +3 -0
  532. package/packages/config-eslint/node_modules/eslint-scope/package.json +65 -0
  533. package/packages/config-eslint/node_modules/eslint-visitor-keys/LICENSE +201 -0
  534. package/packages/config-eslint/node_modules/eslint-visitor-keys/README.md +105 -0
  535. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +384 -0
  536. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +27 -0
  537. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/index.d.ts +16 -0
  538. package/packages/config-eslint/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts +12 -0
  539. package/packages/config-eslint/node_modules/eslint-visitor-keys/lib/index.js +65 -0
  540. package/packages/config-eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js +315 -0
  541. package/packages/config-eslint/node_modules/eslint-visitor-keys/package.json +74 -0
  542. package/packages/config-eslint/node_modules/file-entry-cache/LICENSE +22 -0
  543. package/packages/config-eslint/node_modules/file-entry-cache/README.md +115 -0
  544. package/packages/config-eslint/node_modules/file-entry-cache/cache.js +291 -0
  545. package/packages/config-eslint/node_modules/file-entry-cache/package.json +56 -0
  546. package/packages/config-eslint/node_modules/find-up/index.d.ts +138 -0
  547. package/packages/config-eslint/node_modules/find-up/index.js +89 -0
  548. package/packages/config-eslint/node_modules/find-up/license +9 -0
  549. package/packages/config-eslint/node_modules/find-up/package.json +54 -0
  550. package/packages/config-eslint/node_modules/find-up/readme.md +151 -0
  551. package/packages/config-eslint/node_modules/flat-cache/LICENSE +22 -0
  552. package/packages/config-eslint/node_modules/flat-cache/README.md +77 -0
  553. package/packages/config-eslint/node_modules/flat-cache/changelog.md +278 -0
  554. package/packages/config-eslint/node_modules/flat-cache/package.json +63 -0
  555. package/packages/config-eslint/node_modules/flat-cache/src/cache.js +214 -0
  556. package/packages/config-eslint/node_modules/flat-cache/src/del.js +30 -0
  557. package/packages/config-eslint/node_modules/flat-cache/src/utils.js +42 -0
  558. package/packages/config-eslint/node_modules/glob-parent/LICENSE +15 -0
  559. package/packages/config-eslint/node_modules/glob-parent/README.md +134 -0
  560. package/packages/config-eslint/node_modules/glob-parent/index.js +75 -0
  561. package/packages/config-eslint/node_modules/glob-parent/package.json +54 -0
  562. package/packages/config-eslint/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
  563. package/packages/config-eslint/node_modules/json-schema-traverse/.travis.yml +8 -0
  564. package/packages/config-eslint/node_modules/json-schema-traverse/LICENSE +21 -0
  565. package/packages/config-eslint/node_modules/json-schema-traverse/README.md +83 -0
  566. package/packages/config-eslint/node_modules/json-schema-traverse/index.js +89 -0
  567. package/packages/config-eslint/node_modules/json-schema-traverse/package.json +43 -0
  568. package/packages/config-eslint/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
  569. package/packages/config-eslint/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
  570. package/packages/config-eslint/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
  571. package/packages/config-eslint/node_modules/locate-path/index.d.ts +83 -0
  572. package/packages/config-eslint/node_modules/locate-path/index.js +68 -0
  573. package/packages/config-eslint/node_modules/locate-path/license +9 -0
  574. package/packages/config-eslint/node_modules/locate-path/package.json +46 -0
  575. package/packages/config-eslint/node_modules/locate-path/readme.md +125 -0
  576. package/packages/config-eslint/node_modules/p-limit/index.d.ts +42 -0
  577. package/packages/config-eslint/node_modules/p-limit/index.js +71 -0
  578. package/packages/config-eslint/node_modules/p-limit/license +9 -0
  579. package/packages/config-eslint/node_modules/p-limit/package.json +52 -0
  580. package/packages/config-eslint/node_modules/p-limit/readme.md +101 -0
  581. package/packages/config-eslint/node_modules/p-locate/index.d.ts +53 -0
  582. package/packages/config-eslint/node_modules/p-locate/index.js +50 -0
  583. package/packages/config-eslint/node_modules/p-locate/license +9 -0
  584. package/packages/config-eslint/node_modules/p-locate/package.json +54 -0
  585. package/packages/config-eslint/node_modules/p-locate/readme.md +93 -0
  586. package/packages/config-eslint/node_modules/path-exists/index.d.ts +28 -0
  587. package/packages/config-eslint/node_modules/path-exists/index.js +23 -0
  588. package/packages/config-eslint/node_modules/path-exists/license +9 -0
  589. package/packages/config-eslint/node_modules/path-exists/package.json +39 -0
  590. package/packages/config-eslint/node_modules/path-exists/readme.md +52 -0
  591. package/packages/config-eslint/node_modules/yocto-queue/index.d.ts +56 -0
  592. package/packages/config-eslint/node_modules/yocto-queue/index.js +68 -0
  593. package/packages/config-eslint/node_modules/yocto-queue/license +9 -0
  594. package/packages/config-eslint/node_modules/yocto-queue/package.json +43 -0
  595. package/packages/config-eslint/node_modules/yocto-queue/readme.md +64 -0
  596. package/packages/config-eslint/package.json +2 -2
  597. package/packages/config-hooks/package.json +2 -2
@@ -0,0 +1,2292 @@
1
+ /**
2
+ * @fileoverview Common utils for AST.
3
+ * @author Gyandeep Singh
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const { KEYS: eslintVisitorKeys } = require("eslint-visitor-keys");
13
+ const esutils = require("esutils");
14
+ const espree = require("espree");
15
+ const escapeRegExp = require("escape-string-regexp");
16
+ const {
17
+ breakableTypePattern,
18
+ createGlobalLinebreakMatcher,
19
+ lineBreakPattern,
20
+ shebangPattern
21
+ } = require("../../shared/ast-utils");
22
+ const globals = require("../../../conf/globals");
23
+ const { LATEST_ECMA_VERSION } = require("../../../conf/ecma-version");
24
+
25
+ //------------------------------------------------------------------------------
26
+ // Helpers
27
+ //------------------------------------------------------------------------------
28
+
29
+ const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
30
+ const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
31
+ const arrayMethodWithThisArgPattern = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|some)$/u;
32
+ const arrayOrTypedArrayPattern = /Array$/u;
33
+ const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
34
+ const thisTagPattern = /^[\s*]*@this/mu;
35
+
36
+
37
+ const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
38
+ const ESLINT_DIRECTIVE_PATTERN = /^(?:eslint[- ]|(?:globals?|exported) )/u;
39
+ const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
40
+
41
+ // A set of node types that can contain a list of statements
42
+ const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "StaticBlock", "SwitchCase"]);
43
+
44
+ const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u;
45
+
46
+ // Tests the presence of at least one LegacyOctalEscapeSequence or NonOctalDecimalEscapeSequence in a raw string
47
+ const OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN = /^(?:[^\\]|\\.)*\\(?:[1-9]|0[0-9])/su;
48
+
49
+ const LOGICAL_ASSIGNMENT_OPERATORS = new Set(["&&=", "||=", "??="]);
50
+
51
+ /**
52
+ * All builtin global variables defined in the latest ECMAScript specification.
53
+ * @type {Record<string,boolean>} Key is the name of the variable. Value is `true` if the variable is considered writable, `false` otherwise.
54
+ */
55
+ const ECMASCRIPT_GLOBALS = globals[`es${LATEST_ECMA_VERSION}`];
56
+
57
+ /**
58
+ * Checks reference if is non initializer and writable.
59
+ * @param {Reference} reference A reference to check.
60
+ * @param {int} index The index of the reference in the references.
61
+ * @param {Reference[]} references The array that the reference belongs to.
62
+ * @returns {boolean} Success/Failure
63
+ * @private
64
+ */
65
+ function isModifyingReference(reference, index, references) {
66
+ const identifier = reference.identifier;
67
+
68
+ /*
69
+ * Destructuring assignments can have multiple default value, so
70
+ * possibly there are multiple writeable references for the same
71
+ * identifier.
72
+ */
73
+ const modifyingDifferentIdentifier = index === 0 ||
74
+ references[index - 1].identifier !== identifier;
75
+
76
+ return (identifier &&
77
+ reference.init === false &&
78
+ reference.isWrite() &&
79
+ modifyingDifferentIdentifier
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Checks whether the given string starts with uppercase or not.
85
+ * @param {string} s The string to check.
86
+ * @returns {boolean} `true` if the string starts with uppercase.
87
+ */
88
+ function startsWithUpperCase(s) {
89
+ return s[0] !== s[0].toLocaleLowerCase();
90
+ }
91
+
92
+ /**
93
+ * Checks whether or not a node is a constructor.
94
+ * @param {ASTNode} node A function node to check.
95
+ * @returns {boolean} Whether or not a node is a constructor.
96
+ */
97
+ function isES5Constructor(node) {
98
+ return (node.id && startsWithUpperCase(node.id.name));
99
+ }
100
+
101
+ /**
102
+ * Finds a function node from ancestors of a node.
103
+ * @param {ASTNode} node A start node to find.
104
+ * @returns {Node|null} A found function node.
105
+ */
106
+ function getUpperFunction(node) {
107
+ for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
108
+ if (anyFunctionPattern.test(currentNode.type)) {
109
+ return currentNode;
110
+ }
111
+ }
112
+ return null;
113
+ }
114
+
115
+ /**
116
+ * Checks whether a given node is a function node or not.
117
+ * The following types are function nodes:
118
+ *
119
+ * - ArrowFunctionExpression
120
+ * - FunctionDeclaration
121
+ * - FunctionExpression
122
+ * @param {ASTNode|null} node A node to check.
123
+ * @returns {boolean} `true` if the node is a function node.
124
+ */
125
+ function isFunction(node) {
126
+ return Boolean(node && anyFunctionPattern.test(node.type));
127
+ }
128
+
129
+ /**
130
+ * Checks whether a given node is a loop node or not.
131
+ * The following types are loop nodes:
132
+ *
133
+ * - DoWhileStatement
134
+ * - ForInStatement
135
+ * - ForOfStatement
136
+ * - ForStatement
137
+ * - WhileStatement
138
+ * @param {ASTNode|null} node A node to check.
139
+ * @returns {boolean} `true` if the node is a loop node.
140
+ */
141
+ function isLoop(node) {
142
+ return Boolean(node && anyLoopPattern.test(node.type));
143
+ }
144
+
145
+ /**
146
+ * Checks whether the given node is in a loop or not.
147
+ * @param {ASTNode} node The node to check.
148
+ * @returns {boolean} `true` if the node is in a loop.
149
+ */
150
+ function isInLoop(node) {
151
+ for (let currentNode = node; currentNode && !isFunction(currentNode); currentNode = currentNode.parent) {
152
+ if (isLoop(currentNode)) {
153
+ return true;
154
+ }
155
+ }
156
+
157
+ return false;
158
+ }
159
+
160
+ /**
161
+ * Determines whether the given node is a `null` literal.
162
+ * @param {ASTNode} node The node to check
163
+ * @returns {boolean} `true` if the node is a `null` literal
164
+ */
165
+ function isNullLiteral(node) {
166
+
167
+ /*
168
+ * Checking `node.value === null` does not guarantee that a literal is a null literal.
169
+ * When parsing values that cannot be represented in the current environment (e.g. unicode
170
+ * regexes in Node 4), `node.value` is set to `null` because it wouldn't be possible to
171
+ * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
172
+ * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
173
+ */
174
+ return node.type === "Literal" && node.value === null && !node.regex && !node.bigint;
175
+ }
176
+
177
+ /**
178
+ * Checks whether or not a node is `null` or `undefined`.
179
+ * @param {ASTNode} node A node to check.
180
+ * @returns {boolean} Whether or not the node is a `null` or `undefined`.
181
+ * @public
182
+ */
183
+ function isNullOrUndefined(node) {
184
+ return (
185
+ isNullLiteral(node) ||
186
+ (node.type === "Identifier" && node.name === "undefined") ||
187
+ (node.type === "UnaryExpression" && node.operator === "void")
188
+ );
189
+ }
190
+
191
+ /**
192
+ * Checks whether or not a node is callee.
193
+ * @param {ASTNode} node A node to check.
194
+ * @returns {boolean} Whether or not the node is callee.
195
+ */
196
+ function isCallee(node) {
197
+ return node.parent.type === "CallExpression" && node.parent.callee === node;
198
+ }
199
+
200
+ /**
201
+ * Returns the result of the string conversion applied to the evaluated value of the given expression node,
202
+ * if it can be determined statically.
203
+ *
204
+ * This function returns a `string` value for all `Literal` nodes and simple `TemplateLiteral` nodes only.
205
+ * In all other cases, this function returns `null`.
206
+ * @param {ASTNode} node Expression node.
207
+ * @returns {string|null} String value if it can be determined. Otherwise, `null`.
208
+ */
209
+ function getStaticStringValue(node) {
210
+ switch (node.type) {
211
+ case "Literal":
212
+ if (node.value === null) {
213
+ if (isNullLiteral(node)) {
214
+ return String(node.value); // "null"
215
+ }
216
+ if (node.regex) {
217
+ return `/${node.regex.pattern}/${node.regex.flags}`;
218
+ }
219
+ if (node.bigint) {
220
+ return node.bigint;
221
+ }
222
+
223
+ // Otherwise, this is an unknown literal. The function will return null.
224
+
225
+ } else {
226
+ return String(node.value);
227
+ }
228
+ break;
229
+ case "TemplateLiteral":
230
+ if (node.expressions.length === 0 && node.quasis.length === 1) {
231
+ return node.quasis[0].value.cooked;
232
+ }
233
+ break;
234
+
235
+ // no default
236
+ }
237
+
238
+ return null;
239
+ }
240
+
241
+ /**
242
+ * Gets the property name of a given node.
243
+ * The node can be a MemberExpression, a Property, or a MethodDefinition.
244
+ *
245
+ * If the name is dynamic, this returns `null`.
246
+ *
247
+ * For examples:
248
+ *
249
+ * a.b // => "b"
250
+ * a["b"] // => "b"
251
+ * a['b'] // => "b"
252
+ * a[`b`] // => "b"
253
+ * a[100] // => "100"
254
+ * a[b] // => null
255
+ * a["a" + "b"] // => null
256
+ * a[tag`b`] // => null
257
+ * a[`${b}`] // => null
258
+ *
259
+ * let a = {b: 1} // => "b"
260
+ * let a = {["b"]: 1} // => "b"
261
+ * let a = {['b']: 1} // => "b"
262
+ * let a = {[`b`]: 1} // => "b"
263
+ * let a = {[100]: 1} // => "100"
264
+ * let a = {[b]: 1} // => null
265
+ * let a = {["a" + "b"]: 1} // => null
266
+ * let a = {[tag`b`]: 1} // => null
267
+ * let a = {[`${b}`]: 1} // => null
268
+ * @param {ASTNode} node The node to get.
269
+ * @returns {string|null} The property name if static. Otherwise, null.
270
+ */
271
+ function getStaticPropertyName(node) {
272
+ let prop;
273
+
274
+ switch (node && node.type) {
275
+ case "ChainExpression":
276
+ return getStaticPropertyName(node.expression);
277
+
278
+ case "Property":
279
+ case "PropertyDefinition":
280
+ case "MethodDefinition":
281
+ prop = node.key;
282
+ break;
283
+
284
+ case "MemberExpression":
285
+ prop = node.property;
286
+ break;
287
+
288
+ // no default
289
+ }
290
+
291
+ if (prop) {
292
+ if (prop.type === "Identifier" && !node.computed) {
293
+ return prop.name;
294
+ }
295
+
296
+ return getStaticStringValue(prop);
297
+ }
298
+
299
+ return null;
300
+ }
301
+
302
+ /**
303
+ * Retrieve `ChainExpression#expression` value if the given node a `ChainExpression` node. Otherwise, pass through it.
304
+ * @param {ASTNode} node The node to address.
305
+ * @returns {ASTNode} The `ChainExpression#expression` value if the node is a `ChainExpression` node. Otherwise, the node.
306
+ */
307
+ function skipChainExpression(node) {
308
+ return node && node.type === "ChainExpression" ? node.expression : node;
309
+ }
310
+
311
+ /**
312
+ * Check if the `actual` is an expected value.
313
+ * @param {string} actual The string value to check.
314
+ * @param {string | RegExp} expected The expected string value or pattern.
315
+ * @returns {boolean} `true` if the `actual` is an expected value.
316
+ */
317
+ function checkText(actual, expected) {
318
+ return typeof expected === "string"
319
+ ? actual === expected
320
+ : expected.test(actual);
321
+ }
322
+
323
+ /**
324
+ * Check if a given node is an Identifier node with a given name.
325
+ * @param {ASTNode} node The node to check.
326
+ * @param {string | RegExp} name The expected name or the expected pattern of the object name.
327
+ * @returns {boolean} `true` if the node is an Identifier node with the name.
328
+ */
329
+ function isSpecificId(node, name) {
330
+ return node.type === "Identifier" && checkText(node.name, name);
331
+ }
332
+
333
+ /**
334
+ * Check if a given node is member access with a given object name and property name pair.
335
+ * This is regardless of optional or not.
336
+ * @param {ASTNode} node The node to check.
337
+ * @param {string | RegExp | null} objectName The expected name or the expected pattern of the object name. If this is nullish, this method doesn't check object.
338
+ * @param {string | RegExp | null} propertyName The expected name or the expected pattern of the property name. If this is nullish, this method doesn't check property.
339
+ * @returns {boolean} `true` if the node is member access with the object name and property name pair.
340
+ * The node is a `MemberExpression` or `ChainExpression`.
341
+ */
342
+ function isSpecificMemberAccess(node, objectName, propertyName) {
343
+ const checkNode = skipChainExpression(node);
344
+
345
+ if (checkNode.type !== "MemberExpression") {
346
+ return false;
347
+ }
348
+
349
+ if (objectName && !isSpecificId(checkNode.object, objectName)) {
350
+ return false;
351
+ }
352
+
353
+ if (propertyName) {
354
+ const actualPropertyName = getStaticPropertyName(checkNode);
355
+
356
+ if (typeof actualPropertyName !== "string" || !checkText(actualPropertyName, propertyName)) {
357
+ return false;
358
+ }
359
+ }
360
+
361
+ return true;
362
+ }
363
+
364
+ /**
365
+ * Check if two literal nodes are the same value.
366
+ * @param {ASTNode} left The Literal node to compare.
367
+ * @param {ASTNode} right The other Literal node to compare.
368
+ * @returns {boolean} `true` if the two literal nodes are the same value.
369
+ */
370
+ function equalLiteralValue(left, right) {
371
+
372
+ // RegExp literal.
373
+ if (left.regex || right.regex) {
374
+ return Boolean(
375
+ left.regex &&
376
+ right.regex &&
377
+ left.regex.pattern === right.regex.pattern &&
378
+ left.regex.flags === right.regex.flags
379
+ );
380
+ }
381
+
382
+ // BigInt literal.
383
+ if (left.bigint || right.bigint) {
384
+ return left.bigint === right.bigint;
385
+ }
386
+
387
+ return left.value === right.value;
388
+ }
389
+
390
+ /**
391
+ * Check if two expressions reference the same value. For example:
392
+ * a = a
393
+ * a.b = a.b
394
+ * a[0] = a[0]
395
+ * a['b'] = a['b']
396
+ * @param {ASTNode} left The left side of the comparison.
397
+ * @param {ASTNode} right The right side of the comparison.
398
+ * @param {boolean} [disableStaticComputedKey] Don't address `a.b` and `a["b"]` are the same if `true`. For backward compatibility.
399
+ * @returns {boolean} `true` if both sides match and reference the same value.
400
+ */
401
+ function isSameReference(left, right, disableStaticComputedKey = false) {
402
+ if (left.type !== right.type) {
403
+
404
+ // Handle `a.b` and `a?.b` are samely.
405
+ if (left.type === "ChainExpression") {
406
+ return isSameReference(left.expression, right, disableStaticComputedKey);
407
+ }
408
+ if (right.type === "ChainExpression") {
409
+ return isSameReference(left, right.expression, disableStaticComputedKey);
410
+ }
411
+
412
+ return false;
413
+ }
414
+
415
+ switch (left.type) {
416
+ case "Super":
417
+ case "ThisExpression":
418
+ return true;
419
+
420
+ case "Identifier":
421
+ case "PrivateIdentifier":
422
+ return left.name === right.name;
423
+ case "Literal":
424
+ return equalLiteralValue(left, right);
425
+
426
+ case "ChainExpression":
427
+ return isSameReference(left.expression, right.expression, disableStaticComputedKey);
428
+
429
+ case "MemberExpression": {
430
+ if (!disableStaticComputedKey) {
431
+ const nameA = getStaticPropertyName(left);
432
+
433
+ // x.y = x["y"]
434
+ if (nameA !== null) {
435
+ return (
436
+ isSameReference(left.object, right.object, disableStaticComputedKey) &&
437
+ nameA === getStaticPropertyName(right)
438
+ );
439
+ }
440
+ }
441
+
442
+ /*
443
+ * x[0] = x[0]
444
+ * x[y] = x[y]
445
+ * x.y = x.y
446
+ */
447
+ return (
448
+ left.computed === right.computed &&
449
+ isSameReference(left.object, right.object, disableStaticComputedKey) &&
450
+ isSameReference(left.property, right.property, disableStaticComputedKey)
451
+ );
452
+ }
453
+
454
+ default:
455
+ return false;
456
+ }
457
+ }
458
+
459
+ /**
460
+ * Checks whether or not a node is `Reflect.apply`.
461
+ * @param {ASTNode} node A node to check.
462
+ * @returns {boolean} Whether or not the node is a `Reflect.apply`.
463
+ */
464
+ function isReflectApply(node) {
465
+ return isSpecificMemberAccess(node, "Reflect", "apply");
466
+ }
467
+
468
+ /**
469
+ * Checks whether or not a node is `Array.from`.
470
+ * @param {ASTNode} node A node to check.
471
+ * @returns {boolean} Whether or not the node is a `Array.from`.
472
+ */
473
+ function isArrayFromMethod(node) {
474
+ return isSpecificMemberAccess(node, arrayOrTypedArrayPattern, "from");
475
+ }
476
+
477
+ /**
478
+ * Checks whether or not a node is a method which expects a function as a first argument, and `thisArg` as a second argument.
479
+ * @param {ASTNode} node A node to check.
480
+ * @returns {boolean} Whether or not the node is a method which expects a function as a first argument, and `thisArg` as a second argument.
481
+ */
482
+ function isMethodWhichHasThisArg(node) {
483
+ return isSpecificMemberAccess(node, null, arrayMethodWithThisArgPattern);
484
+ }
485
+
486
+ /**
487
+ * Creates the negate function of the given function.
488
+ * @param {Function} f The function to negate.
489
+ * @returns {Function} Negated function.
490
+ */
491
+ function negate(f) {
492
+ return token => !f(token);
493
+ }
494
+
495
+ /**
496
+ * Checks whether or not a node has a `@this` tag in its comments.
497
+ * @param {ASTNode} node A node to check.
498
+ * @param {SourceCode} sourceCode A SourceCode instance to get comments.
499
+ * @returns {boolean} Whether or not the node has a `@this` tag in its comments.
500
+ */
501
+ function hasJSDocThisTag(node, sourceCode) {
502
+ const jsdocComment = sourceCode.getJSDocComment(node);
503
+
504
+ if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
505
+ return true;
506
+ }
507
+
508
+ // Checks `@this` in its leading comments for callbacks,
509
+ // because callbacks don't have its JSDoc comment.
510
+ // e.g.
511
+ // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
512
+ return sourceCode.getCommentsBefore(node).some(comment => thisTagPattern.test(comment.value));
513
+ }
514
+
515
+ /**
516
+ * Determines if a node is surrounded by parentheses.
517
+ * @param {SourceCode} sourceCode The ESLint source code object
518
+ * @param {ASTNode} node The node to be checked.
519
+ * @returns {boolean} True if the node is parenthesised.
520
+ * @private
521
+ */
522
+ function isParenthesised(sourceCode, node) {
523
+ const previousToken = sourceCode.getTokenBefore(node),
524
+ nextToken = sourceCode.getTokenAfter(node);
525
+
526
+ return Boolean(previousToken && nextToken) &&
527
+ previousToken.value === "(" && previousToken.range[1] <= node.range[0] &&
528
+ nextToken.value === ")" && nextToken.range[0] >= node.range[1];
529
+ }
530
+
531
+ /**
532
+ * Checks if the given token is a `=` token or not.
533
+ * @param {Token} token The token to check.
534
+ * @returns {boolean} `true` if the token is a `=` token.
535
+ */
536
+ function isEqToken(token) {
537
+ return token.value === "=" && token.type === "Punctuator";
538
+ }
539
+
540
+ /**
541
+ * Checks if the given token is an arrow token or not.
542
+ * @param {Token} token The token to check.
543
+ * @returns {boolean} `true` if the token is an arrow token.
544
+ */
545
+ function isArrowToken(token) {
546
+ return token.value === "=>" && token.type === "Punctuator";
547
+ }
548
+
549
+ /**
550
+ * Checks if the given token is a comma token or not.
551
+ * @param {Token} token The token to check.
552
+ * @returns {boolean} `true` if the token is a comma token.
553
+ */
554
+ function isCommaToken(token) {
555
+ return token.value === "," && token.type === "Punctuator";
556
+ }
557
+
558
+ /**
559
+ * Checks if the given token is a dot token or not.
560
+ * @param {Token} token The token to check.
561
+ * @returns {boolean} `true` if the token is a dot token.
562
+ */
563
+ function isDotToken(token) {
564
+ return token.value === "." && token.type === "Punctuator";
565
+ }
566
+
567
+ /**
568
+ * Checks if the given token is a `?.` token or not.
569
+ * @param {Token} token The token to check.
570
+ * @returns {boolean} `true` if the token is a `?.` token.
571
+ */
572
+ function isQuestionDotToken(token) {
573
+ return token.value === "?." && token.type === "Punctuator";
574
+ }
575
+
576
+ /**
577
+ * Checks if the given token is a semicolon token or not.
578
+ * @param {Token} token The token to check.
579
+ * @returns {boolean} `true` if the token is a semicolon token.
580
+ */
581
+ function isSemicolonToken(token) {
582
+ return token.value === ";" && token.type === "Punctuator";
583
+ }
584
+
585
+ /**
586
+ * Checks if the given token is a colon token or not.
587
+ * @param {Token} token The token to check.
588
+ * @returns {boolean} `true` if the token is a colon token.
589
+ */
590
+ function isColonToken(token) {
591
+ return token.value === ":" && token.type === "Punctuator";
592
+ }
593
+
594
+ /**
595
+ * Checks if the given token is an opening parenthesis token or not.
596
+ * @param {Token} token The token to check.
597
+ * @returns {boolean} `true` if the token is an opening parenthesis token.
598
+ */
599
+ function isOpeningParenToken(token) {
600
+ return token.value === "(" && token.type === "Punctuator";
601
+ }
602
+
603
+ /**
604
+ * Checks if the given token is a closing parenthesis token or not.
605
+ * @param {Token} token The token to check.
606
+ * @returns {boolean} `true` if the token is a closing parenthesis token.
607
+ */
608
+ function isClosingParenToken(token) {
609
+ return token.value === ")" && token.type === "Punctuator";
610
+ }
611
+
612
+ /**
613
+ * Checks if the given token is an opening square bracket token or not.
614
+ * @param {Token} token The token to check.
615
+ * @returns {boolean} `true` if the token is an opening square bracket token.
616
+ */
617
+ function isOpeningBracketToken(token) {
618
+ return token.value === "[" && token.type === "Punctuator";
619
+ }
620
+
621
+ /**
622
+ * Checks if the given token is a closing square bracket token or not.
623
+ * @param {Token} token The token to check.
624
+ * @returns {boolean} `true` if the token is a closing square bracket token.
625
+ */
626
+ function isClosingBracketToken(token) {
627
+ return token.value === "]" && token.type === "Punctuator";
628
+ }
629
+
630
+ /**
631
+ * Checks if the given token is an opening brace token or not.
632
+ * @param {Token} token The token to check.
633
+ * @returns {boolean} `true` if the token is an opening brace token.
634
+ */
635
+ function isOpeningBraceToken(token) {
636
+ return token.value === "{" && token.type === "Punctuator";
637
+ }
638
+
639
+ /**
640
+ * Checks if the given token is a closing brace token or not.
641
+ * @param {Token} token The token to check.
642
+ * @returns {boolean} `true` if the token is a closing brace token.
643
+ */
644
+ function isClosingBraceToken(token) {
645
+ return token.value === "}" && token.type === "Punctuator";
646
+ }
647
+
648
+ /**
649
+ * Checks if the given token is a comment token or not.
650
+ * @param {Token} token The token to check.
651
+ * @returns {boolean} `true` if the token is a comment token.
652
+ */
653
+ function isCommentToken(token) {
654
+ return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
655
+ }
656
+
657
+ /**
658
+ * Checks if the given token is a keyword token or not.
659
+ * @param {Token} token The token to check.
660
+ * @returns {boolean} `true` if the token is a keyword token.
661
+ */
662
+ function isKeywordToken(token) {
663
+ return token.type === "Keyword";
664
+ }
665
+
666
+ /**
667
+ * Gets the `(` token of the given function node.
668
+ * @param {ASTNode} node The function node to get.
669
+ * @param {SourceCode} sourceCode The source code object to get tokens.
670
+ * @returns {Token} `(` token.
671
+ */
672
+ function getOpeningParenOfParams(node, sourceCode) {
673
+
674
+ // If the node is an arrow function and doesn't have parens, this returns the identifier of the first param.
675
+ if (node.type === "ArrowFunctionExpression" && node.params.length === 1) {
676
+ const argToken = sourceCode.getFirstToken(node.params[0]);
677
+ const maybeParenToken = sourceCode.getTokenBefore(argToken);
678
+
679
+ return isOpeningParenToken(maybeParenToken) ? maybeParenToken : argToken;
680
+ }
681
+
682
+ // Otherwise, returns paren.
683
+ return node.id
684
+ ? sourceCode.getTokenAfter(node.id, isOpeningParenToken)
685
+ : sourceCode.getFirstToken(node, isOpeningParenToken);
686
+ }
687
+
688
+ /**
689
+ * Checks whether or not the tokens of two given nodes are same.
690
+ * @param {ASTNode} left A node 1 to compare.
691
+ * @param {ASTNode} right A node 2 to compare.
692
+ * @param {SourceCode} sourceCode The ESLint source code object.
693
+ * @returns {boolean} the source code for the given node.
694
+ */
695
+ function equalTokens(left, right, sourceCode) {
696
+ const tokensL = sourceCode.getTokens(left);
697
+ const tokensR = sourceCode.getTokens(right);
698
+
699
+ if (tokensL.length !== tokensR.length) {
700
+ return false;
701
+ }
702
+ for (let i = 0; i < tokensL.length; ++i) {
703
+ if (tokensL[i].type !== tokensR[i].type ||
704
+ tokensL[i].value !== tokensR[i].value
705
+ ) {
706
+ return false;
707
+ }
708
+ }
709
+
710
+ return true;
711
+ }
712
+
713
+ /**
714
+ * Check if the given node is a true logical expression or not.
715
+ *
716
+ * The three binary expressions logical-or (`||`), logical-and (`&&`), and
717
+ * coalesce (`??`) are known as `ShortCircuitExpression`.
718
+ * But ESTree represents those by `LogicalExpression` node.
719
+ *
720
+ * This function rejects coalesce expressions of `LogicalExpression` node.
721
+ * @param {ASTNode} node The node to check.
722
+ * @returns {boolean} `true` if the node is `&&` or `||`.
723
+ * @see https://tc39.es/ecma262/#prod-ShortCircuitExpression
724
+ */
725
+ function isLogicalExpression(node) {
726
+ return (
727
+ node.type === "LogicalExpression" &&
728
+ (node.operator === "&&" || node.operator === "||")
729
+ );
730
+ }
731
+
732
+ /**
733
+ * Check if the given node is a nullish coalescing expression or not.
734
+ *
735
+ * The three binary expressions logical-or (`||`), logical-and (`&&`), and
736
+ * coalesce (`??`) are known as `ShortCircuitExpression`.
737
+ * But ESTree represents those by `LogicalExpression` node.
738
+ *
739
+ * This function finds only coalesce expressions of `LogicalExpression` node.
740
+ * @param {ASTNode} node The node to check.
741
+ * @returns {boolean} `true` if the node is `??`.
742
+ */
743
+ function isCoalesceExpression(node) {
744
+ return node.type === "LogicalExpression" && node.operator === "??";
745
+ }
746
+
747
+ /**
748
+ * Check if given two nodes are the pair of a logical expression and a coalesce expression.
749
+ * @param {ASTNode} left A node to check.
750
+ * @param {ASTNode} right Another node to check.
751
+ * @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression.
752
+ */
753
+ function isMixedLogicalAndCoalesceExpressions(left, right) {
754
+ return (
755
+ (isLogicalExpression(left) && isCoalesceExpression(right)) ||
756
+ (isCoalesceExpression(left) && isLogicalExpression(right))
757
+ );
758
+ }
759
+
760
+ /**
761
+ * Checks if the given operator is a logical assignment operator.
762
+ * @param {string} operator The operator to check.
763
+ * @returns {boolean} `true` if the operator is a logical assignment operator.
764
+ */
765
+ function isLogicalAssignmentOperator(operator) {
766
+ return LOGICAL_ASSIGNMENT_OPERATORS.has(operator);
767
+ }
768
+
769
+ /**
770
+ * Get the colon token of the given SwitchCase node.
771
+ * @param {ASTNode} node The SwitchCase node to get.
772
+ * @param {SourceCode} sourceCode The source code object to get tokens.
773
+ * @returns {Token} The colon token of the node.
774
+ */
775
+ function getSwitchCaseColonToken(node, sourceCode) {
776
+ if (node.test) {
777
+ return sourceCode.getTokenAfter(node.test, isColonToken);
778
+ }
779
+ return sourceCode.getFirstToken(node, 1);
780
+ }
781
+
782
+ /**
783
+ * Gets ESM module export name represented by the given node.
784
+ * @param {ASTNode} node `Identifier` or string `Literal` node in a position
785
+ * that represents a module export name:
786
+ * - `ImportSpecifier#imported`
787
+ * - `ExportSpecifier#local` (if it is a re-export from another module)
788
+ * - `ExportSpecifier#exported`
789
+ * - `ExportAllDeclaration#exported`
790
+ * @returns {string} The module export name.
791
+ */
792
+ function getModuleExportName(node) {
793
+ if (node.type === "Identifier") {
794
+ return node.name;
795
+ }
796
+
797
+ // string literal
798
+ return node.value;
799
+ }
800
+
801
+ /**
802
+ * Returns literal's value converted to the Boolean type
803
+ * @param {ASTNode} node any `Literal` node
804
+ * @returns {boolean | null} `true` when node is truthy, `false` when node is falsy,
805
+ * `null` when it cannot be determined.
806
+ */
807
+ function getBooleanValue(node) {
808
+ if (node.value === null) {
809
+
810
+ /*
811
+ * it might be a null literal or bigint/regex literal in unsupported environments .
812
+ * https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es5.md#regexpliteral
813
+ * https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es2020.md#bigintliteral
814
+ */
815
+
816
+ if (node.raw === "null") {
817
+ return false;
818
+ }
819
+
820
+ // regex is always truthy
821
+ if (typeof node.regex === "object") {
822
+ return true;
823
+ }
824
+
825
+ return null;
826
+ }
827
+
828
+ return !!node.value;
829
+ }
830
+
831
+ /**
832
+ * Checks if a branch node of LogicalExpression short circuits the whole condition
833
+ * @param {ASTNode} node The branch of main condition which needs to be checked
834
+ * @param {string} operator The operator of the main LogicalExpression.
835
+ * @returns {boolean} true when condition short circuits whole condition
836
+ */
837
+ function isLogicalIdentity(node, operator) {
838
+ switch (node.type) {
839
+ case "Literal":
840
+ return (operator === "||" && getBooleanValue(node) === true) ||
841
+ (operator === "&&" && getBooleanValue(node) === false);
842
+
843
+ case "UnaryExpression":
844
+ return (operator === "&&" && node.operator === "void");
845
+
846
+ case "LogicalExpression":
847
+
848
+ /*
849
+ * handles `a && false || b`
850
+ * `false` is an identity element of `&&` but not `||`
851
+ */
852
+ return operator === node.operator &&
853
+ (
854
+ isLogicalIdentity(node.left, operator) ||
855
+ isLogicalIdentity(node.right, operator)
856
+ );
857
+
858
+ case "AssignmentExpression":
859
+ return ["||=", "&&="].includes(node.operator) &&
860
+ operator === node.operator.slice(0, -1) &&
861
+ isLogicalIdentity(node.right, operator);
862
+
863
+ // no default
864
+ }
865
+ return false;
866
+ }
867
+
868
+ /**
869
+ * Checks if an identifier is a reference to a global variable.
870
+ * @param {Scope} scope The scope in which the identifier is referenced.
871
+ * @param {ASTNode} node An identifier node to check.
872
+ * @returns {boolean} `true` if the identifier is a reference to a global variable.
873
+ */
874
+ function isReferenceToGlobalVariable(scope, node) {
875
+ const reference = scope.references.find(ref => ref.identifier === node);
876
+
877
+ return Boolean(
878
+ reference &&
879
+ reference.resolved &&
880
+ reference.resolved.scope.type === "global" &&
881
+ reference.resolved.defs.length === 0
882
+ );
883
+ }
884
+
885
+
886
+ /**
887
+ * Checks if a node has a constant truthiness value.
888
+ * @param {Scope} scope Scope in which the node appears.
889
+ * @param {ASTNode} node The AST node to check.
890
+ * @param {boolean} inBooleanPosition `true` if checking the test of a
891
+ * condition. `false` in all other cases. When `false`, checks if -- for
892
+ * both string and number -- if coerced to that type, the value will
893
+ * be constant.
894
+ * @returns {boolean} true when node's truthiness is constant
895
+ * @private
896
+ */
897
+ function isConstant(scope, node, inBooleanPosition) {
898
+
899
+ // node.elements can return null values in the case of sparse arrays ex. [,]
900
+ if (!node) {
901
+ return true;
902
+ }
903
+ switch (node.type) {
904
+ case "Literal":
905
+ case "ArrowFunctionExpression":
906
+ case "FunctionExpression":
907
+ return true;
908
+ case "ClassExpression":
909
+ case "ObjectExpression":
910
+
911
+ /**
912
+ * In theory objects like:
913
+ *
914
+ * `{toString: () => a}`
915
+ * `{valueOf: () => a}`
916
+ *
917
+ * Or a classes like:
918
+ *
919
+ * `class { static toString() { return a } }`
920
+ * `class { static valueOf() { return a } }`
921
+ *
922
+ * Are not constant verifiably when `inBooleanPosition` is
923
+ * false, but it's an edge case we've opted not to handle.
924
+ */
925
+ return true;
926
+ case "TemplateLiteral":
927
+ return (inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length)) ||
928
+ node.expressions.every(exp => isConstant(scope, exp, false));
929
+
930
+ case "ArrayExpression": {
931
+ if (!inBooleanPosition) {
932
+ return node.elements.every(element => isConstant(scope, element, false));
933
+ }
934
+ return true;
935
+ }
936
+
937
+ case "UnaryExpression":
938
+ if (
939
+ node.operator === "void" ||
940
+ node.operator === "typeof" && inBooleanPosition
941
+ ) {
942
+ return true;
943
+ }
944
+
945
+ if (node.operator === "!") {
946
+ return isConstant(scope, node.argument, true);
947
+ }
948
+
949
+ return isConstant(scope, node.argument, false);
950
+
951
+ case "BinaryExpression":
952
+ return isConstant(scope, node.left, false) &&
953
+ isConstant(scope, node.right, false) &&
954
+ node.operator !== "in";
955
+
956
+ case "LogicalExpression": {
957
+ const isLeftConstant = isConstant(scope, node.left, inBooleanPosition);
958
+ const isRightConstant = isConstant(scope, node.right, inBooleanPosition);
959
+ const isLeftShortCircuit = (isLeftConstant && isLogicalIdentity(node.left, node.operator));
960
+ const isRightShortCircuit = (inBooleanPosition && isRightConstant && isLogicalIdentity(node.right, node.operator));
961
+
962
+ return (isLeftConstant && isRightConstant) ||
963
+ isLeftShortCircuit ||
964
+ isRightShortCircuit;
965
+ }
966
+ case "NewExpression":
967
+ return inBooleanPosition;
968
+ case "AssignmentExpression":
969
+ if (node.operator === "=") {
970
+ return isConstant(scope, node.right, inBooleanPosition);
971
+ }
972
+
973
+ if (["||=", "&&="].includes(node.operator) && inBooleanPosition) {
974
+ return isLogicalIdentity(node.right, node.operator.slice(0, -1));
975
+ }
976
+
977
+ return false;
978
+
979
+ case "SequenceExpression":
980
+ return isConstant(scope, node.expressions.at(-1), inBooleanPosition);
981
+ case "SpreadElement":
982
+ return isConstant(scope, node.argument, inBooleanPosition);
983
+ case "CallExpression":
984
+ if (node.callee.type === "Identifier" && node.callee.name === "Boolean") {
985
+ if (node.arguments.length === 0 || isConstant(scope, node.arguments[0], true)) {
986
+ return isReferenceToGlobalVariable(scope, node.callee);
987
+ }
988
+ }
989
+ return false;
990
+ case "Identifier":
991
+ return node.name === "undefined" && isReferenceToGlobalVariable(scope, node);
992
+
993
+ // no default
994
+ }
995
+ return false;
996
+ }
997
+
998
+ /**
999
+ * Checks whether a node is an ExpressionStatement at the top level of a file or function body.
1000
+ * A top-level ExpressionStatement node is a directive if it contains a single unparenthesized
1001
+ * string literal and if it occurs either as the first sibling or immediately after another
1002
+ * directive.
1003
+ * @param {ASTNode} node The node to check.
1004
+ * @returns {boolean} Whether or not the node is an ExpressionStatement at the top level of a
1005
+ * file or function body.
1006
+ */
1007
+ function isTopLevelExpressionStatement(node) {
1008
+ if (node.type !== "ExpressionStatement") {
1009
+ return false;
1010
+ }
1011
+ const parent = node.parent;
1012
+
1013
+ return parent.type === "Program" || (parent.type === "BlockStatement" && isFunction(parent.parent));
1014
+
1015
+ }
1016
+
1017
+ /**
1018
+ * Check whether the given node is a part of a directive prologue or not.
1019
+ * @param {ASTNode} node The node to check.
1020
+ * @returns {boolean} `true` if the node is a part of directive prologue.
1021
+ */
1022
+ function isDirective(node) {
1023
+ return node.type === "ExpressionStatement" && typeof node.directive === "string";
1024
+ }
1025
+
1026
+ /**
1027
+ * Tests if a node appears at the beginning of an ancestor ExpressionStatement node.
1028
+ * @param {ASTNode} node The node to check.
1029
+ * @returns {boolean} Whether the node appears at the beginning of an ancestor ExpressionStatement node.
1030
+ */
1031
+ function isStartOfExpressionStatement(node) {
1032
+ const start = node.range[0];
1033
+ let ancestor = node;
1034
+
1035
+ while ((ancestor = ancestor.parent) && ancestor.range[0] === start) {
1036
+ if (ancestor.type === "ExpressionStatement") {
1037
+ return true;
1038
+ }
1039
+ }
1040
+ return false;
1041
+ }
1042
+
1043
+ /**
1044
+ * Determines whether an opening parenthesis `(`, bracket `[` or backtick ``` ` ``` needs to be preceded by a semicolon.
1045
+ * This opening parenthesis or bracket should be at the start of an `ExpressionStatement`, a `MethodDefinition` or at
1046
+ * the start of the body of an `ArrowFunctionExpression`.
1047
+ * @type {(sourceCode: SourceCode, node: ASTNode) => boolean}
1048
+ * @param {SourceCode} sourceCode The source code object.
1049
+ * @param {ASTNode} node A node at the position where an opening parenthesis or bracket will be inserted.
1050
+ * @returns {boolean} Whether a semicolon is required before the opening parenthesis or bracket.
1051
+ */
1052
+ let needsPrecedingSemicolon;
1053
+
1054
+ {
1055
+ const BREAK_OR_CONTINUE = new Set(["BreakStatement", "ContinueStatement"]);
1056
+
1057
+ // Declaration types that must contain a string Literal node at the end.
1058
+ const DECLARATIONS = new Set(["ExportAllDeclaration", "ExportNamedDeclaration", "ImportDeclaration"]);
1059
+
1060
+ const IDENTIFIER_OR_KEYWORD = new Set(["Identifier", "Keyword"]);
1061
+
1062
+ // Keywords that can immediately precede an ExpressionStatement node, mapped to the their node types.
1063
+ const NODE_TYPES_BY_KEYWORD = {
1064
+ __proto__: null,
1065
+ break: "BreakStatement",
1066
+ continue: "ContinueStatement",
1067
+ debugger: "DebuggerStatement",
1068
+ do: "DoWhileStatement",
1069
+ else: "IfStatement",
1070
+ return: "ReturnStatement",
1071
+ yield: "YieldExpression"
1072
+ };
1073
+
1074
+ /*
1075
+ * Before an opening parenthesis, postfix `++` and `--` always trigger ASI;
1076
+ * the tokens `:`, `;`, `{` and `=>` don't expect a semicolon, as that would count as an empty statement.
1077
+ */
1078
+ const PUNCTUATORS = new Set([":", ";", "{", "=>", "++", "--"]);
1079
+
1080
+ /*
1081
+ * Statements that can contain an `ExpressionStatement` after a closing parenthesis.
1082
+ * DoWhileStatement is an exception in that it always triggers ASI after the closing parenthesis.
1083
+ */
1084
+ const STATEMENTS = new Set([
1085
+ "DoWhileStatement",
1086
+ "ForInStatement",
1087
+ "ForOfStatement",
1088
+ "ForStatement",
1089
+ "IfStatement",
1090
+ "WhileStatement",
1091
+ "WithStatement"
1092
+ ]);
1093
+
1094
+ needsPrecedingSemicolon =
1095
+ function(sourceCode, node) {
1096
+ const prevToken = sourceCode.getTokenBefore(node);
1097
+
1098
+ if (!prevToken || prevToken.type === "Punctuator" && PUNCTUATORS.has(prevToken.value)) {
1099
+ return false;
1100
+ }
1101
+
1102
+ const prevNode = sourceCode.getNodeByRangeIndex(prevToken.range[0]);
1103
+
1104
+ if (isClosingParenToken(prevToken)) {
1105
+ return !STATEMENTS.has(prevNode.type);
1106
+ }
1107
+
1108
+ if (isClosingBraceToken(prevToken)) {
1109
+ return (
1110
+ prevNode.type === "BlockStatement" && prevNode.parent.type === "FunctionExpression" && prevNode.parent.parent.type !== "MethodDefinition" ||
1111
+ prevNode.type === "ClassBody" && prevNode.parent.type === "ClassExpression" ||
1112
+ prevNode.type === "ObjectExpression"
1113
+ );
1114
+ }
1115
+
1116
+ if (IDENTIFIER_OR_KEYWORD.has(prevToken.type)) {
1117
+ if (BREAK_OR_CONTINUE.has(prevNode.parent.type)) {
1118
+ return false;
1119
+ }
1120
+
1121
+ const keyword = prevToken.value;
1122
+ const nodeType = NODE_TYPES_BY_KEYWORD[keyword];
1123
+
1124
+ return prevNode.type !== nodeType;
1125
+ }
1126
+
1127
+ if (prevToken.type === "String") {
1128
+ return !DECLARATIONS.has(prevNode.parent.type);
1129
+ }
1130
+
1131
+ return true;
1132
+ };
1133
+ }
1134
+
1135
+ //------------------------------------------------------------------------------
1136
+ // Public Interface
1137
+ //------------------------------------------------------------------------------
1138
+
1139
+ module.exports = {
1140
+ COMMENTS_IGNORE_PATTERN,
1141
+ LINEBREAKS,
1142
+ LINEBREAK_MATCHER: lineBreakPattern,
1143
+ SHEBANG_MATCHER: shebangPattern,
1144
+ STATEMENT_LIST_PARENTS,
1145
+ ECMASCRIPT_GLOBALS,
1146
+
1147
+ /**
1148
+ * Determines whether two adjacent tokens are on the same line.
1149
+ * @param {Object} left The left token object.
1150
+ * @param {Object} right The right token object.
1151
+ * @returns {boolean} Whether or not the tokens are on the same line.
1152
+ * @public
1153
+ */
1154
+ isTokenOnSameLine(left, right) {
1155
+ return left.loc.end.line === right.loc.start.line;
1156
+ },
1157
+
1158
+ isNullOrUndefined,
1159
+ isCallee,
1160
+ isES5Constructor,
1161
+ getUpperFunction,
1162
+ isFunction,
1163
+ isLoop,
1164
+ isInLoop,
1165
+ isArrayFromMethod,
1166
+ isParenthesised,
1167
+ createGlobalLinebreakMatcher,
1168
+ equalTokens,
1169
+
1170
+ isArrowToken,
1171
+ isClosingBraceToken,
1172
+ isClosingBracketToken,
1173
+ isClosingParenToken,
1174
+ isColonToken,
1175
+ isCommaToken,
1176
+ isCommentToken,
1177
+ isDotToken,
1178
+ isQuestionDotToken,
1179
+ isKeywordToken,
1180
+ isNotClosingBraceToken: negate(isClosingBraceToken),
1181
+ isNotClosingBracketToken: negate(isClosingBracketToken),
1182
+ isNotClosingParenToken: negate(isClosingParenToken),
1183
+ isNotColonToken: negate(isColonToken),
1184
+ isNotCommaToken: negate(isCommaToken),
1185
+ isNotDotToken: negate(isDotToken),
1186
+ isNotQuestionDotToken: negate(isQuestionDotToken),
1187
+ isNotOpeningBraceToken: negate(isOpeningBraceToken),
1188
+ isNotOpeningBracketToken: negate(isOpeningBracketToken),
1189
+ isNotOpeningParenToken: negate(isOpeningParenToken),
1190
+ isNotSemicolonToken: negate(isSemicolonToken),
1191
+ isOpeningBraceToken,
1192
+ isOpeningBracketToken,
1193
+ isOpeningParenToken,
1194
+ isSemicolonToken,
1195
+ isEqToken,
1196
+
1197
+ /**
1198
+ * Checks whether or not a given node is a string literal.
1199
+ * @param {ASTNode} node A node to check.
1200
+ * @returns {boolean} `true` if the node is a string literal.
1201
+ */
1202
+ isStringLiteral(node) {
1203
+ return (
1204
+ (node.type === "Literal" && typeof node.value === "string") ||
1205
+ node.type === "TemplateLiteral"
1206
+ );
1207
+ },
1208
+
1209
+ /**
1210
+ * Checks whether a given node is a breakable statement or not.
1211
+ * The node is breakable if the node is one of the following type:
1212
+ *
1213
+ * - DoWhileStatement
1214
+ * - ForInStatement
1215
+ * - ForOfStatement
1216
+ * - ForStatement
1217
+ * - SwitchStatement
1218
+ * - WhileStatement
1219
+ * @param {ASTNode} node A node to check.
1220
+ * @returns {boolean} `true` if the node is breakable.
1221
+ */
1222
+ isBreakableStatement(node) {
1223
+ return breakableTypePattern.test(node.type);
1224
+ },
1225
+
1226
+ /**
1227
+ * Gets references which are non initializer and writable.
1228
+ * @param {Reference[]} references An array of references.
1229
+ * @returns {Reference[]} An array of only references which are non initializer and writable.
1230
+ * @public
1231
+ */
1232
+ getModifyingReferences(references) {
1233
+ return references.filter(isModifyingReference);
1234
+ },
1235
+
1236
+ /**
1237
+ * Validate that a string passed in is surrounded by the specified character
1238
+ * @param {string} val The text to check.
1239
+ * @param {string} character The character to see if it's surrounded by.
1240
+ * @returns {boolean} True if the text is surrounded by the character, false if not.
1241
+ * @private
1242
+ */
1243
+ isSurroundedBy(val, character) {
1244
+ return val[0] === character && val.at(-1) === character;
1245
+ },
1246
+
1247
+ /**
1248
+ * Returns whether the provided node is an ESLint directive comment or not
1249
+ * @param {Line|Block} node The comment token to be checked
1250
+ * @returns {boolean} `true` if the node is an ESLint directive comment
1251
+ */
1252
+ isDirectiveComment(node) {
1253
+ const comment = node.value.trim();
1254
+
1255
+ return (
1256
+ node.type === "Line" && comment.startsWith("eslint-") ||
1257
+ node.type === "Block" && ESLINT_DIRECTIVE_PATTERN.test(comment)
1258
+ );
1259
+ },
1260
+
1261
+ /**
1262
+ * Gets the trailing statement of a given node.
1263
+ *
1264
+ * if (code)
1265
+ * consequent;
1266
+ *
1267
+ * When taking this `IfStatement`, returns `consequent;` statement.
1268
+ * @param {ASTNode} A node to get.
1269
+ * @returns {ASTNode|null} The trailing statement's node.
1270
+ */
1271
+ getTrailingStatement: esutils.ast.trailingStatement,
1272
+
1273
+ /**
1274
+ * Finds the variable by a given name in a given scope and its upper scopes.
1275
+ * @param {eslint-scope.Scope} initScope A scope to start find.
1276
+ * @param {string} name A variable name to find.
1277
+ * @returns {eslint-scope.Variable|null} A found variable or `null`.
1278
+ */
1279
+ getVariableByName(initScope, name) {
1280
+ let scope = initScope;
1281
+
1282
+ while (scope) {
1283
+ const variable = scope.set.get(name);
1284
+
1285
+ if (variable) {
1286
+ return variable;
1287
+ }
1288
+
1289
+ scope = scope.upper;
1290
+ }
1291
+
1292
+ return null;
1293
+ },
1294
+
1295
+ /**
1296
+ * Checks whether or not a given function node is the default `this` binding.
1297
+ *
1298
+ * First, this checks the node:
1299
+ *
1300
+ * - The given node is not in `PropertyDefinition#value` position.
1301
+ * - The given node is not `StaticBlock`.
1302
+ * - The function name does not start with uppercase. It's a convention to capitalize the names
1303
+ * of constructor functions. This check is not performed if `capIsConstructor` is set to `false`.
1304
+ * - The function does not have a JSDoc comment that has a @this tag.
1305
+ *
1306
+ * Next, this checks the location of the node.
1307
+ * If the location is below, this judges `this` is valid.
1308
+ *
1309
+ * - The location is not on an object literal.
1310
+ * - The location is not assigned to a variable which starts with an uppercase letter. Applies to anonymous
1311
+ * functions only, as the name of the variable is considered to be the name of the function in this case.
1312
+ * This check is not performed if `capIsConstructor` is set to `false`.
1313
+ * - The location is not on an ES2015 class.
1314
+ * - Its `bind`/`call`/`apply` method is not called directly.
1315
+ * - The function is not a callback of array methods (such as `.forEach()`) if `thisArg` is given.
1316
+ * @param {ASTNode} node A function node to check. It also can be an implicit function, like `StaticBlock`
1317
+ * or any expression that is `PropertyDefinition#value` node.
1318
+ * @param {SourceCode} sourceCode A SourceCode instance to get comments.
1319
+ * @param {boolean} [capIsConstructor = true] `false` disables the assumption that functions which name starts
1320
+ * with an uppercase or are assigned to a variable which name starts with an uppercase are constructors.
1321
+ * @returns {boolean} The function node is the default `this` binding.
1322
+ */
1323
+ isDefaultThisBinding(node, sourceCode, { capIsConstructor = true } = {}) {
1324
+
1325
+ /*
1326
+ * Class field initializers are implicit functions, but ESTree doesn't have the AST node of field initializers.
1327
+ * Therefore, A expression node at `PropertyDefinition#value` is a function.
1328
+ * In this case, `this` is always not default binding.
1329
+ */
1330
+ if (node.parent.type === "PropertyDefinition" && node.parent.value === node) {
1331
+ return false;
1332
+ }
1333
+
1334
+ // Class static blocks are implicit functions. In this case, `this` is always not default binding.
1335
+ if (node.type === "StaticBlock") {
1336
+ return false;
1337
+ }
1338
+
1339
+ if (
1340
+ (capIsConstructor && isES5Constructor(node)) ||
1341
+ hasJSDocThisTag(node, sourceCode)
1342
+ ) {
1343
+ return false;
1344
+ }
1345
+ const isAnonymous = node.id === null;
1346
+ let currentNode = node;
1347
+
1348
+ while (currentNode) {
1349
+ const parent = currentNode.parent;
1350
+
1351
+ switch (parent.type) {
1352
+
1353
+ /*
1354
+ * Looks up the destination.
1355
+ * e.g., obj.foo = nativeFoo || function foo() { ... };
1356
+ */
1357
+ case "LogicalExpression":
1358
+ case "ConditionalExpression":
1359
+ case "ChainExpression":
1360
+ currentNode = parent;
1361
+ break;
1362
+
1363
+ /*
1364
+ * If the upper function is IIFE, checks the destination of the return value.
1365
+ * e.g.
1366
+ * obj.foo = (function() {
1367
+ * // setup...
1368
+ * return function foo() { ... };
1369
+ * })();
1370
+ * obj.foo = (() =>
1371
+ * function foo() { ... }
1372
+ * )();
1373
+ */
1374
+ case "ReturnStatement": {
1375
+ const func = getUpperFunction(parent);
1376
+
1377
+ if (func === null || !isCallee(func)) {
1378
+ return true;
1379
+ }
1380
+ currentNode = func.parent;
1381
+ break;
1382
+ }
1383
+ case "ArrowFunctionExpression":
1384
+ if (currentNode !== parent.body || !isCallee(parent)) {
1385
+ return true;
1386
+ }
1387
+ currentNode = parent.parent;
1388
+ break;
1389
+
1390
+ /*
1391
+ * e.g.
1392
+ * var obj = { foo() { ... } };
1393
+ * var obj = { foo: function() { ... } };
1394
+ * class A { constructor() { ... } }
1395
+ * class A { foo() { ... } }
1396
+ * class A { get foo() { ... } }
1397
+ * class A { set foo() { ... } }
1398
+ * class A { static foo() { ... } }
1399
+ * class A { foo = function() { ... } }
1400
+ */
1401
+ case "Property":
1402
+ case "PropertyDefinition":
1403
+ case "MethodDefinition":
1404
+ return parent.value !== currentNode;
1405
+
1406
+ /*
1407
+ * e.g.
1408
+ * obj.foo = function foo() { ... };
1409
+ * Foo = function() { ... };
1410
+ * [obj.foo = function foo() { ... }] = a;
1411
+ * [Foo = function() { ... }] = a;
1412
+ */
1413
+ case "AssignmentExpression":
1414
+ case "AssignmentPattern":
1415
+ if (parent.left.type === "MemberExpression") {
1416
+ return false;
1417
+ }
1418
+ if (
1419
+ capIsConstructor &&
1420
+ isAnonymous &&
1421
+ parent.left.type === "Identifier" &&
1422
+ startsWithUpperCase(parent.left.name)
1423
+ ) {
1424
+ return false;
1425
+ }
1426
+ return true;
1427
+
1428
+ /*
1429
+ * e.g.
1430
+ * var Foo = function() { ... };
1431
+ */
1432
+ case "VariableDeclarator":
1433
+ return !(
1434
+ capIsConstructor &&
1435
+ isAnonymous &&
1436
+ parent.init === currentNode &&
1437
+ parent.id.type === "Identifier" &&
1438
+ startsWithUpperCase(parent.id.name)
1439
+ );
1440
+
1441
+ /*
1442
+ * e.g.
1443
+ * var foo = function foo() { ... }.bind(obj);
1444
+ * (function foo() { ... }).call(obj);
1445
+ * (function foo() { ... }).apply(obj, []);
1446
+ */
1447
+ case "MemberExpression":
1448
+ if (
1449
+ parent.object === currentNode &&
1450
+ isSpecificMemberAccess(parent, null, bindOrCallOrApplyPattern)
1451
+ ) {
1452
+ const maybeCalleeNode = parent.parent.type === "ChainExpression"
1453
+ ? parent.parent
1454
+ : parent;
1455
+
1456
+ return !(
1457
+ isCallee(maybeCalleeNode) &&
1458
+ maybeCalleeNode.parent.arguments.length >= 1 &&
1459
+ !isNullOrUndefined(maybeCalleeNode.parent.arguments[0])
1460
+ );
1461
+ }
1462
+ return true;
1463
+
1464
+ /*
1465
+ * e.g.
1466
+ * Reflect.apply(function() {}, obj, []);
1467
+ * Array.from([], function() {}, obj);
1468
+ * list.forEach(function() {}, obj);
1469
+ */
1470
+ case "CallExpression":
1471
+ if (isReflectApply(parent.callee)) {
1472
+ return (
1473
+ parent.arguments.length !== 3 ||
1474
+ parent.arguments[0] !== currentNode ||
1475
+ isNullOrUndefined(parent.arguments[1])
1476
+ );
1477
+ }
1478
+ if (isArrayFromMethod(parent.callee)) {
1479
+ return (
1480
+ parent.arguments.length !== 3 ||
1481
+ parent.arguments[1] !== currentNode ||
1482
+ isNullOrUndefined(parent.arguments[2])
1483
+ );
1484
+ }
1485
+ if (isMethodWhichHasThisArg(parent.callee)) {
1486
+ return (
1487
+ parent.arguments.length !== 2 ||
1488
+ parent.arguments[0] !== currentNode ||
1489
+ isNullOrUndefined(parent.arguments[1])
1490
+ );
1491
+ }
1492
+ return true;
1493
+
1494
+ // Otherwise `this` is default.
1495
+ default:
1496
+ return true;
1497
+ }
1498
+ }
1499
+
1500
+ /* c8 ignore next */
1501
+ return true;
1502
+ },
1503
+
1504
+ /**
1505
+ * Get the precedence level based on the node type
1506
+ * @param {ASTNode} node node to evaluate
1507
+ * @returns {int} precedence level
1508
+ * @private
1509
+ */
1510
+ getPrecedence(node) {
1511
+ switch (node.type) {
1512
+ case "SequenceExpression":
1513
+ return 0;
1514
+
1515
+ case "AssignmentExpression":
1516
+ case "ArrowFunctionExpression":
1517
+ case "YieldExpression":
1518
+ return 1;
1519
+
1520
+ case "ConditionalExpression":
1521
+ return 3;
1522
+
1523
+ case "LogicalExpression":
1524
+ switch (node.operator) {
1525
+ case "||":
1526
+ case "??":
1527
+ return 4;
1528
+ case "&&":
1529
+ return 5;
1530
+
1531
+ // no default
1532
+ }
1533
+
1534
+ /* falls through */
1535
+
1536
+ case "BinaryExpression":
1537
+
1538
+ switch (node.operator) {
1539
+ case "|":
1540
+ return 6;
1541
+ case "^":
1542
+ return 7;
1543
+ case "&":
1544
+ return 8;
1545
+ case "==":
1546
+ case "!=":
1547
+ case "===":
1548
+ case "!==":
1549
+ return 9;
1550
+ case "<":
1551
+ case "<=":
1552
+ case ">":
1553
+ case ">=":
1554
+ case "in":
1555
+ case "instanceof":
1556
+ return 10;
1557
+ case "<<":
1558
+ case ">>":
1559
+ case ">>>":
1560
+ return 11;
1561
+ case "+":
1562
+ case "-":
1563
+ return 12;
1564
+ case "*":
1565
+ case "/":
1566
+ case "%":
1567
+ return 13;
1568
+ case "**":
1569
+ return 15;
1570
+
1571
+ // no default
1572
+ }
1573
+
1574
+ /* falls through */
1575
+
1576
+ case "UnaryExpression":
1577
+ case "AwaitExpression":
1578
+ return 16;
1579
+
1580
+ case "UpdateExpression":
1581
+ return 17;
1582
+
1583
+ case "CallExpression":
1584
+ case "ChainExpression":
1585
+ case "ImportExpression":
1586
+ return 18;
1587
+
1588
+ case "NewExpression":
1589
+ return 19;
1590
+
1591
+ default:
1592
+ if (node.type in eslintVisitorKeys) {
1593
+ return 20;
1594
+ }
1595
+
1596
+ /*
1597
+ * if the node is not a standard node that we know about, then assume it has the lowest precedence
1598
+ * this will mean that rules will wrap unknown nodes in parentheses where applicable instead of
1599
+ * unwrapping them and potentially changing the meaning of the code or introducing a syntax error.
1600
+ */
1601
+ return -1;
1602
+ }
1603
+ },
1604
+
1605
+ /**
1606
+ * Checks whether the given node is an empty block node or not.
1607
+ * @param {ASTNode|null} node The node to check.
1608
+ * @returns {boolean} `true` if the node is an empty block.
1609
+ */
1610
+ isEmptyBlock(node) {
1611
+ return Boolean(node && node.type === "BlockStatement" && node.body.length === 0);
1612
+ },
1613
+
1614
+ /**
1615
+ * Checks whether the given node is an empty function node or not.
1616
+ * @param {ASTNode|null} node The node to check.
1617
+ * @returns {boolean} `true` if the node is an empty function.
1618
+ */
1619
+ isEmptyFunction(node) {
1620
+ return isFunction(node) && module.exports.isEmptyBlock(node.body);
1621
+ },
1622
+
1623
+ /**
1624
+ * Get directives from directive prologue of a Program or Function node.
1625
+ * @param {ASTNode} node The node to check.
1626
+ * @returns {ASTNode[]} The directives found in the directive prologue.
1627
+ */
1628
+ getDirectivePrologue(node) {
1629
+ const directives = [];
1630
+
1631
+ // Directive prologues only occur at the top of files or functions.
1632
+ if (
1633
+ node.type === "Program" ||
1634
+ node.type === "FunctionDeclaration" ||
1635
+ node.type === "FunctionExpression" ||
1636
+
1637
+ /*
1638
+ * Do not check arrow functions with implicit return.
1639
+ * `() => "use strict";` returns the string `"use strict"`.
1640
+ */
1641
+ (node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement")
1642
+ ) {
1643
+ const statements = node.type === "Program" ? node.body : node.body.body;
1644
+
1645
+ for (const statement of statements) {
1646
+ if (
1647
+ statement.type === "ExpressionStatement" &&
1648
+ statement.expression.type === "Literal"
1649
+ ) {
1650
+ directives.push(statement);
1651
+ } else {
1652
+ break;
1653
+ }
1654
+ }
1655
+ }
1656
+
1657
+ return directives;
1658
+ },
1659
+
1660
+ /**
1661
+ * Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added
1662
+ * after the node will be parsed as a decimal point, rather than a property-access dot.
1663
+ * @param {ASTNode} node The node to check.
1664
+ * @returns {boolean} `true` if this node is a decimal integer.
1665
+ * @example
1666
+ *
1667
+ * 0 // true
1668
+ * 5 // true
1669
+ * 50 // true
1670
+ * 5_000 // true
1671
+ * 1_234_56 // true
1672
+ * 08 // true
1673
+ * 0192 // true
1674
+ * 5. // false
1675
+ * .5 // false
1676
+ * 5.0 // false
1677
+ * 5.00_00 // false
1678
+ * 05 // false
1679
+ * 0x5 // false
1680
+ * 0b101 // false
1681
+ * 0b11_01 // false
1682
+ * 0o5 // false
1683
+ * 5e0 // false
1684
+ * 5e1_000 // false
1685
+ * 5n // false
1686
+ * 1_000n // false
1687
+ * "5" // false
1688
+ *
1689
+ */
1690
+ isDecimalInteger(node) {
1691
+ return node.type === "Literal" && typeof node.value === "number" &&
1692
+ DECIMAL_INTEGER_PATTERN.test(node.raw);
1693
+ },
1694
+
1695
+ /**
1696
+ * Determines whether this token is a decimal integer numeric token.
1697
+ * This is similar to isDecimalInteger(), but for tokens.
1698
+ * @param {Token} token The token to check.
1699
+ * @returns {boolean} `true` if this token is a decimal integer.
1700
+ */
1701
+ isDecimalIntegerNumericToken(token) {
1702
+ return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value);
1703
+ },
1704
+
1705
+ /**
1706
+ * Gets the name and kind of the given function node.
1707
+ *
1708
+ * - `function foo() {}` .................... `function 'foo'`
1709
+ * - `(function foo() {})` .................. `function 'foo'`
1710
+ * - `(function() {})` ...................... `function`
1711
+ * - `function* foo() {}` ................... `generator function 'foo'`
1712
+ * - `(function* foo() {})` ................. `generator function 'foo'`
1713
+ * - `(function*() {})` ..................... `generator function`
1714
+ * - `() => {}` ............................. `arrow function`
1715
+ * - `async () => {}` ....................... `async arrow function`
1716
+ * - `({ foo: function foo() {} })` ......... `method 'foo'`
1717
+ * - `({ foo: function() {} })` ............. `method 'foo'`
1718
+ * - `({ ['foo']: function() {} })` ......... `method 'foo'`
1719
+ * - `({ [foo]: function() {} })` ........... `method`
1720
+ * - `({ foo() {} })` ....................... `method 'foo'`
1721
+ * - `({ foo: function* foo() {} })` ........ `generator method 'foo'`
1722
+ * - `({ foo: function*() {} })` ............ `generator method 'foo'`
1723
+ * - `({ ['foo']: function*() {} })` ........ `generator method 'foo'`
1724
+ * - `({ [foo]: function*() {} })` .......... `generator method`
1725
+ * - `({ *foo() {} })` ...................... `generator method 'foo'`
1726
+ * - `({ foo: async function foo() {} })` ... `async method 'foo'`
1727
+ * - `({ foo: async function() {} })` ....... `async method 'foo'`
1728
+ * - `({ ['foo']: async function() {} })` ... `async method 'foo'`
1729
+ * - `({ [foo]: async function() {} })` ..... `async method`
1730
+ * - `({ async foo() {} })` ................. `async method 'foo'`
1731
+ * - `({ get foo() {} })` ................... `getter 'foo'`
1732
+ * - `({ set foo(a) {} })` .................. `setter 'foo'`
1733
+ * - `class A { constructor() {} }` ......... `constructor`
1734
+ * - `class A { foo() {} }` ................. `method 'foo'`
1735
+ * - `class A { *foo() {} }` ................ `generator method 'foo'`
1736
+ * - `class A { async foo() {} }` ........... `async method 'foo'`
1737
+ * - `class A { ['foo']() {} }` ............. `method 'foo'`
1738
+ * - `class A { *['foo']() {} }` ............ `generator method 'foo'`
1739
+ * - `class A { async ['foo']() {} }` ....... `async method 'foo'`
1740
+ * - `class A { [foo]() {} }` ............... `method`
1741
+ * - `class A { *[foo]() {} }` .............. `generator method`
1742
+ * - `class A { async [foo]() {} }` ......... `async method`
1743
+ * - `class A { get foo() {} }` ............. `getter 'foo'`
1744
+ * - `class A { set foo(a) {} }` ............ `setter 'foo'`
1745
+ * - `class A { static foo() {} }` .......... `static method 'foo'`
1746
+ * - `class A { static *foo() {} }` ......... `static generator method 'foo'`
1747
+ * - `class A { static async foo() {} }` .... `static async method 'foo'`
1748
+ * - `class A { static get foo() {} }` ...... `static getter 'foo'`
1749
+ * - `class A { static set foo(a) {} }` ..... `static setter 'foo'`
1750
+ * - `class A { foo = () => {}; }` .......... `method 'foo'`
1751
+ * - `class A { foo = function() {}; }` ..... `method 'foo'`
1752
+ * - `class A { foo = function bar() {}; }` . `method 'foo'`
1753
+ * - `class A { static foo = () => {}; }` ... `static method 'foo'`
1754
+ * - `class A { '#foo' = () => {}; }` ....... `method '#foo'`
1755
+ * - `class A { #foo = () => {}; }` ......... `private method #foo`
1756
+ * - `class A { static #foo = () => {}; }` .. `static private method #foo`
1757
+ * - `class A { '#foo'() {} }` .............. `method '#foo'`
1758
+ * - `class A { #foo() {} }` ................ `private method #foo`
1759
+ * - `class A { static #foo() {} }` ......... `static private method #foo`
1760
+ * @param {ASTNode} node The function node to get.
1761
+ * @returns {string} The name and kind of the function node.
1762
+ */
1763
+ getFunctionNameWithKind(node) {
1764
+ const parent = node.parent;
1765
+ const tokens = [];
1766
+
1767
+ if (parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
1768
+
1769
+ // The proposal uses `static` word consistently before visibility words: https://github.com/tc39/proposal-static-class-features
1770
+ if (parent.static) {
1771
+ tokens.push("static");
1772
+ }
1773
+ if (!parent.computed && parent.key.type === "PrivateIdentifier") {
1774
+ tokens.push("private");
1775
+ }
1776
+ }
1777
+ if (node.async) {
1778
+ tokens.push("async");
1779
+ }
1780
+ if (node.generator) {
1781
+ tokens.push("generator");
1782
+ }
1783
+
1784
+ if (parent.type === "Property" || parent.type === "MethodDefinition") {
1785
+ if (parent.kind === "constructor") {
1786
+ return "constructor";
1787
+ }
1788
+ if (parent.kind === "get") {
1789
+ tokens.push("getter");
1790
+ } else if (parent.kind === "set") {
1791
+ tokens.push("setter");
1792
+ } else {
1793
+ tokens.push("method");
1794
+ }
1795
+ } else if (parent.type === "PropertyDefinition") {
1796
+ tokens.push("method");
1797
+ } else {
1798
+ if (node.type === "ArrowFunctionExpression") {
1799
+ tokens.push("arrow");
1800
+ }
1801
+ tokens.push("function");
1802
+ }
1803
+
1804
+ if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
1805
+ if (!parent.computed && parent.key.type === "PrivateIdentifier") {
1806
+ tokens.push(`#${parent.key.name}`);
1807
+ } else {
1808
+ const name = getStaticPropertyName(parent);
1809
+
1810
+ if (name !== null) {
1811
+ tokens.push(`'${name}'`);
1812
+ } else if (node.id) {
1813
+ tokens.push(`'${node.id.name}'`);
1814
+ }
1815
+ }
1816
+ } else if (node.id) {
1817
+ tokens.push(`'${node.id.name}'`);
1818
+ }
1819
+
1820
+ return tokens.join(" ");
1821
+ },
1822
+
1823
+ /**
1824
+ * Gets the location of the given function node for reporting.
1825
+ *
1826
+ * - `function foo() {}`
1827
+ * ^^^^^^^^^^^^
1828
+ * - `(function foo() {})`
1829
+ * ^^^^^^^^^^^^
1830
+ * - `(function() {})`
1831
+ * ^^^^^^^^
1832
+ * - `function* foo() {}`
1833
+ * ^^^^^^^^^^^^^
1834
+ * - `(function* foo() {})`
1835
+ * ^^^^^^^^^^^^^
1836
+ * - `(function*() {})`
1837
+ * ^^^^^^^^^
1838
+ * - `() => {}`
1839
+ * ^^
1840
+ * - `async () => {}`
1841
+ * ^^
1842
+ * - `({ foo: function foo() {} })`
1843
+ * ^^^^^^^^^^^^^^^^^
1844
+ * - `({ foo: function() {} })`
1845
+ * ^^^^^^^^^^^^^
1846
+ * - `({ ['foo']: function() {} })`
1847
+ * ^^^^^^^^^^^^^^^^^
1848
+ * - `({ [foo]: function() {} })`
1849
+ * ^^^^^^^^^^^^^^^
1850
+ * - `({ foo() {} })`
1851
+ * ^^^
1852
+ * - `({ foo: function* foo() {} })`
1853
+ * ^^^^^^^^^^^^^^^^^^
1854
+ * - `({ foo: function*() {} })`
1855
+ * ^^^^^^^^^^^^^^
1856
+ * - `({ ['foo']: function*() {} })`
1857
+ * ^^^^^^^^^^^^^^^^^^
1858
+ * - `({ [foo]: function*() {} })`
1859
+ * ^^^^^^^^^^^^^^^^
1860
+ * - `({ *foo() {} })`
1861
+ * ^^^^
1862
+ * - `({ foo: async function foo() {} })`
1863
+ * ^^^^^^^^^^^^^^^^^^^^^^^
1864
+ * - `({ foo: async function() {} })`
1865
+ * ^^^^^^^^^^^^^^^^^^^
1866
+ * - `({ ['foo']: async function() {} })`
1867
+ * ^^^^^^^^^^^^^^^^^^^^^^^
1868
+ * - `({ [foo]: async function() {} })`
1869
+ * ^^^^^^^^^^^^^^^^^^^^^
1870
+ * - `({ async foo() {} })`
1871
+ * ^^^^^^^^^
1872
+ * - `({ get foo() {} })`
1873
+ * ^^^^^^^
1874
+ * - `({ set foo(a) {} })`
1875
+ * ^^^^^^^
1876
+ * - `class A { constructor() {} }`
1877
+ * ^^^^^^^^^^^
1878
+ * - `class A { foo() {} }`
1879
+ * ^^^
1880
+ * - `class A { *foo() {} }`
1881
+ * ^^^^
1882
+ * - `class A { async foo() {} }`
1883
+ * ^^^^^^^^^
1884
+ * - `class A { ['foo']() {} }`
1885
+ * ^^^^^^^
1886
+ * - `class A { *['foo']() {} }`
1887
+ * ^^^^^^^^
1888
+ * - `class A { async ['foo']() {} }`
1889
+ * ^^^^^^^^^^^^^
1890
+ * - `class A { [foo]() {} }`
1891
+ * ^^^^^
1892
+ * - `class A { *[foo]() {} }`
1893
+ * ^^^^^^
1894
+ * - `class A { async [foo]() {} }`
1895
+ * ^^^^^^^^^^^
1896
+ * - `class A { get foo() {} }`
1897
+ * ^^^^^^^
1898
+ * - `class A { set foo(a) {} }`
1899
+ * ^^^^^^^
1900
+ * - `class A { static foo() {} }`
1901
+ * ^^^^^^^^^^
1902
+ * - `class A { static *foo() {} }`
1903
+ * ^^^^^^^^^^^
1904
+ * - `class A { static async foo() {} }`
1905
+ * ^^^^^^^^^^^^^^^^
1906
+ * - `class A { static get foo() {} }`
1907
+ * ^^^^^^^^^^^^^^
1908
+ * - `class A { static set foo(a) {} }`
1909
+ * ^^^^^^^^^^^^^^
1910
+ * - `class A { foo = function() {} }`
1911
+ * ^^^^^^^^^^^^^^
1912
+ * - `class A { static foo = function() {} }`
1913
+ * ^^^^^^^^^^^^^^^^^^^^^
1914
+ * - `class A { foo = (a, b) => {} }`
1915
+ * ^^^^^^
1916
+ * @param {ASTNode} node The function node to get.
1917
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1918
+ * @returns {string} The location of the function node for reporting.
1919
+ */
1920
+ getFunctionHeadLoc(node, sourceCode) {
1921
+ const parent = node.parent;
1922
+ let start;
1923
+ let end;
1924
+
1925
+ if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
1926
+ start = parent.loc.start;
1927
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
1928
+ } else if (node.type === "ArrowFunctionExpression") {
1929
+ const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
1930
+
1931
+ start = arrowToken.loc.start;
1932
+ end = arrowToken.loc.end;
1933
+ } else {
1934
+ start = node.loc.start;
1935
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
1936
+ }
1937
+
1938
+ return {
1939
+ start: Object.assign({}, start),
1940
+ end: Object.assign({}, end)
1941
+ };
1942
+ },
1943
+
1944
+ /**
1945
+ * Gets next location when the result is not out of bound, otherwise returns null.
1946
+ *
1947
+ * Assumptions:
1948
+ *
1949
+ * - The given location represents a valid location in the given source code.
1950
+ * - Columns are 0-based.
1951
+ * - Lines are 1-based.
1952
+ * - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location.
1953
+ * - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end.
1954
+ * The start (column 0) of that extra line is considered to be a valid location.
1955
+ *
1956
+ * Examples of successive locations (line, column):
1957
+ *
1958
+ * code: foo
1959
+ * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null
1960
+ *
1961
+ * code: foo<LF>
1962
+ * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
1963
+ *
1964
+ * code: foo<CR><LF>
1965
+ * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
1966
+ *
1967
+ * code: a<LF>b
1968
+ * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null
1969
+ *
1970
+ * code: a<LF>b<LF>
1971
+ * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
1972
+ *
1973
+ * code: a<CR><LF>b<CR><LF>
1974
+ * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
1975
+ *
1976
+ * code: a<LF><LF>
1977
+ * locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null
1978
+ *
1979
+ * code: <LF>
1980
+ * locations: (1, 0) -> (2, 0) -> null
1981
+ *
1982
+ * code:
1983
+ * locations: (1, 0) -> null
1984
+ * @param {SourceCode} sourceCode The sourceCode
1985
+ * @param {{line: number, column: number}} location The location
1986
+ * @returns {{line: number, column: number} | null} Next location
1987
+ */
1988
+ getNextLocation(sourceCode, { line, column }) {
1989
+ if (column < sourceCode.lines[line - 1].length) {
1990
+ return {
1991
+ line,
1992
+ column: column + 1
1993
+ };
1994
+ }
1995
+
1996
+ if (line < sourceCode.lines.length) {
1997
+ return {
1998
+ line: line + 1,
1999
+ column: 0
2000
+ };
2001
+ }
2002
+
2003
+ return null;
2004
+ },
2005
+
2006
+ /**
2007
+ * Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses
2008
+ * surrounding the node.
2009
+ * @param {SourceCode} sourceCode The source code object
2010
+ * @param {ASTNode} node An expression node
2011
+ * @returns {string} The text representing the node, with all surrounding parentheses included
2012
+ */
2013
+ getParenthesisedText(sourceCode, node) {
2014
+ let leftToken = sourceCode.getFirstToken(node);
2015
+ let rightToken = sourceCode.getLastToken(node);
2016
+
2017
+ while (
2018
+ sourceCode.getTokenBefore(leftToken) &&
2019
+ sourceCode.getTokenBefore(leftToken).type === "Punctuator" &&
2020
+ sourceCode.getTokenBefore(leftToken).value === "(" &&
2021
+ sourceCode.getTokenAfter(rightToken) &&
2022
+ sourceCode.getTokenAfter(rightToken).type === "Punctuator" &&
2023
+ sourceCode.getTokenAfter(rightToken).value === ")"
2024
+ ) {
2025
+ leftToken = sourceCode.getTokenBefore(leftToken);
2026
+ rightToken = sourceCode.getTokenAfter(rightToken);
2027
+ }
2028
+
2029
+ return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]);
2030
+ },
2031
+
2032
+ /**
2033
+ * Determine if a node has a possibility to be an Error object
2034
+ * @param {ASTNode} node ASTNode to check
2035
+ * @returns {boolean} True if there is a chance it contains an Error obj
2036
+ */
2037
+ couldBeError(node) {
2038
+ switch (node.type) {
2039
+ case "Identifier":
2040
+ case "CallExpression":
2041
+ case "NewExpression":
2042
+ case "MemberExpression":
2043
+ case "TaggedTemplateExpression":
2044
+ case "YieldExpression":
2045
+ case "AwaitExpression":
2046
+ case "ChainExpression":
2047
+ return true; // possibly an error object.
2048
+
2049
+ case "AssignmentExpression":
2050
+ if (["=", "&&="].includes(node.operator)) {
2051
+ return module.exports.couldBeError(node.right);
2052
+ }
2053
+
2054
+ if (["||=", "??="].includes(node.operator)) {
2055
+ return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
2056
+ }
2057
+
2058
+ /**
2059
+ * All other assignment operators are mathematical assignment operators (arithmetic or bitwise).
2060
+ * An assignment expression with a mathematical operator can either evaluate to a primitive value,
2061
+ * or throw, depending on the operands. Thus, it cannot evaluate to an `Error` object.
2062
+ */
2063
+ return false;
2064
+
2065
+ case "SequenceExpression": {
2066
+ const exprs = node.expressions;
2067
+
2068
+ return exprs.length !== 0 && module.exports.couldBeError(exprs.at(-1));
2069
+ }
2070
+
2071
+ case "LogicalExpression":
2072
+
2073
+ /*
2074
+ * If the && operator short-circuits, the left side was falsy and therefore not an error, and if it
2075
+ * doesn't short-circuit, it takes the value from the right side, so the right side must always be
2076
+ * a plausible error. A future improvement could verify that the left side could be truthy by
2077
+ * excluding falsy literals.
2078
+ */
2079
+ if (node.operator === "&&") {
2080
+ return module.exports.couldBeError(node.right);
2081
+ }
2082
+
2083
+ return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
2084
+
2085
+ case "ConditionalExpression":
2086
+ return module.exports.couldBeError(node.consequent) || module.exports.couldBeError(node.alternate);
2087
+
2088
+ default:
2089
+ return false;
2090
+ }
2091
+ },
2092
+
2093
+ /**
2094
+ * Check if a given node is a numeric literal or not.
2095
+ * @param {ASTNode} node The node to check.
2096
+ * @returns {boolean} `true` if the node is a number or bigint literal.
2097
+ */
2098
+ isNumericLiteral(node) {
2099
+ return (
2100
+ node.type === "Literal" &&
2101
+ (typeof node.value === "number" || Boolean(node.bigint))
2102
+ );
2103
+ },
2104
+
2105
+ /**
2106
+ * Determines whether two tokens can safely be placed next to each other without merging into a single token
2107
+ * @param {Token|string} leftValue The left token. If this is a string, it will be tokenized and the last token will be used.
2108
+ * @param {Token|string} rightValue The right token. If this is a string, it will be tokenized and the first token will be used.
2109
+ * @returns {boolean} If the tokens cannot be safely placed next to each other, returns `false`. If the tokens can be placed
2110
+ * next to each other, behavior is undefined (although it should return `true` in most cases).
2111
+ */
2112
+ canTokensBeAdjacent(leftValue, rightValue) {
2113
+ const espreeOptions = {
2114
+ ecmaVersion: espree.latestEcmaVersion,
2115
+ comment: true,
2116
+ range: true
2117
+ };
2118
+
2119
+ let leftToken;
2120
+
2121
+ if (typeof leftValue === "string") {
2122
+ let tokens;
2123
+
2124
+ try {
2125
+ tokens = espree.tokenize(leftValue, espreeOptions);
2126
+ } catch {
2127
+ return false;
2128
+ }
2129
+
2130
+ const comments = tokens.comments;
2131
+
2132
+ leftToken = tokens.at(-1);
2133
+ if (comments.length) {
2134
+ const lastComment = comments.at(-1);
2135
+
2136
+ if (!leftToken || lastComment.range[0] > leftToken.range[0]) {
2137
+ leftToken = lastComment;
2138
+ }
2139
+ }
2140
+ } else {
2141
+ leftToken = leftValue;
2142
+ }
2143
+
2144
+ /*
2145
+ * If a hashbang comment was passed as a token object from SourceCode,
2146
+ * its type will be "Shebang" because of the way ESLint itself handles hashbangs.
2147
+ * If a hashbang comment was passed in a string and then tokenized in this function,
2148
+ * its type will be "Hashbang" because of the way Espree tokenizes hashbangs.
2149
+ */
2150
+ if (leftToken.type === "Shebang" || leftToken.type === "Hashbang") {
2151
+ return false;
2152
+ }
2153
+
2154
+ let rightToken;
2155
+
2156
+ if (typeof rightValue === "string") {
2157
+ let tokens;
2158
+
2159
+ try {
2160
+ tokens = espree.tokenize(rightValue, espreeOptions);
2161
+ } catch {
2162
+ return false;
2163
+ }
2164
+
2165
+ const comments = tokens.comments;
2166
+
2167
+ rightToken = tokens[0];
2168
+ if (comments.length) {
2169
+ const firstComment = comments[0];
2170
+
2171
+ if (!rightToken || firstComment.range[0] < rightToken.range[0]) {
2172
+ rightToken = firstComment;
2173
+ }
2174
+ }
2175
+ } else {
2176
+ rightToken = rightValue;
2177
+ }
2178
+
2179
+ if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") {
2180
+ if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") {
2181
+ const PLUS_TOKENS = new Set(["+", "++"]);
2182
+ const MINUS_TOKENS = new Set(["-", "--"]);
2183
+
2184
+ return !(
2185
+ PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) ||
2186
+ MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value)
2187
+ );
2188
+ }
2189
+ if (leftToken.type === "Punctuator" && leftToken.value === "/") {
2190
+ return !["Block", "Line", "RegularExpression"].includes(rightToken.type);
2191
+ }
2192
+ return true;
2193
+ }
2194
+
2195
+ if (
2196
+ leftToken.type === "String" || rightToken.type === "String" ||
2197
+ leftToken.type === "Template" || rightToken.type === "Template"
2198
+ ) {
2199
+ return true;
2200
+ }
2201
+
2202
+ if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith(".")) {
2203
+ return true;
2204
+ }
2205
+
2206
+ if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line") {
2207
+ return true;
2208
+ }
2209
+
2210
+ if (rightToken.type === "PrivateIdentifier") {
2211
+ return true;
2212
+ }
2213
+
2214
+ return false;
2215
+ },
2216
+
2217
+ /**
2218
+ * Get the `loc` object of a given name in a `/*globals` directive comment.
2219
+ * @param {SourceCode} sourceCode The source code to convert index to loc.
2220
+ * @param {Comment} comment The `/*globals` directive comment which include the name.
2221
+ * @param {string} name The name to find.
2222
+ * @returns {SourceLocation} The `loc` object.
2223
+ */
2224
+ getNameLocationInGlobalDirectiveComment(sourceCode, comment, name) {
2225
+ const namePattern = new RegExp(`[\\s,]${escapeRegExp(name)}(?:$|[\\s,:])`, "gu");
2226
+
2227
+ // To ignore the first text "global".
2228
+ namePattern.lastIndex = comment.value.indexOf("global") + 6;
2229
+
2230
+ // Search a given variable name.
2231
+ const match = namePattern.exec(comment.value);
2232
+
2233
+ // Convert the index to loc.
2234
+ const start = sourceCode.getLocFromIndex(
2235
+ comment.range[0] +
2236
+ "/*".length +
2237
+ (match ? match.index + 1 : 0)
2238
+ );
2239
+ const end = {
2240
+ line: start.line,
2241
+ column: start.column + (match ? name.length : 1)
2242
+ };
2243
+
2244
+ return { start, end };
2245
+ },
2246
+
2247
+ /**
2248
+ * Determines whether the given raw string contains an octal escape sequence
2249
+ * or a non-octal decimal escape sequence ("\8", "\9").
2250
+ *
2251
+ * "\1", "\2" ... "\7", "\8", "\9"
2252
+ * "\00", "\01" ... "\07", "\08", "\09"
2253
+ *
2254
+ * "\0", when not followed by a digit, is not an octal escape sequence.
2255
+ * @param {string} rawString A string in its raw representation.
2256
+ * @returns {boolean} `true` if the string contains at least one octal escape sequence
2257
+ * or at least one non-octal decimal escape sequence.
2258
+ */
2259
+ hasOctalOrNonOctalDecimalEscapeSequence(rawString) {
2260
+ return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString);
2261
+ },
2262
+
2263
+ /**
2264
+ * Determines whether the given node is a template literal without expressions.
2265
+ * @param {ASTNode} node Node to check.
2266
+ * @returns {boolean} True if the node is a template literal without expressions.
2267
+ */
2268
+ isStaticTemplateLiteral(node) {
2269
+ return node.type === "TemplateLiteral" && node.expressions.length === 0;
2270
+ },
2271
+
2272
+ isReferenceToGlobalVariable,
2273
+ isLogicalExpression,
2274
+ isCoalesceExpression,
2275
+ isMixedLogicalAndCoalesceExpressions,
2276
+ isNullLiteral,
2277
+ getStaticStringValue,
2278
+ getStaticPropertyName,
2279
+ skipChainExpression,
2280
+ isSpecificId,
2281
+ isSpecificMemberAccess,
2282
+ equalLiteralValue,
2283
+ isSameReference,
2284
+ isLogicalAssignmentOperator,
2285
+ getSwitchCaseColonToken,
2286
+ getModuleExportName,
2287
+ isConstant,
2288
+ isTopLevelExpressionStatement,
2289
+ isDirective,
2290
+ isStartOfExpressionStatement,
2291
+ needsPrecedingSemicolon
2292
+ };