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