@alexlit/lint-kit 166.0.1 → 167.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (603) hide show
  1. package/package.json +1 -1
  2. package/packages/config-commitlint/package.json +3 -3
  3. package/packages/config-eslint/package.json +4 -4
  4. package/scripts/lint.eslint.sh +1 -1
  5. package/packages/config-eslint/node_modules/@eslint/js/LICENSE +0 -19
  6. package/packages/config-eslint/node_modules/@eslint/js/README.md +0 -103
  7. package/packages/config-eslint/node_modules/@eslint/js/package.json +0 -36
  8. package/packages/config-eslint/node_modules/@eslint/js/src/configs/eslint-all.js +0 -217
  9. package/packages/config-eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js +0 -79
  10. package/packages/config-eslint/node_modules/@eslint/js/src/index.js +0 -23
  11. package/packages/config-eslint/node_modules/@eslint/js/types/index.d.ts +0 -14
  12. package/packages/config-eslint/node_modules/ajv/.tonic_example.js +0 -20
  13. package/packages/config-eslint/node_modules/ajv/LICENSE +0 -22
  14. package/packages/config-eslint/node_modules/ajv/README.md +0 -1497
  15. package/packages/config-eslint/node_modules/ajv/dist/ajv.bundle.js +0 -7189
  16. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js +0 -3
  17. package/packages/config-eslint/node_modules/ajv/dist/ajv.min.js.map +0 -1
  18. package/packages/config-eslint/node_modules/ajv/lib/ajv.d.ts +0 -397
  19. package/packages/config-eslint/node_modules/ajv/lib/ajv.js +0 -506
  20. package/packages/config-eslint/node_modules/ajv/lib/cache.js +0 -26
  21. package/packages/config-eslint/node_modules/ajv/lib/compile/async.js +0 -90
  22. package/packages/config-eslint/node_modules/ajv/lib/compile/equal.js +0 -5
  23. package/packages/config-eslint/node_modules/ajv/lib/compile/error_classes.js +0 -34
  24. package/packages/config-eslint/node_modules/ajv/lib/compile/formats.js +0 -142
  25. package/packages/config-eslint/node_modules/ajv/lib/compile/index.js +0 -387
  26. package/packages/config-eslint/node_modules/ajv/lib/compile/resolve.js +0 -270
  27. package/packages/config-eslint/node_modules/ajv/lib/compile/rules.js +0 -66
  28. package/packages/config-eslint/node_modules/ajv/lib/compile/schema_obj.js +0 -9
  29. package/packages/config-eslint/node_modules/ajv/lib/compile/ucs2length.js +0 -20
  30. package/packages/config-eslint/node_modules/ajv/lib/compile/util.js +0 -239
  31. package/packages/config-eslint/node_modules/ajv/lib/data.js +0 -49
  32. package/packages/config-eslint/node_modules/ajv/lib/definition_schema.js +0 -37
  33. package/packages/config-eslint/node_modules/ajv/lib/dot/_limit.jst +0 -113
  34. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitItems.jst +0 -12
  35. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitLength.jst +0 -12
  36. package/packages/config-eslint/node_modules/ajv/lib/dot/_limitProperties.jst +0 -12
  37. package/packages/config-eslint/node_modules/ajv/lib/dot/allOf.jst +0 -32
  38. package/packages/config-eslint/node_modules/ajv/lib/dot/anyOf.jst +0 -46
  39. package/packages/config-eslint/node_modules/ajv/lib/dot/coerce.def +0 -51
  40. package/packages/config-eslint/node_modules/ajv/lib/dot/comment.jst +0 -9
  41. package/packages/config-eslint/node_modules/ajv/lib/dot/const.jst +0 -11
  42. package/packages/config-eslint/node_modules/ajv/lib/dot/contains.jst +0 -55
  43. package/packages/config-eslint/node_modules/ajv/lib/dot/custom.jst +0 -191
  44. package/packages/config-eslint/node_modules/ajv/lib/dot/defaults.def +0 -47
  45. package/packages/config-eslint/node_modules/ajv/lib/dot/definitions.def +0 -203
  46. package/packages/config-eslint/node_modules/ajv/lib/dot/dependencies.jst +0 -79
  47. package/packages/config-eslint/node_modules/ajv/lib/dot/enum.jst +0 -30
  48. package/packages/config-eslint/node_modules/ajv/lib/dot/errors.def +0 -194
  49. package/packages/config-eslint/node_modules/ajv/lib/dot/format.jst +0 -106
  50. package/packages/config-eslint/node_modules/ajv/lib/dot/if.jst +0 -73
  51. package/packages/config-eslint/node_modules/ajv/lib/dot/items.jst +0 -98
  52. package/packages/config-eslint/node_modules/ajv/lib/dot/missing.def +0 -39
  53. package/packages/config-eslint/node_modules/ajv/lib/dot/multipleOf.jst +0 -22
  54. package/packages/config-eslint/node_modules/ajv/lib/dot/not.jst +0 -43
  55. package/packages/config-eslint/node_modules/ajv/lib/dot/oneOf.jst +0 -54
  56. package/packages/config-eslint/node_modules/ajv/lib/dot/pattern.jst +0 -14
  57. package/packages/config-eslint/node_modules/ajv/lib/dot/properties.jst +0 -245
  58. package/packages/config-eslint/node_modules/ajv/lib/dot/propertyNames.jst +0 -52
  59. package/packages/config-eslint/node_modules/ajv/lib/dot/ref.jst +0 -85
  60. package/packages/config-eslint/node_modules/ajv/lib/dot/required.jst +0 -108
  61. package/packages/config-eslint/node_modules/ajv/lib/dot/uniqueItems.jst +0 -62
  62. package/packages/config-eslint/node_modules/ajv/lib/dot/validate.jst +0 -276
  63. package/packages/config-eslint/node_modules/ajv/lib/dotjs/README.md +0 -3
  64. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limit.js +0 -163
  65. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitItems.js +0 -80
  66. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitLength.js +0 -85
  67. package/packages/config-eslint/node_modules/ajv/lib/dotjs/_limitProperties.js +0 -80
  68. package/packages/config-eslint/node_modules/ajv/lib/dotjs/allOf.js +0 -42
  69. package/packages/config-eslint/node_modules/ajv/lib/dotjs/anyOf.js +0 -73
  70. package/packages/config-eslint/node_modules/ajv/lib/dotjs/comment.js +0 -14
  71. package/packages/config-eslint/node_modules/ajv/lib/dotjs/const.js +0 -56
  72. package/packages/config-eslint/node_modules/ajv/lib/dotjs/contains.js +0 -81
  73. package/packages/config-eslint/node_modules/ajv/lib/dotjs/custom.js +0 -228
  74. package/packages/config-eslint/node_modules/ajv/lib/dotjs/dependencies.js +0 -168
  75. package/packages/config-eslint/node_modules/ajv/lib/dotjs/enum.js +0 -66
  76. package/packages/config-eslint/node_modules/ajv/lib/dotjs/format.js +0 -150
  77. package/packages/config-eslint/node_modules/ajv/lib/dotjs/if.js +0 -103
  78. package/packages/config-eslint/node_modules/ajv/lib/dotjs/index.js +0 -33
  79. package/packages/config-eslint/node_modules/ajv/lib/dotjs/items.js +0 -140
  80. package/packages/config-eslint/node_modules/ajv/lib/dotjs/multipleOf.js +0 -80
  81. package/packages/config-eslint/node_modules/ajv/lib/dotjs/not.js +0 -84
  82. package/packages/config-eslint/node_modules/ajv/lib/dotjs/oneOf.js +0 -73
  83. package/packages/config-eslint/node_modules/ajv/lib/dotjs/pattern.js +0 -75
  84. package/packages/config-eslint/node_modules/ajv/lib/dotjs/properties.js +0 -335
  85. package/packages/config-eslint/node_modules/ajv/lib/dotjs/propertyNames.js +0 -81
  86. package/packages/config-eslint/node_modules/ajv/lib/dotjs/ref.js +0 -124
  87. package/packages/config-eslint/node_modules/ajv/lib/dotjs/required.js +0 -270
  88. package/packages/config-eslint/node_modules/ajv/lib/dotjs/uniqueItems.js +0 -86
  89. package/packages/config-eslint/node_modules/ajv/lib/dotjs/validate.js +0 -482
  90. package/packages/config-eslint/node_modules/ajv/lib/keyword.js +0 -146
  91. package/packages/config-eslint/node_modules/ajv/lib/refs/data.json +0 -17
  92. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-04.json +0 -149
  93. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-06.json +0 -154
  94. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-draft-07.json +0 -168
  95. package/packages/config-eslint/node_modules/ajv/lib/refs/json-schema-secure.json +0 -94
  96. package/packages/config-eslint/node_modules/ajv/package.json +0 -106
  97. package/packages/config-eslint/node_modules/ajv/scripts/.eslintrc.yml +0 -3
  98. package/packages/config-eslint/node_modules/ajv/scripts/bundle.js +0 -61
  99. package/packages/config-eslint/node_modules/ajv/scripts/compile-dots.js +0 -73
  100. package/packages/config-eslint/node_modules/ajv/scripts/info +0 -10
  101. package/packages/config-eslint/node_modules/ajv/scripts/prepare-tests +0 -12
  102. package/packages/config-eslint/node_modules/ajv/scripts/publish-built-version +0 -32
  103. package/packages/config-eslint/node_modules/ajv/scripts/travis-gh-pages +0 -23
  104. package/packages/config-eslint/node_modules/ansi-styles/index.d.ts +0 -345
  105. package/packages/config-eslint/node_modules/ansi-styles/index.js +0 -163
  106. package/packages/config-eslint/node_modules/ansi-styles/license +0 -9
  107. package/packages/config-eslint/node_modules/ansi-styles/package.json +0 -56
  108. package/packages/config-eslint/node_modules/ansi-styles/readme.md +0 -152
  109. package/packages/config-eslint/node_modules/chalk/index.d.ts +0 -415
  110. package/packages/config-eslint/node_modules/chalk/license +0 -9
  111. package/packages/config-eslint/node_modules/chalk/package.json +0 -68
  112. package/packages/config-eslint/node_modules/chalk/readme.md +0 -341
  113. package/packages/config-eslint/node_modules/chalk/source/index.js +0 -229
  114. package/packages/config-eslint/node_modules/chalk/source/templates.js +0 -134
  115. package/packages/config-eslint/node_modules/chalk/source/util.js +0 -39
  116. package/packages/config-eslint/node_modules/color-convert/CHANGELOG.md +0 -54
  117. package/packages/config-eslint/node_modules/color-convert/LICENSE +0 -21
  118. package/packages/config-eslint/node_modules/color-convert/README.md +0 -68
  119. package/packages/config-eslint/node_modules/color-convert/conversions.js +0 -839
  120. package/packages/config-eslint/node_modules/color-convert/index.js +0 -81
  121. package/packages/config-eslint/node_modules/color-convert/package.json +0 -48
  122. package/packages/config-eslint/node_modules/color-convert/route.js +0 -97
  123. package/packages/config-eslint/node_modules/color-name/LICENSE +0 -8
  124. package/packages/config-eslint/node_modules/color-name/README.md +0 -11
  125. package/packages/config-eslint/node_modules/color-name/index.js +0 -152
  126. package/packages/config-eslint/node_modules/color-name/package.json +0 -28
  127. package/packages/config-eslint/node_modules/eslint/LICENSE +0 -19
  128. package/packages/config-eslint/node_modules/eslint/README.md +0 -354
  129. package/packages/config-eslint/node_modules/eslint/bin/eslint.js +0 -196
  130. package/packages/config-eslint/node_modules/eslint/conf/default-cli-options.js +0 -32
  131. package/packages/config-eslint/node_modules/eslint/conf/ecma-version.js +0 -16
  132. package/packages/config-eslint/node_modules/eslint/conf/globals.js +0 -169
  133. package/packages/config-eslint/node_modules/eslint/conf/replacements.json +0 -26
  134. package/packages/config-eslint/node_modules/eslint/conf/rule-type-list.json +0 -91
  135. package/packages/config-eslint/node_modules/eslint/lib/api.js +0 -50
  136. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/cli-engine.js +0 -1109
  137. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/file-enumerator.js +0 -541
  138. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json +0 -18
  139. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/html.js +0 -359
  140. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/json-with-metadata.js +0 -16
  141. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/json.js +0 -13
  142. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/formatters/stylish.js +0 -122
  143. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/hash.js +0 -35
  144. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/index.js +0 -7
  145. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/lint-result-cache.js +0 -220
  146. package/packages/config-eslint/node_modules/eslint/lib/cli-engine/load-rules.js +0 -46
  147. package/packages/config-eslint/node_modules/eslint/lib/cli.js +0 -553
  148. package/packages/config-eslint/node_modules/eslint/lib/config/config-loader.js +0 -816
  149. package/packages/config-eslint/node_modules/eslint/lib/config/config.js +0 -674
  150. package/packages/config-eslint/node_modules/eslint/lib/config/default-config.js +0 -78
  151. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-array.js +0 -217
  152. package/packages/config-eslint/node_modules/eslint/lib/config/flat-config-schema.js +0 -598
  153. package/packages/config-eslint/node_modules/eslint/lib/config-api.js +0 -12
  154. package/packages/config-eslint/node_modules/eslint/lib/eslint/eslint-helpers.js +0 -1465
  155. package/packages/config-eslint/node_modules/eslint/lib/eslint/eslint.js +0 -1362
  156. package/packages/config-eslint/node_modules/eslint/lib/eslint/index.js +0 -9
  157. package/packages/config-eslint/node_modules/eslint/lib/eslint/legacy-eslint.js +0 -786
  158. package/packages/config-eslint/node_modules/eslint/lib/eslint/worker.js +0 -173
  159. package/packages/config-eslint/node_modules/eslint/lib/languages/js/index.js +0 -336
  160. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/index.js +0 -7
  161. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/source-code.js +0 -1364
  162. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js +0 -61
  163. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-cursor.js +0 -57
  164. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursor.js +0 -76
  165. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursors.js +0 -120
  166. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/decorative-cursor.js +0 -38
  167. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/filter-cursor.js +0 -42
  168. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js +0 -65
  169. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-cursor.js +0 -62
  170. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/index.js +0 -721
  171. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/limit-cursor.js +0 -39
  172. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/padded-token-cursor.js +0 -45
  173. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/skip-cursor.js +0 -41
  174. package/packages/config-eslint/node_modules/eslint/lib/languages/js/source-code/token-store/utils.js +0 -110
  175. package/packages/config-eslint/node_modules/eslint/lib/languages/js/validate-language-options.js +0 -196
  176. package/packages/config-eslint/node_modules/eslint/lib/linter/apply-disable-directives.js +0 -584
  177. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +0 -828
  178. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js +0 -262
  179. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js +0 -2370
  180. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path.js +0 -332
  181. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js +0 -223
  182. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +0 -374
  183. package/packages/config-eslint/node_modules/eslint/lib/linter/code-path-analysis/id-generator.js +0 -44
  184. package/packages/config-eslint/node_modules/eslint/lib/linter/esquery.js +0 -332
  185. package/packages/config-eslint/node_modules/eslint/lib/linter/file-context.js +0 -144
  186. package/packages/config-eslint/node_modules/eslint/lib/linter/file-report.js +0 -608
  187. package/packages/config-eslint/node_modules/eslint/lib/linter/index.js +0 -11
  188. package/packages/config-eslint/node_modules/eslint/lib/linter/interpolate.js +0 -50
  189. package/packages/config-eslint/node_modules/eslint/lib/linter/linter.js +0 -2676
  190. package/packages/config-eslint/node_modules/eslint/lib/linter/rule-fixer.js +0 -169
  191. package/packages/config-eslint/node_modules/eslint/lib/linter/rules.js +0 -71
  192. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-fixer.js +0 -154
  193. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-traverser.js +0 -333
  194. package/packages/config-eslint/node_modules/eslint/lib/linter/source-code-visitor.js +0 -81
  195. package/packages/config-eslint/node_modules/eslint/lib/linter/timing.js +0 -209
  196. package/packages/config-eslint/node_modules/eslint/lib/linter/vfile.js +0 -115
  197. package/packages/config-eslint/node_modules/eslint/lib/options.js +0 -536
  198. package/packages/config-eslint/node_modules/eslint/lib/rule-tester/index.js +0 -7
  199. package/packages/config-eslint/node_modules/eslint/lib/rule-tester/rule-tester.js +0 -1579
  200. package/packages/config-eslint/node_modules/eslint/lib/rules/accessor-pairs.js +0 -420
  201. package/packages/config-eslint/node_modules/eslint/lib/rules/array-bracket-newline.js +0 -291
  202. package/packages/config-eslint/node_modules/eslint/lib/rules/array-bracket-spacing.js +0 -301
  203. package/packages/config-eslint/node_modules/eslint/lib/rules/array-callback-return.js +0 -493
  204. package/packages/config-eslint/node_modules/eslint/lib/rules/array-element-newline.js +0 -374
  205. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-body-style.js +0 -418
  206. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-parens.js +0 -237
  207. package/packages/config-eslint/node_modules/eslint/lib/rules/arrow-spacing.js +0 -188
  208. package/packages/config-eslint/node_modules/eslint/lib/rules/block-scoped-var.js +0 -137
  209. package/packages/config-eslint/node_modules/eslint/lib/rules/block-spacing.js +0 -202
  210. package/packages/config-eslint/node_modules/eslint/lib/rules/brace-style.js +0 -278
  211. package/packages/config-eslint/node_modules/eslint/lib/rules/callback-return.js +0 -216
  212. package/packages/config-eslint/node_modules/eslint/lib/rules/camelcase.js +0 -422
  213. package/packages/config-eslint/node_modules/eslint/lib/rules/capitalized-comments.js +0 -325
  214. package/packages/config-eslint/node_modules/eslint/lib/rules/class-methods-use-this.js +0 -250
  215. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-dangle.js +0 -424
  216. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-spacing.js +0 -208
  217. package/packages/config-eslint/node_modules/eslint/lib/rules/comma-style.js +0 -391
  218. package/packages/config-eslint/node_modules/eslint/lib/rules/complexity.js +0 -201
  219. package/packages/config-eslint/node_modules/eslint/lib/rules/computed-property-spacing.js +0 -251
  220. package/packages/config-eslint/node_modules/eslint/lib/rules/consistent-return.js +0 -221
  221. package/packages/config-eslint/node_modules/eslint/lib/rules/consistent-this.js +0 -179
  222. package/packages/config-eslint/node_modules/eslint/lib/rules/constructor-super.js +0 -453
  223. package/packages/config-eslint/node_modules/eslint/lib/rules/curly.js +0 -425
  224. package/packages/config-eslint/node_modules/eslint/lib/rules/default-case-last.js +0 -51
  225. package/packages/config-eslint/node_modules/eslint/lib/rules/default-case.js +0 -103
  226. package/packages/config-eslint/node_modules/eslint/lib/rules/default-param-last.js +0 -78
  227. package/packages/config-eslint/node_modules/eslint/lib/rules/dot-location.js +0 -138
  228. package/packages/config-eslint/node_modules/eslint/lib/rules/dot-notation.js +0 -216
  229. package/packages/config-eslint/node_modules/eslint/lib/rules/eol-last.js +0 -135
  230. package/packages/config-eslint/node_modules/eslint/lib/rules/eqeqeq.js +0 -210
  231. package/packages/config-eslint/node_modules/eslint/lib/rules/for-direction.js +0 -168
  232. package/packages/config-eslint/node_modules/eslint/lib/rules/func-call-spacing.js +0 -281
  233. package/packages/config-eslint/node_modules/eslint/lib/rules/func-name-matching.js +0 -338
  234. package/packages/config-eslint/node_modules/eslint/lib/rules/func-names.js +0 -192
  235. package/packages/config-eslint/node_modules/eslint/lib/rules/func-style.js +0 -221
  236. package/packages/config-eslint/node_modules/eslint/lib/rules/function-call-argument-newline.js +0 -166
  237. package/packages/config-eslint/node_modules/eslint/lib/rules/function-paren-newline.js +0 -368
  238. package/packages/config-eslint/node_modules/eslint/lib/rules/generator-star-spacing.js +0 -246
  239. package/packages/config-eslint/node_modules/eslint/lib/rules/getter-return.js +0 -242
  240. package/packages/config-eslint/node_modules/eslint/lib/rules/global-require.js +0 -117
  241. package/packages/config-eslint/node_modules/eslint/lib/rules/grouped-accessor-pairs.js +0 -268
  242. package/packages/config-eslint/node_modules/eslint/lib/rules/guard-for-in.js +0 -85
  243. package/packages/config-eslint/node_modules/eslint/lib/rules/handle-callback-err.js +0 -122
  244. package/packages/config-eslint/node_modules/eslint/lib/rules/id-blacklist.js +0 -241
  245. package/packages/config-eslint/node_modules/eslint/lib/rules/id-denylist.js +0 -223
  246. package/packages/config-eslint/node_modules/eslint/lib/rules/id-length.js +0 -217
  247. package/packages/config-eslint/node_modules/eslint/lib/rules/id-match.js +0 -363
  248. package/packages/config-eslint/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js +0 -125
  249. package/packages/config-eslint/node_modules/eslint/lib/rules/indent-legacy.js +0 -1369
  250. package/packages/config-eslint/node_modules/eslint/lib/rules/indent.js +0 -2334
  251. package/packages/config-eslint/node_modules/eslint/lib/rules/index.js +0 -332
  252. package/packages/config-eslint/node_modules/eslint/lib/rules/init-declarations.js +0 -172
  253. package/packages/config-eslint/node_modules/eslint/lib/rules/jsx-quotes.js +0 -128
  254. package/packages/config-eslint/node_modules/eslint/lib/rules/key-spacing.js +0 -822
  255. package/packages/config-eslint/node_modules/eslint/lib/rules/keyword-spacing.js +0 -701
  256. package/packages/config-eslint/node_modules/eslint/lib/rules/line-comment-position.js +0 -157
  257. package/packages/config-eslint/node_modules/eslint/lib/rules/linebreak-style.js +0 -135
  258. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-around-comment.js +0 -581
  259. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-around-directive.js +0 -249
  260. package/packages/config-eslint/node_modules/eslint/lib/rules/lines-between-class-members.js +0 -358
  261. package/packages/config-eslint/node_modules/eslint/lib/rules/logical-assignment-operators.js +0 -688
  262. package/packages/config-eslint/node_modules/eslint/lib/rules/max-classes-per-file.js +0 -90
  263. package/packages/config-eslint/node_modules/eslint/lib/rules/max-depth.js +0 -159
  264. package/packages/config-eslint/node_modules/eslint/lib/rules/max-len.js +0 -497
  265. package/packages/config-eslint/node_modules/eslint/lib/rules/max-lines-per-function.js +0 -238
  266. package/packages/config-eslint/node_modules/eslint/lib/rules/max-lines.js +0 -189
  267. package/packages/config-eslint/node_modules/eslint/lib/rules/max-nested-callbacks.js +0 -115
  268. package/packages/config-eslint/node_modules/eslint/lib/rules/max-params.js +0 -129
  269. package/packages/config-eslint/node_modules/eslint/lib/rules/max-statements-per-line.js +0 -224
  270. package/packages/config-eslint/node_modules/eslint/lib/rules/max-statements.js +0 -188
  271. package/packages/config-eslint/node_modules/eslint/lib/rules/multiline-comment-style.js +0 -652
  272. package/packages/config-eslint/node_modules/eslint/lib/rules/multiline-ternary.js +0 -257
  273. package/packages/config-eslint/node_modules/eslint/lib/rules/new-cap.js +0 -277
  274. package/packages/config-eslint/node_modules/eslint/lib/rules/new-parens.js +0 -120
  275. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-after-var.js +0 -307
  276. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-before-return.js +0 -242
  277. package/packages/config-eslint/node_modules/eslint/lib/rules/newline-per-chained-call.js +0 -159
  278. package/packages/config-eslint/node_modules/eslint/lib/rules/no-alert.js +0 -149
  279. package/packages/config-eslint/node_modules/eslint/lib/rules/no-array-constructor.js +0 -195
  280. package/packages/config-eslint/node_modules/eslint/lib/rules/no-async-promise-executor.js +0 -45
  281. package/packages/config-eslint/node_modules/eslint/lib/rules/no-await-in-loop.js +0 -115
  282. package/packages/config-eslint/node_modules/eslint/lib/rules/no-bitwise.js +0 -145
  283. package/packages/config-eslint/node_modules/eslint/lib/rules/no-buffer-constructor.js +0 -74
  284. package/packages/config-eslint/node_modules/eslint/lib/rules/no-caller.js +0 -52
  285. package/packages/config-eslint/node_modules/eslint/lib/rules/no-case-declarations.js +0 -80
  286. package/packages/config-eslint/node_modules/eslint/lib/rules/no-catch-shadow.js +0 -96
  287. package/packages/config-eslint/node_modules/eslint/lib/rules/no-class-assign.js +0 -66
  288. package/packages/config-eslint/node_modules/eslint/lib/rules/no-compare-neg-zero.js +0 -74
  289. package/packages/config-eslint/node_modules/eslint/lib/rules/no-cond-assign.js +0 -175
  290. package/packages/config-eslint/node_modules/eslint/lib/rules/no-confusing-arrow.js +0 -127
  291. package/packages/config-eslint/node_modules/eslint/lib/rules/no-console.js +0 -221
  292. package/packages/config-eslint/node_modules/eslint/lib/rules/no-const-assign.js +0 -73
  293. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constant-binary-expression.js +0 -603
  294. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constant-condition.js +0 -177
  295. package/packages/config-eslint/node_modules/eslint/lib/rules/no-constructor-return.js +0 -62
  296. package/packages/config-eslint/node_modules/eslint/lib/rules/no-continue.js +0 -38
  297. package/packages/config-eslint/node_modules/eslint/lib/rules/no-control-regex.js +0 -142
  298. package/packages/config-eslint/node_modules/eslint/lib/rules/no-debugger.js +0 -41
  299. package/packages/config-eslint/node_modules/eslint/lib/rules/no-delete-var.js +0 -42
  300. package/packages/config-eslint/node_modules/eslint/lib/rules/no-div-regex.js +0 -60
  301. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-args.js +0 -92
  302. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-class-members.js +0 -117
  303. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-else-if.js +0 -145
  304. package/packages/config-eslint/node_modules/eslint/lib/rules/no-dupe-keys.js +0 -165
  305. package/packages/config-eslint/node_modules/eslint/lib/rules/no-duplicate-case.js +0 -78
  306. package/packages/config-eslint/node_modules/eslint/lib/rules/no-duplicate-imports.js +0 -368
  307. package/packages/config-eslint/node_modules/eslint/lib/rules/no-else-return.js +0 -450
  308. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-character-class.js +0 -83
  309. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-function.js +0 -236
  310. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-pattern.js +0 -85
  311. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty-static-block.js +0 -73
  312. package/packages/config-eslint/node_modules/eslint/lib/rules/no-empty.js +0 -153
  313. package/packages/config-eslint/node_modules/eslint/lib/rules/no-eq-null.js +0 -51
  314. package/packages/config-eslint/node_modules/eslint/lib/rules/no-eval.js +0 -295
  315. package/packages/config-eslint/node_modules/eslint/lib/rules/no-ex-assign.js +0 -57
  316. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extend-native.js +0 -180
  317. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-bind.js +0 -224
  318. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +0 -420
  319. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-label.js +0 -169
  320. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-parens.js +0 -1669
  321. package/packages/config-eslint/node_modules/eslint/lib/rules/no-extra-semi.js +0 -167
  322. package/packages/config-eslint/node_modules/eslint/lib/rules/no-fallthrough.js +0 -260
  323. package/packages/config-eslint/node_modules/eslint/lib/rules/no-floating-decimal.js +0 -99
  324. package/packages/config-eslint/node_modules/eslint/lib/rules/no-func-assign.js +0 -77
  325. package/packages/config-eslint/node_modules/eslint/lib/rules/no-global-assign.js +0 -101
  326. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implicit-coercion.js +0 -468
  327. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implicit-globals.js +0 -187
  328. package/packages/config-eslint/node_modules/eslint/lib/rules/no-implied-eval.js +0 -170
  329. package/packages/config-eslint/node_modules/eslint/lib/rules/no-import-assign.js +0 -227
  330. package/packages/config-eslint/node_modules/eslint/lib/rules/no-inline-comments.js +0 -115
  331. package/packages/config-eslint/node_modules/eslint/lib/rules/no-inner-declarations.js +0 -147
  332. package/packages/config-eslint/node_modules/eslint/lib/rules/no-invalid-regexp.js +0 -243
  333. package/packages/config-eslint/node_modules/eslint/lib/rules/no-invalid-this.js +0 -178
  334. package/packages/config-eslint/node_modules/eslint/lib/rules/no-irregular-whitespace.js +0 -292
  335. package/packages/config-eslint/node_modules/eslint/lib/rules/no-iterator.js +0 -48
  336. package/packages/config-eslint/node_modules/eslint/lib/rules/no-label-var.js +0 -78
  337. package/packages/config-eslint/node_modules/eslint/lib/rules/no-labels.js +0 -156
  338. package/packages/config-eslint/node_modules/eslint/lib/rules/no-lone-blocks.js +0 -140
  339. package/packages/config-eslint/node_modules/eslint/lib/rules/no-lonely-if.js +0 -126
  340. package/packages/config-eslint/node_modules/eslint/lib/rules/no-loop-func.js +0 -267
  341. package/packages/config-eslint/node_modules/eslint/lib/rules/no-loss-of-precision.js +0 -249
  342. package/packages/config-eslint/node_modules/eslint/lib/rules/no-magic-numbers.js +0 -365
  343. package/packages/config-eslint/node_modules/eslint/lib/rules/no-misleading-character-class.js +0 -595
  344. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-operators.js +0 -253
  345. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-requires.js +0 -267
  346. package/packages/config-eslint/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +0 -148
  347. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-assign.js +0 -66
  348. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-spaces.js +0 -179
  349. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multi-str.js +0 -67
  350. package/packages/config-eslint/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +0 -210
  351. package/packages/config-eslint/node_modules/eslint/lib/rules/no-native-reassign.js +0 -114
  352. package/packages/config-eslint/node_modules/eslint/lib/rules/no-negated-condition.js +0 -100
  353. package/packages/config-eslint/node_modules/eslint/lib/rules/no-negated-in-lhs.js +0 -59
  354. package/packages/config-eslint/node_modules/eslint/lib/rules/no-nested-ternary.js +0 -46
  355. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-func.js +0 -96
  356. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js +0 -70
  357. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-object.js +0 -76
  358. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-require.js +0 -67
  359. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-symbol.js +0 -74
  360. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new-wrappers.js +0 -62
  361. package/packages/config-eslint/node_modules/eslint/lib/rules/no-new.js +0 -42
  362. package/packages/config-eslint/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js +0 -176
  363. package/packages/config-eslint/node_modules/eslint/lib/rules/no-obj-calls.js +0 -99
  364. package/packages/config-eslint/node_modules/eslint/lib/rules/no-object-constructor.js +0 -124
  365. package/packages/config-eslint/node_modules/eslint/lib/rules/no-octal-escape.js +0 -53
  366. package/packages/config-eslint/node_modules/eslint/lib/rules/no-octal.js +0 -42
  367. package/packages/config-eslint/node_modules/eslint/lib/rules/no-param-reassign.js +0 -248
  368. package/packages/config-eslint/node_modules/eslint/lib/rules/no-path-concat.js +0 -79
  369. package/packages/config-eslint/node_modules/eslint/lib/rules/no-plusplus.js +0 -102
  370. package/packages/config-eslint/node_modules/eslint/lib/rules/no-process-env.js +0 -68
  371. package/packages/config-eslint/node_modules/eslint/lib/rules/no-process-exit.js +0 -67
  372. package/packages/config-eslint/node_modules/eslint/lib/rules/no-promise-executor-return.js +0 -264
  373. package/packages/config-eslint/node_modules/eslint/lib/rules/no-proto.js +0 -45
  374. package/packages/config-eslint/node_modules/eslint/lib/rules/no-prototype-builtins.js +0 -181
  375. package/packages/config-eslint/node_modules/eslint/lib/rules/no-redeclare.js +0 -173
  376. package/packages/config-eslint/node_modules/eslint/lib/rules/no-regex-spaces.js +0 -219
  377. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-exports.js +0 -227
  378. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-globals.js +0 -266
  379. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-imports.js +0 -850
  380. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-modules.js +0 -249
  381. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-properties.js +0 -233
  382. package/packages/config-eslint/node_modules/eslint/lib/rules/no-restricted-syntax.js +0 -74
  383. package/packages/config-eslint/node_modules/eslint/lib/rules/no-return-assign.js +0 -87
  384. package/packages/config-eslint/node_modules/eslint/lib/rules/no-return-await.js +0 -162
  385. package/packages/config-eslint/node_modules/eslint/lib/rules/no-script-url.js +0 -68
  386. package/packages/config-eslint/node_modules/eslint/lib/rules/no-self-assign.js +0 -186
  387. package/packages/config-eslint/node_modules/eslint/lib/rules/no-self-compare.js +0 -77
  388. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sequences.js +0 -158
  389. package/packages/config-eslint/node_modules/eslint/lib/rules/no-setter-return.js +0 -224
  390. package/packages/config-eslint/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +0 -113
  391. package/packages/config-eslint/node_modules/eslint/lib/rules/no-shadow.js +0 -624
  392. package/packages/config-eslint/node_modules/eslint/lib/rules/no-spaced-func.js +0 -105
  393. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sparse-arrays.js +0 -68
  394. package/packages/config-eslint/node_modules/eslint/lib/rules/no-sync.js +0 -81
  395. package/packages/config-eslint/node_modules/eslint/lib/rules/no-tabs.js +0 -110
  396. package/packages/config-eslint/node_modules/eslint/lib/rules/no-template-curly-in-string.js +0 -45
  397. package/packages/config-eslint/node_modules/eslint/lib/rules/no-ternary.js +0 -38
  398. package/packages/config-eslint/node_modules/eslint/lib/rules/no-this-before-super.js +0 -365
  399. package/packages/config-eslint/node_modules/eslint/lib/rules/no-throw-literal.js +0 -46
  400. package/packages/config-eslint/node_modules/eslint/lib/rules/no-trailing-spaces.js +0 -227
  401. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unassigned-vars.js +0 -80
  402. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undef-init.js +0 -101
  403. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undef.js +0 -84
  404. package/packages/config-eslint/node_modules/eslint/lib/rules/no-undefined.js +0 -85
  405. package/packages/config-eslint/node_modules/eslint/lib/rules/no-underscore-dangle.js +0 -383
  406. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unexpected-multiline.js +0 -130
  407. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +0 -360
  408. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unneeded-ternary.js +0 -232
  409. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unreachable-loop.js +0 -190
  410. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unreachable.js +0 -300
  411. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-finally.js +0 -119
  412. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-negation.js +0 -152
  413. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js +0 -221
  414. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-expressions.js +0 -227
  415. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-labels.js +0 -158
  416. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-private-class-members.js +0 -219
  417. package/packages/config-eslint/node_modules/eslint/lib/rules/no-unused-vars.js +0 -1739
  418. package/packages/config-eslint/node_modules/eslint/lib/rules/no-use-before-define.js +0 -446
  419. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-assignment.js +0 -654
  420. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-backreference.js +0 -263
  421. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-call.js +0 -95
  422. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-catch.js +0 -57
  423. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-computed-key.js +0 -204
  424. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-concat.js +0 -121
  425. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-constructor.js +0 -252
  426. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-escape.js +0 -406
  427. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-rename.js +0 -202
  428. package/packages/config-eslint/node_modules/eslint/lib/rules/no-useless-return.js +0 -401
  429. package/packages/config-eslint/node_modules/eslint/lib/rules/no-var.js +0 -367
  430. package/packages/config-eslint/node_modules/eslint/lib/rules/no-void.js +0 -69
  431. package/packages/config-eslint/node_modules/eslint/lib/rules/no-warning-comments.js +0 -209
  432. package/packages/config-eslint/node_modules/eslint/lib/rules/no-whitespace-before-property.js +0 -150
  433. package/packages/config-eslint/node_modules/eslint/lib/rules/no-with.js +0 -37
  434. package/packages/config-eslint/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +0 -164
  435. package/packages/config-eslint/node_modules/eslint/lib/rules/object-curly-newline.js +0 -383
  436. package/packages/config-eslint/node_modules/eslint/lib/rules/object-curly-spacing.js +0 -375
  437. package/packages/config-eslint/node_modules/eslint/lib/rules/object-property-newline.js +0 -151
  438. package/packages/config-eslint/node_modules/eslint/lib/rules/object-shorthand.js +0 -652
  439. package/packages/config-eslint/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +0 -117
  440. package/packages/config-eslint/node_modules/eslint/lib/rules/one-var.js +0 -717
  441. package/packages/config-eslint/node_modules/eslint/lib/rules/operator-assignment.js +0 -270
  442. package/packages/config-eslint/node_modules/eslint/lib/rules/operator-linebreak.js +0 -315
  443. package/packages/config-eslint/node_modules/eslint/lib/rules/padded-blocks.js +0 -366
  444. package/packages/config-eslint/node_modules/eslint/lib/rules/padding-line-between-statements.js +0 -612
  445. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-arrow-callback.js +0 -437
  446. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-const.js +0 -546
  447. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-destructuring.js +0 -332
  448. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-exponentiation-operator.js +0 -235
  449. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-named-capture-group.js +0 -197
  450. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-numeric-literals.js +0 -157
  451. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-object-has-own.js +0 -148
  452. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-object-spread.js +0 -319
  453. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +0 -154
  454. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-reflect.js +0 -150
  455. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-regex-literals.js +0 -605
  456. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-rest-params.js +0 -117
  457. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-spread.js +0 -91
  458. package/packages/config-eslint/node_modules/eslint/lib/rules/prefer-template.js +0 -347
  459. package/packages/config-eslint/node_modules/eslint/lib/rules/preserve-caught-error.js +0 -535
  460. package/packages/config-eslint/node_modules/eslint/lib/rules/quote-props.js +0 -394
  461. package/packages/config-eslint/node_modules/eslint/lib/rules/quotes.js +0 -416
  462. package/packages/config-eslint/node_modules/eslint/lib/rules/radix.js +0 -216
  463. package/packages/config-eslint/node_modules/eslint/lib/rules/require-atomic-updates.js +0 -365
  464. package/packages/config-eslint/node_modules/eslint/lib/rules/require-await.js +0 -184
  465. package/packages/config-eslint/node_modules/eslint/lib/rules/require-unicode-regexp.js +0 -317
  466. package/packages/config-eslint/node_modules/eslint/lib/rules/require-yield.js +0 -76
  467. package/packages/config-eslint/node_modules/eslint/lib/rules/rest-spread-spacing.js +0 -153
  468. package/packages/config-eslint/node_modules/eslint/lib/rules/semi-spacing.js +0 -297
  469. package/packages/config-eslint/node_modules/eslint/lib/rules/semi-style.js +0 -218
  470. package/packages/config-eslint/node_modules/eslint/lib/rules/semi.js +0 -476
  471. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-imports.js +0 -319
  472. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-keys.js +0 -268
  473. package/packages/config-eslint/node_modules/eslint/lib/rules/sort-vars.js +0 -140
  474. package/packages/config-eslint/node_modules/eslint/lib/rules/space-before-blocks.js +0 -232
  475. package/packages/config-eslint/node_modules/eslint/lib/rules/space-before-function-paren.js +0 -205
  476. package/packages/config-eslint/node_modules/eslint/lib/rules/space-in-parens.js +0 -374
  477. package/packages/config-eslint/node_modules/eslint/lib/rules/space-infix-ops.js +0 -252
  478. package/packages/config-eslint/node_modules/eslint/lib/rules/space-unary-ops.js +0 -400
  479. package/packages/config-eslint/node_modules/eslint/lib/rules/spaced-comment.js +0 -447
  480. package/packages/config-eslint/node_modules/eslint/lib/rules/strict.js +0 -314
  481. package/packages/config-eslint/node_modules/eslint/lib/rules/switch-colon-spacing.js +0 -158
  482. package/packages/config-eslint/node_modules/eslint/lib/rules/symbol-description.js +0 -70
  483. package/packages/config-eslint/node_modules/eslint/lib/rules/template-curly-spacing.js +0 -168
  484. package/packages/config-eslint/node_modules/eslint/lib/rules/template-tag-spacing.js +0 -121
  485. package/packages/config-eslint/node_modules/eslint/lib/rules/unicode-bom.js +0 -73
  486. package/packages/config-eslint/node_modules/eslint/lib/rules/use-isnan.js +0 -268
  487. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/ast-utils.js +0 -2733
  488. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/char-source.js +0 -247
  489. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/fix-tracker.js +0 -125
  490. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/keywords.js +0 -67
  491. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js +0 -118
  492. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/regular-expressions.js +0 -58
  493. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/index.js +0 -16
  494. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js +0 -13
  495. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-emoji-modifier.js +0 -13
  496. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-regional-indicator-symbol.js +0 -13
  497. package/packages/config-eslint/node_modules/eslint/lib/rules/utils/unicode/is-surrogate-pair.js +0 -14
  498. package/packages/config-eslint/node_modules/eslint/lib/rules/valid-typeof.js +0 -171
  499. package/packages/config-eslint/node_modules/eslint/lib/rules/vars-on-top.js +0 -165
  500. package/packages/config-eslint/node_modules/eslint/lib/rules/wrap-iife.js +0 -238
  501. package/packages/config-eslint/node_modules/eslint/lib/rules/wrap-regex.js +0 -91
  502. package/packages/config-eslint/node_modules/eslint/lib/rules/yield-star-spacing.js +0 -159
  503. package/packages/config-eslint/node_modules/eslint/lib/rules/yoda.js +0 -362
  504. package/packages/config-eslint/node_modules/eslint/lib/services/parser-service.js +0 -65
  505. package/packages/config-eslint/node_modules/eslint/lib/services/processor-service.js +0 -101
  506. package/packages/config-eslint/node_modules/eslint/lib/services/suppressions-service.js +0 -302
  507. package/packages/config-eslint/node_modules/eslint/lib/services/warning-service.js +0 -111
  508. package/packages/config-eslint/node_modules/eslint/lib/shared/ajv.js +0 -34
  509. package/packages/config-eslint/node_modules/eslint/lib/shared/assert.js +0 -21
  510. package/packages/config-eslint/node_modules/eslint/lib/shared/ast-utils.js +0 -30
  511. package/packages/config-eslint/node_modules/eslint/lib/shared/deep-merge-arrays.js +0 -62
  512. package/packages/config-eslint/node_modules/eslint/lib/shared/directives.js +0 -16
  513. package/packages/config-eslint/node_modules/eslint/lib/shared/flags.js +0 -108
  514. package/packages/config-eslint/node_modules/eslint/lib/shared/logging.js +0 -38
  515. package/packages/config-eslint/node_modules/eslint/lib/shared/naming.js +0 -109
  516. package/packages/config-eslint/node_modules/eslint/lib/shared/option-utils.js +0 -63
  517. package/packages/config-eslint/node_modules/eslint/lib/shared/relative-module-resolver.js +0 -28
  518. package/packages/config-eslint/node_modules/eslint/lib/shared/runtime-info.js +0 -177
  519. package/packages/config-eslint/node_modules/eslint/lib/shared/serialization.js +0 -78
  520. package/packages/config-eslint/node_modules/eslint/lib/shared/severity.js +0 -49
  521. package/packages/config-eslint/node_modules/eslint/lib/shared/stats.js +0 -30
  522. package/packages/config-eslint/node_modules/eslint/lib/shared/string-utils.js +0 -58
  523. package/packages/config-eslint/node_modules/eslint/lib/shared/text-table.js +0 -68
  524. package/packages/config-eslint/node_modules/eslint/lib/shared/translate-cli-options.js +0 -281
  525. package/packages/config-eslint/node_modules/eslint/lib/shared/traverser.js +0 -202
  526. package/packages/config-eslint/node_modules/eslint/lib/types/config-api.d.ts +0 -12
  527. package/packages/config-eslint/node_modules/eslint/lib/types/index.d.ts +0 -1473
  528. package/packages/config-eslint/node_modules/eslint/lib/types/rules.d.ts +0 -5589
  529. package/packages/config-eslint/node_modules/eslint/lib/types/universal.d.ts +0 -6
  530. package/packages/config-eslint/node_modules/eslint/lib/types/use-at-your-own-risk.d.ts +0 -87
  531. package/packages/config-eslint/node_modules/eslint/lib/universal.js +0 -10
  532. package/packages/config-eslint/node_modules/eslint/lib/unsupported-api.js +0 -29
  533. package/packages/config-eslint/node_modules/eslint/messages/all-files-ignored.js +0 -16
  534. package/packages/config-eslint/node_modules/eslint/messages/all-matched-files-ignored.js +0 -21
  535. package/packages/config-eslint/node_modules/eslint/messages/config-file-missing.js +0 -16
  536. package/packages/config-eslint/node_modules/eslint/messages/config-plugin-missing.js +0 -14
  537. package/packages/config-eslint/node_modules/eslint/messages/config-serialize-function.js +0 -30
  538. package/packages/config-eslint/node_modules/eslint/messages/eslintrc-incompat.js +0 -117
  539. package/packages/config-eslint/node_modules/eslint/messages/eslintrc-plugins.js +0 -27
  540. package/packages/config-eslint/node_modules/eslint/messages/extend-config-missing.js +0 -13
  541. package/packages/config-eslint/node_modules/eslint/messages/failed-to-read-json.js +0 -11
  542. package/packages/config-eslint/node_modules/eslint/messages/file-not-found.js +0 -10
  543. package/packages/config-eslint/node_modules/eslint/messages/invalid-rule-options.js +0 -17
  544. package/packages/config-eslint/node_modules/eslint/messages/invalid-rule-severity.js +0 -13
  545. package/packages/config-eslint/node_modules/eslint/messages/no-config-found.js +0 -15
  546. package/packages/config-eslint/node_modules/eslint/messages/plugin-conflict.js +0 -22
  547. package/packages/config-eslint/node_modules/eslint/messages/plugin-invalid.js +0 -16
  548. package/packages/config-eslint/node_modules/eslint/messages/plugin-missing.js +0 -19
  549. package/packages/config-eslint/node_modules/eslint/messages/print-config-with-directory-path.js +0 -8
  550. package/packages/config-eslint/node_modules/eslint/messages/shared.js +0 -23
  551. package/packages/config-eslint/node_modules/eslint/messages/whitespace-found.js +0 -11
  552. package/packages/config-eslint/node_modules/eslint/package.json +0 -226
  553. package/packages/config-eslint/node_modules/find-up/index.d.ts +0 -138
  554. package/packages/config-eslint/node_modules/find-up/index.js +0 -89
  555. package/packages/config-eslint/node_modules/find-up/license +0 -9
  556. package/packages/config-eslint/node_modules/find-up/package.json +0 -54
  557. package/packages/config-eslint/node_modules/find-up/readme.md +0 -151
  558. package/packages/config-eslint/node_modules/globals/globals.json +0 -3970
  559. package/packages/config-eslint/node_modules/globals/index.d.ts +0 -4087
  560. package/packages/config-eslint/node_modules/globals/index.js +0 -2
  561. package/packages/config-eslint/node_modules/globals/license +0 -9
  562. package/packages/config-eslint/node_modules/globals/package.json +0 -122
  563. package/packages/config-eslint/node_modules/globals/readme.md +0 -42
  564. package/packages/config-eslint/node_modules/ignore/LICENSE-MIT +0 -21
  565. package/packages/config-eslint/node_modules/ignore/README.md +0 -412
  566. package/packages/config-eslint/node_modules/ignore/index.d.ts +0 -61
  567. package/packages/config-eslint/node_modules/ignore/index.js +0 -636
  568. package/packages/config-eslint/node_modules/ignore/legacy.js +0 -559
  569. package/packages/config-eslint/node_modules/ignore/package.json +0 -74
  570. package/packages/config-eslint/node_modules/json-schema-traverse/.eslintrc.yml +0 -27
  571. package/packages/config-eslint/node_modules/json-schema-traverse/.travis.yml +0 -8
  572. package/packages/config-eslint/node_modules/json-schema-traverse/LICENSE +0 -21
  573. package/packages/config-eslint/node_modules/json-schema-traverse/README.md +0 -83
  574. package/packages/config-eslint/node_modules/json-schema-traverse/index.js +0 -89
  575. package/packages/config-eslint/node_modules/json-schema-traverse/package.json +0 -43
  576. package/packages/config-eslint/node_modules/json-schema-traverse/spec/.eslintrc.yml +0 -6
  577. package/packages/config-eslint/node_modules/json-schema-traverse/spec/fixtures/schema.js +0 -125
  578. package/packages/config-eslint/node_modules/json-schema-traverse/spec/index.spec.js +0 -171
  579. package/packages/config-eslint/node_modules/locate-path/index.d.ts +0 -83
  580. package/packages/config-eslint/node_modules/locate-path/index.js +0 -68
  581. package/packages/config-eslint/node_modules/locate-path/license +0 -9
  582. package/packages/config-eslint/node_modules/locate-path/package.json +0 -46
  583. package/packages/config-eslint/node_modules/locate-path/readme.md +0 -125
  584. package/packages/config-eslint/node_modules/p-limit/index.d.ts +0 -42
  585. package/packages/config-eslint/node_modules/p-limit/index.js +0 -71
  586. package/packages/config-eslint/node_modules/p-limit/license +0 -9
  587. package/packages/config-eslint/node_modules/p-limit/package.json +0 -52
  588. package/packages/config-eslint/node_modules/p-limit/readme.md +0 -101
  589. package/packages/config-eslint/node_modules/p-locate/index.d.ts +0 -53
  590. package/packages/config-eslint/node_modules/p-locate/index.js +0 -50
  591. package/packages/config-eslint/node_modules/p-locate/license +0 -9
  592. package/packages/config-eslint/node_modules/p-locate/package.json +0 -54
  593. package/packages/config-eslint/node_modules/p-locate/readme.md +0 -93
  594. package/packages/config-eslint/node_modules/path-exists/index.d.ts +0 -28
  595. package/packages/config-eslint/node_modules/path-exists/index.js +0 -23
  596. package/packages/config-eslint/node_modules/path-exists/license +0 -9
  597. package/packages/config-eslint/node_modules/path-exists/package.json +0 -39
  598. package/packages/config-eslint/node_modules/path-exists/readme.md +0 -52
  599. package/packages/config-eslint/node_modules/yocto-queue/index.d.ts +0 -56
  600. package/packages/config-eslint/node_modules/yocto-queue/index.js +0 -68
  601. package/packages/config-eslint/node_modules/yocto-queue/license +0 -9
  602. package/packages/config-eslint/node_modules/yocto-queue/package.json +0 -43
  603. package/packages/config-eslint/node_modules/yocto-queue/readme.md +0 -64
@@ -1,2334 +0,0 @@
1
- /**
2
- * @fileoverview This rule sets a specific indentation style and width for your code
3
- *
4
- * @author Teddy Katz
5
- * @author Vitaly Puzrin
6
- * @author Gyandeep Singh
7
- * @deprecated in ESLint v8.53.0
8
- */
9
-
10
- "use strict";
11
-
12
- //------------------------------------------------------------------------------
13
- // Requirements
14
- //------------------------------------------------------------------------------
15
-
16
- const astUtils = require("./utils/ast-utils");
17
-
18
- //------------------------------------------------------------------------------
19
- // Rule Definition
20
- //------------------------------------------------------------------------------
21
-
22
- const KNOWN_NODES = new Set([
23
- "AssignmentExpression",
24
- "AssignmentPattern",
25
- "ArrayExpression",
26
- "ArrayPattern",
27
- "ArrowFunctionExpression",
28
- "AwaitExpression",
29
- "BlockStatement",
30
- "BinaryExpression",
31
- "BreakStatement",
32
- "CallExpression",
33
- "CatchClause",
34
- "ChainExpression",
35
- "ClassBody",
36
- "ClassDeclaration",
37
- "ClassExpression",
38
- "ConditionalExpression",
39
- "ContinueStatement",
40
- "DoWhileStatement",
41
- "DebuggerStatement",
42
- "EmptyStatement",
43
- "ExperimentalRestProperty",
44
- "ExperimentalSpreadProperty",
45
- "ExpressionStatement",
46
- "ForStatement",
47
- "ForInStatement",
48
- "ForOfStatement",
49
- "FunctionDeclaration",
50
- "FunctionExpression",
51
- "Identifier",
52
- "IfStatement",
53
- "Literal",
54
- "LabeledStatement",
55
- "LogicalExpression",
56
- "MemberExpression",
57
- "MetaProperty",
58
- "MethodDefinition",
59
- "NewExpression",
60
- "ObjectExpression",
61
- "ObjectPattern",
62
- "PrivateIdentifier",
63
- "Program",
64
- "Property",
65
- "PropertyDefinition",
66
- "RestElement",
67
- "ReturnStatement",
68
- "SequenceExpression",
69
- "SpreadElement",
70
- "StaticBlock",
71
- "Super",
72
- "SwitchCase",
73
- "SwitchStatement",
74
- "TaggedTemplateExpression",
75
- "TemplateElement",
76
- "TemplateLiteral",
77
- "ThisExpression",
78
- "ThrowStatement",
79
- "TryStatement",
80
- "UnaryExpression",
81
- "UpdateExpression",
82
- "VariableDeclaration",
83
- "VariableDeclarator",
84
- "WhileStatement",
85
- "WithStatement",
86
- "YieldExpression",
87
- "JSXFragment",
88
- "JSXOpeningFragment",
89
- "JSXClosingFragment",
90
- "JSXIdentifier",
91
- "JSXNamespacedName",
92
- "JSXMemberExpression",
93
- "JSXEmptyExpression",
94
- "JSXExpressionContainer",
95
- "JSXElement",
96
- "JSXClosingElement",
97
- "JSXOpeningElement",
98
- "JSXAttribute",
99
- "JSXSpreadAttribute",
100
- "JSXText",
101
- "ExportDefaultDeclaration",
102
- "ExportNamedDeclaration",
103
- "ExportAllDeclaration",
104
- "ExportSpecifier",
105
- "ImportDeclaration",
106
- "ImportSpecifier",
107
- "ImportDefaultSpecifier",
108
- "ImportNamespaceSpecifier",
109
- "ImportExpression",
110
- ]);
111
-
112
- /*
113
- * General rule strategy:
114
- * 1. An OffsetStorage instance stores a map of desired offsets, where each token has a specified offset from another
115
- * specified token or to the first column.
116
- * 2. As the AST is traversed, modify the desired offsets of tokens accordingly. For example, when entering a
117
- * BlockStatement, offset all of the tokens in the BlockStatement by 1 indent level from the opening curly
118
- * brace of the BlockStatement.
119
- * 3. After traversing the AST, calculate the expected indentation levels of every token according to the
120
- * OffsetStorage container.
121
- * 4. For each line, compare the expected indentation of the first token to the actual indentation in the file,
122
- * and report the token if the two values are not equal.
123
- */
124
-
125
- /**
126
- * A mutable map that stores (key, value) pairs. The keys are numeric indices, and must be unique.
127
- * This is intended to be a generic wrapper around a map with non-negative integer keys, so that the underlying implementation
128
- * can easily be swapped out.
129
- */
130
- class IndexMap {
131
- /**
132
- * Creates an empty map
133
- * @param {number} maxKey The maximum key
134
- */
135
- constructor(maxKey) {
136
- // Initializing the array with the maximum expected size avoids dynamic reallocations that could degrade performance.
137
- this._values = Array(maxKey + 1);
138
- }
139
-
140
- /**
141
- * Inserts an entry into the map.
142
- * @param {number} key The entry's key
143
- * @param {any} value The entry's value
144
- * @returns {void}
145
- */
146
- insert(key, value) {
147
- this._values[key] = value;
148
- }
149
-
150
- /**
151
- * Finds the value of the entry with the largest key less than or equal to the provided key
152
- * @param {number} key The provided key
153
- * @returns {*|undefined} The value of the found entry, or undefined if no such entry exists.
154
- */
155
- findLastNotAfter(key) {
156
- const values = this._values;
157
-
158
- for (let index = key; index >= 0; index--) {
159
- const value = values[index];
160
-
161
- if (value) {
162
- return value;
163
- }
164
- }
165
- return void 0;
166
- }
167
-
168
- /**
169
- * Deletes all of the keys in the interval [start, end)
170
- * @param {number} start The start of the range
171
- * @param {number} end The end of the range
172
- * @returns {void}
173
- */
174
- deleteRange(start, end) {
175
- this._values.fill(void 0, start, end);
176
- }
177
- }
178
-
179
- /**
180
- * A helper class to get token-based info related to indentation
181
- */
182
- class TokenInfo {
183
- /**
184
- * @param {SourceCode} sourceCode A SourceCode object
185
- */
186
- constructor(sourceCode) {
187
- this.sourceCode = sourceCode;
188
- this.firstTokensByLineNumber = new Map();
189
- const tokens = sourceCode.tokensAndComments;
190
-
191
- for (let i = 0; i < tokens.length; i++) {
192
- const token = tokens[i];
193
-
194
- if (!this.firstTokensByLineNumber.has(token.loc.start.line)) {
195
- this.firstTokensByLineNumber.set(token.loc.start.line, token);
196
- }
197
- if (
198
- !this.firstTokensByLineNumber.has(token.loc.end.line) &&
199
- sourceCode.text
200
- .slice(
201
- token.range[1] - token.loc.end.column,
202
- token.range[1],
203
- )
204
- .trim()
205
- ) {
206
- this.firstTokensByLineNumber.set(token.loc.end.line, token);
207
- }
208
- }
209
- }
210
-
211
- /**
212
- * Gets the first token on a given token's line
213
- * @param {Token|ASTNode} token a node or token
214
- * @returns {Token} The first token on the given line
215
- */
216
- getFirstTokenOfLine(token) {
217
- return this.firstTokensByLineNumber.get(token.loc.start.line);
218
- }
219
-
220
- /**
221
- * Determines whether a token is the first token in its line
222
- * @param {Token} token The token
223
- * @returns {boolean} `true` if the token is the first on its line
224
- */
225
- isFirstTokenOfLine(token) {
226
- return this.getFirstTokenOfLine(token) === token;
227
- }
228
-
229
- /**
230
- * Get the actual indent of a token
231
- * @param {Token} token Token to examine. This should be the first token on its line.
232
- * @returns {string} The indentation characters that precede the token
233
- */
234
- getTokenIndent(token) {
235
- return this.sourceCode.text.slice(
236
- token.range[0] - token.loc.start.column,
237
- token.range[0],
238
- );
239
- }
240
- }
241
-
242
- /**
243
- * A class to store information on desired offsets of tokens from each other
244
- */
245
- class OffsetStorage {
246
- /**
247
- * @param {TokenInfo} tokenInfo a TokenInfo instance
248
- * @param {number} indentSize The desired size of each indentation level
249
- * @param {string} indentType The indentation character
250
- * @param {number} maxIndex The maximum end index of any token
251
- */
252
- constructor(tokenInfo, indentSize, indentType, maxIndex) {
253
- this._tokenInfo = tokenInfo;
254
- this._indentSize = indentSize;
255
- this._indentType = indentType;
256
-
257
- this._indexMap = new IndexMap(maxIndex);
258
- this._indexMap.insert(0, { offset: 0, from: null, force: false });
259
-
260
- this._lockedFirstTokens = new WeakMap();
261
- this._desiredIndentCache = new WeakMap();
262
- this._ignoredTokens = new WeakSet();
263
- }
264
-
265
- _getOffsetDescriptor(token) {
266
- return this._indexMap.findLastNotAfter(token.range[0]);
267
- }
268
-
269
- /**
270
- * Sets the offset column of token B to match the offset column of token A.
271
- * - **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
272
- * most cases, `setDesiredOffset` should be used instead.
273
- * @param {Token} baseToken The first token
274
- * @param {Token} offsetToken The second token, whose offset should be matched to the first token
275
- * @returns {void}
276
- */
277
- matchOffsetOf(baseToken, offsetToken) {
278
- /*
279
- * lockedFirstTokens is a map from a token whose indentation is controlled by the "first" option to
280
- * the token that it depends on. For example, with the `ArrayExpression: first` option, the first
281
- * token of each element in the array after the first will be mapped to the first token of the first
282
- * element. The desired indentation of each of these tokens is computed based on the desired indentation
283
- * of the "first" element, rather than through the normal offset mechanism.
284
- */
285
- this._lockedFirstTokens.set(offsetToken, baseToken);
286
- }
287
-
288
- /**
289
- * Sets the desired offset of a token.
290
- *
291
- * This uses a line-based offset collapsing behavior to handle tokens on the same line.
292
- * For example, consider the following two cases:
293
- *
294
- * (
295
- * [
296
- * bar
297
- * ]
298
- * )
299
- *
300
- * ([
301
- * bar
302
- * ])
303
- *
304
- * Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from
305
- * the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is
306
- * the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces)
307
- * from the start of its line.
308
- *
309
- * However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level
310
- * between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the
311
- * `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented
312
- * by 1 indent level from the start of the line.
313
- *
314
- * This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node,
315
- * without needing to check which lines those tokens are on.
316
- *
317
- * Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive
318
- * behavior can occur. For example, consider the following cases:
319
- *
320
- * foo(
321
- * ).
322
- * bar(
323
- * baz
324
- * )
325
- *
326
- * foo(
327
- * ).bar(
328
- * baz
329
- * )
330
- *
331
- * Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz`
332
- * should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz`
333
- * being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no
334
- * collapsing would occur).
335
- *
336
- * Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and
337
- * offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed
338
- * in the second case.
339
- * @param {Token} token The token
340
- * @param {Token} fromToken The token that `token` should be offset from
341
- * @param {number} offset The desired indent level
342
- * @returns {void}
343
- */
344
- setDesiredOffset(token, fromToken, offset) {
345
- return this.setDesiredOffsets(token.range, fromToken, offset);
346
- }
347
-
348
- /**
349
- * Sets the desired offset of all tokens in a range
350
- * It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens.
351
- * Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains
352
- * it). This means that the offset of each token is updated O(AST depth) times.
353
- * It would not be performant to store and update the offsets for each token independently, because the rule would end
354
- * up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files.
355
- *
356
- * Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following
357
- * list could represent the state of the offset tree at a given point:
358
- *
359
- * - Tokens starting in the interval [0, 15) are aligned with the beginning of the file
360
- * - Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
361
- * - Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
362
- * - Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
363
- * - Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
364
- *
365
- * The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
366
- * `setDesiredOffsets([30, 43], fooToken, 1);`
367
- * @param {[number, number]} range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied.
368
- * @param {Token} fromToken The token that this is offset from
369
- * @param {number} offset The desired indent level
370
- * @param {boolean} force `true` if this offset should not use the normal collapsing behavior. This should almost always be false.
371
- * @returns {void}
372
- */
373
- setDesiredOffsets(range, fromToken, offset, force) {
374
- /*
375
- * Offset ranges are stored as a collection of nodes, where each node maps a numeric key to an offset
376
- * descriptor. The tree for the example above would have the following nodes:
377
- *
378
- * * key: 0, value: { offset: 0, from: null }
379
- * * key: 15, value: { offset: 1, from: barToken }
380
- * * key: 30, value: { offset: 1, from: fooToken }
381
- * * key: 43, value: { offset: 2, from: barToken }
382
- * * key: 820, value: { offset: 1, from: bazToken }
383
- *
384
- * To find the offset descriptor for any given token, one needs to find the node with the largest key
385
- * which is <= token.start. To make this operation fast, the nodes are stored in a map indexed by key.
386
- */
387
-
388
- const descriptorToInsert = { offset, from: fromToken, force };
389
-
390
- const descriptorAfterRange = this._indexMap.findLastNotAfter(range[1]);
391
-
392
- const fromTokenIsInRange =
393
- fromToken &&
394
- fromToken.range[0] >= range[0] &&
395
- fromToken.range[1] <= range[1];
396
- const fromTokenDescriptor =
397
- fromTokenIsInRange && this._getOffsetDescriptor(fromToken);
398
-
399
- // First, remove any existing nodes in the range from the map.
400
- this._indexMap.deleteRange(range[0] + 1, range[1]);
401
-
402
- // Insert a new node into the map for this range
403
- this._indexMap.insert(range[0], descriptorToInsert);
404
-
405
- /*
406
- * To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
407
- * even if it's in the current range.
408
- */
409
- if (fromTokenIsInRange) {
410
- this._indexMap.insert(fromToken.range[0], fromTokenDescriptor);
411
- this._indexMap.insert(fromToken.range[1], descriptorToInsert);
412
- }
413
-
414
- /*
415
- * To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
416
- * tokens the same as it was before.
417
- */
418
- this._indexMap.insert(range[1], descriptorAfterRange);
419
- }
420
-
421
- /**
422
- * Gets the desired indent of a token
423
- * @param {Token} token The token
424
- * @returns {string} The desired indent of the token
425
- */
426
- getDesiredIndent(token) {
427
- if (!this._desiredIndentCache.has(token)) {
428
- if (this._ignoredTokens.has(token)) {
429
- /*
430
- * If the token is ignored, use the actual indent of the token as the desired indent.
431
- * This ensures that no errors are reported for this token.
432
- */
433
- this._desiredIndentCache.set(
434
- token,
435
- this._tokenInfo.getTokenIndent(token),
436
- );
437
- } else if (this._lockedFirstTokens.has(token)) {
438
- const firstToken = this._lockedFirstTokens.get(token);
439
-
440
- this._desiredIndentCache.set(
441
- token,
442
-
443
- // (indentation for the first element's line)
444
- this.getDesiredIndent(
445
- this._tokenInfo.getFirstTokenOfLine(firstToken),
446
- ) +
447
- // (space between the start of the first element's line and the first element)
448
- this._indentType.repeat(
449
- firstToken.loc.start.column -
450
- this._tokenInfo.getFirstTokenOfLine(firstToken)
451
- .loc.start.column,
452
- ),
453
- );
454
- } else {
455
- const offsetInfo = this._getOffsetDescriptor(token);
456
- const offset =
457
- offsetInfo.from &&
458
- offsetInfo.from.loc.start.line === token.loc.start.line &&
459
- !/^\s*?\n/u.test(token.value) &&
460
- !offsetInfo.force
461
- ? 0
462
- : offsetInfo.offset * this._indentSize;
463
-
464
- this._desiredIndentCache.set(
465
- token,
466
- (offsetInfo.from
467
- ? this.getDesiredIndent(offsetInfo.from)
468
- : "") + this._indentType.repeat(offset),
469
- );
470
- }
471
- }
472
- return this._desiredIndentCache.get(token);
473
- }
474
-
475
- /**
476
- * Ignores a token, preventing it from being reported.
477
- * @param {Token} token The token
478
- * @returns {void}
479
- */
480
- ignoreToken(token) {
481
- if (this._tokenInfo.isFirstTokenOfLine(token)) {
482
- this._ignoredTokens.add(token);
483
- }
484
- }
485
-
486
- /**
487
- * Gets the first token that the given token's indentation is dependent on
488
- * @param {Token} token The token
489
- * @returns {Token} The token that the given token depends on, or `null` if the given token is at the top level
490
- */
491
- getFirstDependency(token) {
492
- return this._getOffsetDescriptor(token).from;
493
- }
494
- }
495
-
496
- const ELEMENT_LIST_SCHEMA = {
497
- oneOf: [
498
- {
499
- type: "integer",
500
- minimum: 0,
501
- },
502
- {
503
- enum: ["first", "off"],
504
- },
505
- ],
506
- };
507
-
508
- /** @type {import('../types').Rule.RuleModule} */
509
- module.exports = {
510
- meta: {
511
- deprecated: {
512
- message: "Formatting rules are being moved out of ESLint core.",
513
- url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
514
- deprecatedSince: "8.53.0",
515
- availableUntil: "11.0.0",
516
- replacedBy: [
517
- {
518
- message:
519
- "ESLint Stylistic now maintains deprecated stylistic core rules.",
520
- url: "https://eslint.style/guide/migration",
521
- plugin: {
522
- name: "@stylistic/eslint-plugin",
523
- url: "https://eslint.style",
524
- },
525
- rule: {
526
- name: "indent",
527
- url: "https://eslint.style/rules/indent",
528
- },
529
- },
530
- ],
531
- },
532
- type: "layout",
533
-
534
- docs: {
535
- description: "Enforce consistent indentation",
536
- recommended: false,
537
- url: "https://eslint.org/docs/latest/rules/indent",
538
- },
539
-
540
- fixable: "whitespace",
541
-
542
- schema: [
543
- {
544
- oneOf: [
545
- {
546
- enum: ["tab"],
547
- },
548
- {
549
- type: "integer",
550
- minimum: 0,
551
- },
552
- ],
553
- },
554
- {
555
- type: "object",
556
- properties: {
557
- SwitchCase: {
558
- type: "integer",
559
- minimum: 0,
560
- default: 0,
561
- },
562
- VariableDeclarator: {
563
- oneOf: [
564
- ELEMENT_LIST_SCHEMA,
565
- {
566
- type: "object",
567
- properties: {
568
- var: ELEMENT_LIST_SCHEMA,
569
- let: ELEMENT_LIST_SCHEMA,
570
- const: ELEMENT_LIST_SCHEMA,
571
- },
572
- additionalProperties: false,
573
- },
574
- ],
575
- },
576
- outerIIFEBody: {
577
- oneOf: [
578
- {
579
- type: "integer",
580
- minimum: 0,
581
- },
582
- {
583
- enum: ["off"],
584
- },
585
- ],
586
- },
587
- MemberExpression: {
588
- oneOf: [
589
- {
590
- type: "integer",
591
- minimum: 0,
592
- },
593
- {
594
- enum: ["off"],
595
- },
596
- ],
597
- },
598
- FunctionDeclaration: {
599
- type: "object",
600
- properties: {
601
- parameters: ELEMENT_LIST_SCHEMA,
602
- body: {
603
- type: "integer",
604
- minimum: 0,
605
- },
606
- },
607
- additionalProperties: false,
608
- },
609
- FunctionExpression: {
610
- type: "object",
611
- properties: {
612
- parameters: ELEMENT_LIST_SCHEMA,
613
- body: {
614
- type: "integer",
615
- minimum: 0,
616
- },
617
- },
618
- additionalProperties: false,
619
- },
620
- StaticBlock: {
621
- type: "object",
622
- properties: {
623
- body: {
624
- type: "integer",
625
- minimum: 0,
626
- },
627
- },
628
- additionalProperties: false,
629
- },
630
- CallExpression: {
631
- type: "object",
632
- properties: {
633
- arguments: ELEMENT_LIST_SCHEMA,
634
- },
635
- additionalProperties: false,
636
- },
637
- ArrayExpression: ELEMENT_LIST_SCHEMA,
638
- ObjectExpression: ELEMENT_LIST_SCHEMA,
639
- ImportDeclaration: ELEMENT_LIST_SCHEMA,
640
- flatTernaryExpressions: {
641
- type: "boolean",
642
- default: false,
643
- },
644
- offsetTernaryExpressions: {
645
- type: "boolean",
646
- default: false,
647
- },
648
- ignoredNodes: {
649
- type: "array",
650
- items: {
651
- type: "string",
652
- not: {
653
- pattern: ":exit$",
654
- },
655
- },
656
- },
657
- ignoreComments: {
658
- type: "boolean",
659
- default: false,
660
- },
661
- },
662
- additionalProperties: false,
663
- },
664
- ],
665
- messages: {
666
- wrongIndentation:
667
- "Expected indentation of {{expected}} but found {{actual}}.",
668
- },
669
- },
670
-
671
- create(context) {
672
- const DEFAULT_VARIABLE_INDENT = 1;
673
- const DEFAULT_PARAMETER_INDENT = 1;
674
- const DEFAULT_FUNCTION_BODY_INDENT = 1;
675
-
676
- let indentType = "space";
677
- let indentSize = 4;
678
- const options = {
679
- SwitchCase: 0,
680
- VariableDeclarator: {
681
- var: DEFAULT_VARIABLE_INDENT,
682
- let: DEFAULT_VARIABLE_INDENT,
683
- const: DEFAULT_VARIABLE_INDENT,
684
- },
685
- outerIIFEBody: 1,
686
- FunctionDeclaration: {
687
- parameters: DEFAULT_PARAMETER_INDENT,
688
- body: DEFAULT_FUNCTION_BODY_INDENT,
689
- },
690
- FunctionExpression: {
691
- parameters: DEFAULT_PARAMETER_INDENT,
692
- body: DEFAULT_FUNCTION_BODY_INDENT,
693
- },
694
- StaticBlock: {
695
- body: DEFAULT_FUNCTION_BODY_INDENT,
696
- },
697
- CallExpression: {
698
- arguments: DEFAULT_PARAMETER_INDENT,
699
- },
700
- MemberExpression: 1,
701
- ArrayExpression: 1,
702
- ObjectExpression: 1,
703
- ImportDeclaration: 1,
704
- flatTernaryExpressions: false,
705
- ignoredNodes: [],
706
- ignoreComments: false,
707
- };
708
-
709
- if (context.options.length) {
710
- if (context.options[0] === "tab") {
711
- indentSize = 1;
712
- indentType = "tab";
713
- } else {
714
- indentSize = context.options[0];
715
- indentType = "space";
716
- }
717
-
718
- if (context.options[1]) {
719
- Object.assign(options, context.options[1]);
720
-
721
- if (
722
- typeof options.VariableDeclarator === "number" ||
723
- options.VariableDeclarator === "first"
724
- ) {
725
- options.VariableDeclarator = {
726
- var: options.VariableDeclarator,
727
- let: options.VariableDeclarator,
728
- const: options.VariableDeclarator,
729
- };
730
- }
731
- }
732
- }
733
-
734
- const sourceCode = context.sourceCode;
735
- const tokenInfo = new TokenInfo(sourceCode);
736
- const offsets = new OffsetStorage(
737
- tokenInfo,
738
- indentSize,
739
- indentType === "space" ? " " : "\t",
740
- sourceCode.text.length,
741
- );
742
- const parameterParens = new WeakSet();
743
-
744
- /**
745
- * Creates an error message for a line, given the expected/actual indentation.
746
- * @param {number} expectedAmount The expected amount of indentation characters for this line
747
- * @param {number} actualSpaces The actual number of indentation spaces that were found on this line
748
- * @param {number} actualTabs The actual number of indentation tabs that were found on this line
749
- * @returns {string} An error message for this line
750
- */
751
- function createErrorMessageData(
752
- expectedAmount,
753
- actualSpaces,
754
- actualTabs,
755
- ) {
756
- const expectedStatement = `${expectedAmount} ${indentType}${expectedAmount === 1 ? "" : "s"}`; // e.g. "2 tabs"
757
- const foundSpacesWord = `space${actualSpaces === 1 ? "" : "s"}`; // e.g. "space"
758
- const foundTabsWord = `tab${actualTabs === 1 ? "" : "s"}`; // e.g. "tabs"
759
- let foundStatement;
760
-
761
- if (actualSpaces > 0) {
762
- /*
763
- * Abbreviate the message if the expected indentation is also spaces.
764
- * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
765
- */
766
- foundStatement =
767
- indentType === "space"
768
- ? actualSpaces
769
- : `${actualSpaces} ${foundSpacesWord}`;
770
- } else if (actualTabs > 0) {
771
- foundStatement =
772
- indentType === "tab"
773
- ? actualTabs
774
- : `${actualTabs} ${foundTabsWord}`;
775
- } else {
776
- foundStatement = "0";
777
- }
778
- return {
779
- expected: expectedStatement,
780
- actual: foundStatement,
781
- };
782
- }
783
-
784
- /**
785
- * Reports a given indent violation
786
- * @param {Token} token Token violating the indent rule
787
- * @param {string} neededIndent Expected indentation string
788
- * @returns {void}
789
- */
790
- function report(token, neededIndent) {
791
- const actualIndent = Array.from(tokenInfo.getTokenIndent(token));
792
- const numSpaces = actualIndent.filter(char => char === " ").length;
793
- const numTabs = actualIndent.filter(char => char === "\t").length;
794
-
795
- context.report({
796
- node: token,
797
- messageId: "wrongIndentation",
798
- data: createErrorMessageData(
799
- neededIndent.length,
800
- numSpaces,
801
- numTabs,
802
- ),
803
- loc: {
804
- start: { line: token.loc.start.line, column: 0 },
805
- end: {
806
- line: token.loc.start.line,
807
- column: token.loc.start.column,
808
- },
809
- },
810
- fix(fixer) {
811
- const range = [
812
- token.range[0] - token.loc.start.column,
813
- token.range[0],
814
- ];
815
- const newText = neededIndent;
816
-
817
- return fixer.replaceTextRange(range, newText);
818
- },
819
- });
820
- }
821
-
822
- /**
823
- * Checks if a token's indentation is correct
824
- * @param {Token} token Token to examine
825
- * @param {string} desiredIndent Desired indentation of the string
826
- * @returns {boolean} `true` if the token's indentation is correct
827
- */
828
- function validateTokenIndent(token, desiredIndent) {
829
- const indentation = tokenInfo.getTokenIndent(token);
830
-
831
- return (
832
- indentation === desiredIndent ||
833
- // To avoid conflicts with no-mixed-spaces-and-tabs, don't report mixed spaces and tabs.
834
- (indentation.includes(" ") && indentation.includes("\t"))
835
- );
836
- }
837
-
838
- /**
839
- * Check to see if the node is a file level IIFE
840
- * @param {ASTNode} node The function node to check.
841
- * @returns {boolean} True if the node is the outer IIFE
842
- */
843
- function isOuterIIFE(node) {
844
- /*
845
- * Verify that the node is an IIFE
846
- */
847
- if (
848
- !node.parent ||
849
- node.parent.type !== "CallExpression" ||
850
- node.parent.callee !== node
851
- ) {
852
- return false;
853
- }
854
-
855
- /*
856
- * Navigate legal ancestors to determine whether this IIFE is outer.
857
- * A "legal ancestor" is an expression or statement that causes the function to get executed immediately.
858
- * For example, `!(function(){})()` is an outer IIFE even though it is preceded by a ! operator.
859
- */
860
- let statement = node.parent && node.parent.parent;
861
-
862
- while (
863
- (statement.type === "UnaryExpression" &&
864
- ["!", "~", "+", "-"].includes(statement.operator)) ||
865
- statement.type === "AssignmentExpression" ||
866
- statement.type === "LogicalExpression" ||
867
- statement.type === "SequenceExpression" ||
868
- statement.type === "VariableDeclarator"
869
- ) {
870
- statement = statement.parent;
871
- }
872
-
873
- return (
874
- (statement.type === "ExpressionStatement" ||
875
- statement.type === "VariableDeclaration") &&
876
- statement.parent.type === "Program"
877
- );
878
- }
879
-
880
- /**
881
- * Counts the number of linebreaks that follow the last non-whitespace character in a string
882
- * @param {string} string The string to check
883
- * @returns {number} The number of JavaScript linebreaks that follow the last non-whitespace character,
884
- * or the total number of linebreaks if the string is all whitespace.
885
- */
886
- function countTrailingLinebreaks(string) {
887
- const trailingWhitespace = string.match(/\s*$/u)[0];
888
- const linebreakMatches = trailingWhitespace.match(
889
- astUtils.createGlobalLinebreakMatcher(),
890
- );
891
-
892
- return linebreakMatches === null ? 0 : linebreakMatches.length;
893
- }
894
-
895
- /**
896
- * Check indentation for lists of elements (arrays, objects, function params)
897
- * @param {ASTNode[]} elements List of elements that should be offset
898
- * @param {Token} startToken The start token of the list that element should be aligned against, e.g. '['
899
- * @param {Token} endToken The end token of the list, e.g. ']'
900
- * @param {number|string} offset The amount that the elements should be offset
901
- * @returns {void}
902
- */
903
- function addElementListIndent(elements, startToken, endToken, offset) {
904
- /**
905
- * Gets the first token of a given element, including surrounding parentheses.
906
- * @param {ASTNode} element A node in the `elements` list
907
- * @returns {Token} The first token of this element
908
- */
909
- function getFirstToken(element) {
910
- let token = sourceCode.getTokenBefore(element);
911
-
912
- while (
913
- astUtils.isOpeningParenToken(token) &&
914
- token !== startToken
915
- ) {
916
- token = sourceCode.getTokenBefore(token);
917
- }
918
- return sourceCode.getTokenAfter(token);
919
- }
920
-
921
- // Run through all the tokens in the list, and offset them by one indent level (mainly for comments, other things will end up overridden)
922
- offsets.setDesiredOffsets(
923
- [startToken.range[1], endToken.range[0]],
924
- startToken,
925
- typeof offset === "number" ? offset : 1,
926
- );
927
- offsets.setDesiredOffset(endToken, startToken, 0);
928
-
929
- // If the preference is "first" but there is no first element (e.g. sparse arrays w/ empty first slot), fall back to 1 level.
930
- if (offset === "first" && elements.length && !elements[0]) {
931
- return;
932
- }
933
- elements.forEach((element, index) => {
934
- if (!element) {
935
- // Skip holes in arrays
936
- return;
937
- }
938
- if (offset === "off") {
939
- // Ignore the first token of every element if the "off" option is used
940
- offsets.ignoreToken(getFirstToken(element));
941
- }
942
-
943
- // Offset the following elements correctly relative to the first element
944
- if (index === 0) {
945
- return;
946
- }
947
- if (
948
- offset === "first" &&
949
- tokenInfo.isFirstTokenOfLine(getFirstToken(element))
950
- ) {
951
- offsets.matchOffsetOf(
952
- getFirstToken(elements[0]),
953
- getFirstToken(element),
954
- );
955
- } else {
956
- const previousElement = elements[index - 1];
957
- const firstTokenOfPreviousElement =
958
- previousElement && getFirstToken(previousElement);
959
- const previousElementLastToken =
960
- previousElement &&
961
- sourceCode.getLastToken(previousElement);
962
-
963
- if (
964
- previousElement &&
965
- previousElementLastToken.loc.end.line -
966
- countTrailingLinebreaks(
967
- previousElementLastToken.value,
968
- ) >
969
- startToken.loc.end.line
970
- ) {
971
- offsets.setDesiredOffsets(
972
- [previousElement.range[1], element.range[1]],
973
- firstTokenOfPreviousElement,
974
- 0,
975
- );
976
- }
977
- }
978
- });
979
- }
980
-
981
- /**
982
- * Check and decide whether to check for indentation for blockless nodes
983
- * Scenarios are for or while statements without braces around them
984
- * @param {ASTNode} node node to examine
985
- * @returns {void}
986
- */
987
- function addBlocklessNodeIndent(node) {
988
- if (node.type !== "BlockStatement") {
989
- const lastParentToken = sourceCode.getTokenBefore(
990
- node,
991
- astUtils.isNotOpeningParenToken,
992
- );
993
-
994
- let firstBodyToken = sourceCode.getFirstToken(node);
995
- let lastBodyToken = sourceCode.getLastToken(node);
996
-
997
- while (
998
- astUtils.isOpeningParenToken(
999
- sourceCode.getTokenBefore(firstBodyToken),
1000
- ) &&
1001
- astUtils.isClosingParenToken(
1002
- sourceCode.getTokenAfter(lastBodyToken),
1003
- )
1004
- ) {
1005
- firstBodyToken = sourceCode.getTokenBefore(firstBodyToken);
1006
- lastBodyToken = sourceCode.getTokenAfter(lastBodyToken);
1007
- }
1008
-
1009
- offsets.setDesiredOffsets(
1010
- [firstBodyToken.range[0], lastBodyToken.range[1]],
1011
- lastParentToken,
1012
- 1,
1013
- );
1014
- }
1015
- }
1016
-
1017
- /**
1018
- * Checks the indentation for nodes that are like function calls (`CallExpression` and `NewExpression`)
1019
- * @param {ASTNode} node A CallExpression or NewExpression node
1020
- * @returns {void}
1021
- */
1022
- function addFunctionCallIndent(node) {
1023
- let openingParen;
1024
-
1025
- if (node.arguments.length) {
1026
- openingParen = sourceCode.getFirstTokenBetween(
1027
- node.callee,
1028
- node.arguments[0],
1029
- astUtils.isOpeningParenToken,
1030
- );
1031
- } else {
1032
- openingParen = sourceCode.getLastToken(node, 1);
1033
- }
1034
- const closingParen = sourceCode.getLastToken(node);
1035
-
1036
- parameterParens.add(openingParen);
1037
- parameterParens.add(closingParen);
1038
-
1039
- /*
1040
- * If `?.` token exists, set desired offset for that.
1041
- * This logic is copied from `MemberExpression`'s.
1042
- */
1043
- if (node.optional) {
1044
- const dotToken = sourceCode.getTokenAfter(
1045
- node.callee,
1046
- astUtils.isQuestionDotToken,
1047
- );
1048
- const calleeParenCount = sourceCode.getTokensBetween(
1049
- node.callee,
1050
- dotToken,
1051
- { filter: astUtils.isClosingParenToken },
1052
- ).length;
1053
- const firstTokenOfCallee = calleeParenCount
1054
- ? sourceCode.getTokenBefore(node.callee, {
1055
- skip: calleeParenCount - 1,
1056
- })
1057
- : sourceCode.getFirstToken(node.callee);
1058
- const lastTokenOfCallee = sourceCode.getTokenBefore(dotToken);
1059
- const offsetBase =
1060
- lastTokenOfCallee.loc.end.line ===
1061
- openingParen.loc.start.line
1062
- ? lastTokenOfCallee
1063
- : firstTokenOfCallee;
1064
-
1065
- offsets.setDesiredOffset(dotToken, offsetBase, 1);
1066
- }
1067
-
1068
- const offsetAfterToken =
1069
- node.callee.type === "TaggedTemplateExpression"
1070
- ? sourceCode.getFirstToken(node.callee.quasi)
1071
- : openingParen;
1072
- const offsetToken = sourceCode.getTokenBefore(offsetAfterToken);
1073
-
1074
- offsets.setDesiredOffset(openingParen, offsetToken, 0);
1075
-
1076
- addElementListIndent(
1077
- node.arguments,
1078
- openingParen,
1079
- closingParen,
1080
- options.CallExpression.arguments,
1081
- );
1082
- }
1083
-
1084
- /**
1085
- * Checks the indentation of parenthesized values, given a list of tokens in a program
1086
- * @param {Token[]} tokens A list of tokens
1087
- * @returns {void}
1088
- */
1089
- function addParensIndent(tokens) {
1090
- const parenStack = [];
1091
- const parenPairs = [];
1092
-
1093
- for (let i = 0; i < tokens.length; i++) {
1094
- const nextToken = tokens[i];
1095
-
1096
- if (astUtils.isOpeningParenToken(nextToken)) {
1097
- parenStack.push(nextToken);
1098
- } else if (astUtils.isClosingParenToken(nextToken)) {
1099
- parenPairs.push({
1100
- left: parenStack.pop(),
1101
- right: nextToken,
1102
- });
1103
- }
1104
- }
1105
-
1106
- for (let i = parenPairs.length - 1; i >= 0; i--) {
1107
- const leftParen = parenPairs[i].left;
1108
- const rightParen = parenPairs[i].right;
1109
-
1110
- // We only want to handle parens around expressions, so exclude parentheses that are in function parameters and function call arguments.
1111
- if (
1112
- !parameterParens.has(leftParen) &&
1113
- !parameterParens.has(rightParen)
1114
- ) {
1115
- const parenthesizedTokens = new Set(
1116
- sourceCode.getTokensBetween(leftParen, rightParen),
1117
- );
1118
-
1119
- parenthesizedTokens.forEach(token => {
1120
- if (
1121
- !parenthesizedTokens.has(
1122
- offsets.getFirstDependency(token),
1123
- )
1124
- ) {
1125
- offsets.setDesiredOffset(token, leftParen, 1);
1126
- }
1127
- });
1128
- }
1129
-
1130
- offsets.setDesiredOffset(rightParen, leftParen, 0);
1131
- }
1132
- }
1133
-
1134
- /**
1135
- * Ignore all tokens within an unknown node whose offset do not depend
1136
- * on another token's offset within the unknown node
1137
- * @param {ASTNode} node Unknown Node
1138
- * @returns {void}
1139
- */
1140
- function ignoreNode(node) {
1141
- const unknownNodeTokens = new Set(
1142
- sourceCode.getTokens(node, { includeComments: true }),
1143
- );
1144
-
1145
- unknownNodeTokens.forEach(token => {
1146
- if (!unknownNodeTokens.has(offsets.getFirstDependency(token))) {
1147
- const firstTokenOfLine =
1148
- tokenInfo.getFirstTokenOfLine(token);
1149
-
1150
- if (token === firstTokenOfLine) {
1151
- offsets.ignoreToken(token);
1152
- } else {
1153
- offsets.setDesiredOffset(token, firstTokenOfLine, 0);
1154
- }
1155
- }
1156
- });
1157
- }
1158
-
1159
- /**
1160
- * Check whether the given token is on the first line of a statement.
1161
- * @param {Token} token The token to check.
1162
- * @param {ASTNode} leafNode The expression node that the token belongs directly.
1163
- * @returns {boolean} `true` if the token is on the first line of a statement.
1164
- */
1165
- function isOnFirstLineOfStatement(token, leafNode) {
1166
- let node = leafNode;
1167
-
1168
- while (
1169
- node.parent &&
1170
- !node.parent.type.endsWith("Statement") &&
1171
- !node.parent.type.endsWith("Declaration")
1172
- ) {
1173
- node = node.parent;
1174
- }
1175
- node = node.parent;
1176
-
1177
- return !node || node.loc.start.line === token.loc.start.line;
1178
- }
1179
-
1180
- /**
1181
- * Check whether there are any blank (whitespace-only) lines between
1182
- * two tokens on separate lines.
1183
- * @param {Token} firstToken The first token.
1184
- * @param {Token} secondToken The second token.
1185
- * @returns {boolean} `true` if the tokens are on separate lines and
1186
- * there exists a blank line between them, `false` otherwise.
1187
- */
1188
- function hasBlankLinesBetween(firstToken, secondToken) {
1189
- const firstTokenLine = firstToken.loc.end.line;
1190
- const secondTokenLine = secondToken.loc.start.line;
1191
-
1192
- if (
1193
- firstTokenLine === secondTokenLine ||
1194
- firstTokenLine === secondTokenLine - 1
1195
- ) {
1196
- return false;
1197
- }
1198
-
1199
- for (
1200
- let line = firstTokenLine + 1;
1201
- line < secondTokenLine;
1202
- ++line
1203
- ) {
1204
- if (!tokenInfo.firstTokensByLineNumber.has(line)) {
1205
- return true;
1206
- }
1207
- }
1208
-
1209
- return false;
1210
- }
1211
-
1212
- const ignoredNodeFirstTokens = new Set();
1213
-
1214
- const baseOffsetListeners = {
1215
- "ArrayExpression, ArrayPattern"(node) {
1216
- const openingBracket = sourceCode.getFirstToken(node);
1217
- const closingBracket = sourceCode.getTokenAfter(
1218
- [...node.elements].reverse().find(_ => _) || openingBracket,
1219
- astUtils.isClosingBracketToken,
1220
- );
1221
-
1222
- addElementListIndent(
1223
- node.elements,
1224
- openingBracket,
1225
- closingBracket,
1226
- options.ArrayExpression,
1227
- );
1228
- },
1229
-
1230
- "ObjectExpression, ObjectPattern"(node) {
1231
- const openingCurly = sourceCode.getFirstToken(node);
1232
- const closingCurly = sourceCode.getTokenAfter(
1233
- node.properties.length
1234
- ? node.properties.at(-1)
1235
- : openingCurly,
1236
- astUtils.isClosingBraceToken,
1237
- );
1238
-
1239
- addElementListIndent(
1240
- node.properties,
1241
- openingCurly,
1242
- closingCurly,
1243
- options.ObjectExpression,
1244
- );
1245
- },
1246
-
1247
- ArrowFunctionExpression(node) {
1248
- const maybeOpeningParen = sourceCode.getFirstToken(node, {
1249
- skip: node.async ? 1 : 0,
1250
- });
1251
-
1252
- if (astUtils.isOpeningParenToken(maybeOpeningParen)) {
1253
- const openingParen = maybeOpeningParen;
1254
- const closingParen = sourceCode.getTokenBefore(
1255
- node.body,
1256
- astUtils.isClosingParenToken,
1257
- );
1258
-
1259
- parameterParens.add(openingParen);
1260
- parameterParens.add(closingParen);
1261
- addElementListIndent(
1262
- node.params,
1263
- openingParen,
1264
- closingParen,
1265
- options.FunctionExpression.parameters,
1266
- );
1267
- }
1268
-
1269
- addBlocklessNodeIndent(node.body);
1270
- },
1271
-
1272
- AssignmentExpression(node) {
1273
- const operator = sourceCode.getFirstTokenBetween(
1274
- node.left,
1275
- node.right,
1276
- token => token.value === node.operator,
1277
- );
1278
-
1279
- offsets.setDesiredOffsets(
1280
- [operator.range[0], node.range[1]],
1281
- sourceCode.getLastToken(node.left),
1282
- 1,
1283
- );
1284
- offsets.ignoreToken(operator);
1285
- offsets.ignoreToken(sourceCode.getTokenAfter(operator));
1286
- },
1287
-
1288
- "BinaryExpression, LogicalExpression"(node) {
1289
- const operator = sourceCode.getFirstTokenBetween(
1290
- node.left,
1291
- node.right,
1292
- token => token.value === node.operator,
1293
- );
1294
-
1295
- /*
1296
- * For backwards compatibility, don't check BinaryExpression indents, e.g.
1297
- * var foo = bar &&
1298
- * baz;
1299
- */
1300
-
1301
- const tokenAfterOperator = sourceCode.getTokenAfter(operator);
1302
-
1303
- offsets.ignoreToken(operator);
1304
- offsets.ignoreToken(tokenAfterOperator);
1305
- offsets.setDesiredOffset(tokenAfterOperator, operator, 0);
1306
- },
1307
-
1308
- "BlockStatement, ClassBody"(node) {
1309
- let blockIndentLevel;
1310
-
1311
- if (node.parent && isOuterIIFE(node.parent)) {
1312
- blockIndentLevel = options.outerIIFEBody;
1313
- } else if (
1314
- node.parent &&
1315
- (node.parent.type === "FunctionExpression" ||
1316
- node.parent.type === "ArrowFunctionExpression")
1317
- ) {
1318
- blockIndentLevel = options.FunctionExpression.body;
1319
- } else if (
1320
- node.parent &&
1321
- node.parent.type === "FunctionDeclaration"
1322
- ) {
1323
- blockIndentLevel = options.FunctionDeclaration.body;
1324
- } else {
1325
- blockIndentLevel = 1;
1326
- }
1327
-
1328
- /*
1329
- * For blocks that aren't lone statements, ensure that the opening curly brace
1330
- * is aligned with the parent.
1331
- */
1332
- if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
1333
- offsets.setDesiredOffset(
1334
- sourceCode.getFirstToken(node),
1335
- sourceCode.getFirstToken(node.parent),
1336
- 0,
1337
- );
1338
- }
1339
-
1340
- addElementListIndent(
1341
- node.body,
1342
- sourceCode.getFirstToken(node),
1343
- sourceCode.getLastToken(node),
1344
- blockIndentLevel,
1345
- );
1346
- },
1347
-
1348
- CallExpression: addFunctionCallIndent,
1349
-
1350
- "ClassDeclaration[superClass], ClassExpression[superClass]"(node) {
1351
- const classToken = sourceCode.getFirstToken(node);
1352
- const extendsToken = sourceCode.getTokenBefore(
1353
- node.superClass,
1354
- astUtils.isNotOpeningParenToken,
1355
- );
1356
-
1357
- offsets.setDesiredOffsets(
1358
- [extendsToken.range[0], node.body.range[0]],
1359
- classToken,
1360
- 1,
1361
- );
1362
- },
1363
-
1364
- ConditionalExpression(node) {
1365
- const firstToken = sourceCode.getFirstToken(node);
1366
-
1367
- // `flatTernaryExpressions` option is for the following style:
1368
- // var a =
1369
- // foo > 0 ? bar :
1370
- // foo < 0 ? baz :
1371
- // /*else*/ qiz ;
1372
- if (
1373
- !options.flatTernaryExpressions ||
1374
- !astUtils.isTokenOnSameLine(node.test, node.consequent) ||
1375
- isOnFirstLineOfStatement(firstToken, node)
1376
- ) {
1377
- const questionMarkToken = sourceCode.getFirstTokenBetween(
1378
- node.test,
1379
- node.consequent,
1380
- token =>
1381
- token.type === "Punctuator" && token.value === "?",
1382
- );
1383
- const colonToken = sourceCode.getFirstTokenBetween(
1384
- node.consequent,
1385
- node.alternate,
1386
- token =>
1387
- token.type === "Punctuator" && token.value === ":",
1388
- );
1389
-
1390
- const firstConsequentToken =
1391
- sourceCode.getTokenAfter(questionMarkToken);
1392
- const lastConsequentToken =
1393
- sourceCode.getTokenBefore(colonToken);
1394
- const firstAlternateToken =
1395
- sourceCode.getTokenAfter(colonToken);
1396
-
1397
- offsets.setDesiredOffset(questionMarkToken, firstToken, 1);
1398
- offsets.setDesiredOffset(colonToken, firstToken, 1);
1399
-
1400
- offsets.setDesiredOffset(
1401
- firstConsequentToken,
1402
- firstToken,
1403
- firstConsequentToken.type === "Punctuator" &&
1404
- options.offsetTernaryExpressions
1405
- ? 2
1406
- : 1,
1407
- );
1408
-
1409
- /*
1410
- * The alternate and the consequent should usually have the same indentation.
1411
- * If they share part of a line, align the alternate against the first token of the consequent.
1412
- * This allows the alternate to be indented correctly in cases like this:
1413
- * foo ? (
1414
- * bar
1415
- * ) : ( // this '(' is aligned with the '(' above, so it's considered to be aligned with `foo`
1416
- * baz // as a result, `baz` is offset by 1 rather than 2
1417
- * )
1418
- */
1419
- if (
1420
- lastConsequentToken.loc.end.line ===
1421
- firstAlternateToken.loc.start.line
1422
- ) {
1423
- offsets.setDesiredOffset(
1424
- firstAlternateToken,
1425
- firstConsequentToken,
1426
- 0,
1427
- );
1428
- } else {
1429
- /**
1430
- * If the alternate and consequent do not share part of a line, offset the alternate from the first
1431
- * token of the conditional expression. For example:
1432
- * foo ? bar
1433
- * : baz
1434
- *
1435
- * If `baz` were aligned with `bar` rather than being offset by 1 from `foo`, `baz` would end up
1436
- * having no expected indentation.
1437
- */
1438
- offsets.setDesiredOffset(
1439
- firstAlternateToken,
1440
- firstToken,
1441
- firstAlternateToken.type === "Punctuator" &&
1442
- options.offsetTernaryExpressions
1443
- ? 2
1444
- : 1,
1445
- );
1446
- }
1447
- }
1448
- },
1449
-
1450
- "DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement, WithStatement":
1451
- node => addBlocklessNodeIndent(node.body),
1452
-
1453
- ExportNamedDeclaration(node) {
1454
- if (node.declaration === null) {
1455
- const closingCurly = sourceCode.getLastToken(
1456
- node,
1457
- astUtils.isClosingBraceToken,
1458
- );
1459
-
1460
- // Indent the specifiers in `export {foo, bar, baz}`
1461
- addElementListIndent(
1462
- node.specifiers,
1463
- sourceCode.getFirstToken(node, { skip: 1 }),
1464
- closingCurly,
1465
- 1,
1466
- );
1467
-
1468
- if (node.source) {
1469
- // Indent everything after and including the `from` token in `export {foo, bar, baz} from 'qux'`
1470
- offsets.setDesiredOffsets(
1471
- [closingCurly.range[1], node.range[1]],
1472
- sourceCode.getFirstToken(node),
1473
- 1,
1474
- );
1475
- }
1476
- }
1477
- },
1478
-
1479
- ForStatement(node) {
1480
- const forOpeningParen = sourceCode.getFirstToken(node, 1);
1481
-
1482
- if (node.init) {
1483
- offsets.setDesiredOffsets(
1484
- node.init.range,
1485
- forOpeningParen,
1486
- 1,
1487
- );
1488
- }
1489
- if (node.test) {
1490
- offsets.setDesiredOffsets(
1491
- node.test.range,
1492
- forOpeningParen,
1493
- 1,
1494
- );
1495
- }
1496
- if (node.update) {
1497
- offsets.setDesiredOffsets(
1498
- node.update.range,
1499
- forOpeningParen,
1500
- 1,
1501
- );
1502
- }
1503
- addBlocklessNodeIndent(node.body);
1504
- },
1505
-
1506
- "FunctionDeclaration, FunctionExpression"(node) {
1507
- const closingParen = sourceCode.getTokenBefore(node.body);
1508
- const openingParen = sourceCode.getTokenBefore(
1509
- node.params.length ? node.params[0] : closingParen,
1510
- );
1511
-
1512
- parameterParens.add(openingParen);
1513
- parameterParens.add(closingParen);
1514
- addElementListIndent(
1515
- node.params,
1516
- openingParen,
1517
- closingParen,
1518
- options[node.type].parameters,
1519
- );
1520
- },
1521
-
1522
- IfStatement(node) {
1523
- addBlocklessNodeIndent(node.consequent);
1524
- if (node.alternate) {
1525
- addBlocklessNodeIndent(node.alternate);
1526
- }
1527
- },
1528
-
1529
- /*
1530
- * For blockless nodes with semicolon-first style, don't indent the semicolon.
1531
- * e.g.
1532
- * if (foo)
1533
- * bar()
1534
- * ; [1, 2, 3].map(foo)
1535
- *
1536
- * Traversal into the node sets indentation of the semicolon, so we need to override it on exit.
1537
- */
1538
- ":matches(DoWhileStatement, ForStatement, ForInStatement, ForOfStatement, IfStatement, WhileStatement, WithStatement):exit"(
1539
- node,
1540
- ) {
1541
- let nodesToCheck;
1542
-
1543
- if (node.type === "IfStatement") {
1544
- nodesToCheck = [node.consequent];
1545
- if (node.alternate) {
1546
- nodesToCheck.push(node.alternate);
1547
- }
1548
- } else {
1549
- nodesToCheck = [node.body];
1550
- }
1551
-
1552
- for (const nodeToCheck of nodesToCheck) {
1553
- const lastToken = sourceCode.getLastToken(nodeToCheck);
1554
-
1555
- if (astUtils.isSemicolonToken(lastToken)) {
1556
- const tokenBeforeLast =
1557
- sourceCode.getTokenBefore(lastToken);
1558
- const tokenAfterLast =
1559
- sourceCode.getTokenAfter(lastToken);
1560
-
1561
- // override indentation of `;` only if its line looks like a semicolon-first style line
1562
- if (
1563
- !astUtils.isTokenOnSameLine(
1564
- tokenBeforeLast,
1565
- lastToken,
1566
- ) &&
1567
- tokenAfterLast &&
1568
- astUtils.isTokenOnSameLine(
1569
- lastToken,
1570
- tokenAfterLast,
1571
- )
1572
- ) {
1573
- offsets.setDesiredOffset(
1574
- lastToken,
1575
- sourceCode.getFirstToken(node),
1576
- 0,
1577
- );
1578
- }
1579
- }
1580
- }
1581
- },
1582
-
1583
- ImportDeclaration(node) {
1584
- if (
1585
- node.specifiers.some(
1586
- specifier => specifier.type === "ImportSpecifier",
1587
- )
1588
- ) {
1589
- const openingCurly = sourceCode.getFirstToken(
1590
- node,
1591
- astUtils.isOpeningBraceToken,
1592
- );
1593
- const closingCurly = sourceCode.getLastToken(
1594
- node,
1595
- astUtils.isClosingBraceToken,
1596
- );
1597
-
1598
- addElementListIndent(
1599
- node.specifiers.filter(
1600
- specifier => specifier.type === "ImportSpecifier",
1601
- ),
1602
- openingCurly,
1603
- closingCurly,
1604
- options.ImportDeclaration,
1605
- );
1606
- }
1607
-
1608
- const fromToken = sourceCode.getLastToken(
1609
- node,
1610
- token =>
1611
- token.type === "Identifier" && token.value === "from",
1612
- );
1613
- const sourceToken = sourceCode.getLastToken(
1614
- node,
1615
- token => token.type === "String",
1616
- );
1617
- const semiToken = sourceCode.getLastToken(
1618
- node,
1619
- token => token.type === "Punctuator" && token.value === ";",
1620
- );
1621
-
1622
- if (fromToken) {
1623
- const end =
1624
- semiToken && semiToken.range[1] === sourceToken.range[1]
1625
- ? node.range[1]
1626
- : sourceToken.range[1];
1627
-
1628
- offsets.setDesiredOffsets(
1629
- [fromToken.range[0], end],
1630
- sourceCode.getFirstToken(node),
1631
- 1,
1632
- );
1633
- }
1634
- },
1635
-
1636
- ImportExpression(node) {
1637
- const openingParen = sourceCode.getFirstToken(node, 1);
1638
- const closingParen = sourceCode.getLastToken(node);
1639
-
1640
- parameterParens.add(openingParen);
1641
- parameterParens.add(closingParen);
1642
- offsets.setDesiredOffset(
1643
- openingParen,
1644
- sourceCode.getTokenBefore(openingParen),
1645
- 0,
1646
- );
1647
-
1648
- addElementListIndent(
1649
- [node.source],
1650
- openingParen,
1651
- closingParen,
1652
- options.CallExpression.arguments,
1653
- );
1654
- },
1655
-
1656
- "MemberExpression, JSXMemberExpression, MetaProperty"(node) {
1657
- const object =
1658
- node.type === "MetaProperty" ? node.meta : node.object;
1659
- const firstNonObjectToken = sourceCode.getFirstTokenBetween(
1660
- object,
1661
- node.property,
1662
- astUtils.isNotClosingParenToken,
1663
- );
1664
- const secondNonObjectToken =
1665
- sourceCode.getTokenAfter(firstNonObjectToken);
1666
-
1667
- const objectParenCount = sourceCode.getTokensBetween(
1668
- object,
1669
- node.property,
1670
- { filter: astUtils.isClosingParenToken },
1671
- ).length;
1672
- const firstObjectToken = objectParenCount
1673
- ? sourceCode.getTokenBefore(object, {
1674
- skip: objectParenCount - 1,
1675
- })
1676
- : sourceCode.getFirstToken(object);
1677
- const lastObjectToken =
1678
- sourceCode.getTokenBefore(firstNonObjectToken);
1679
- const firstPropertyToken = node.computed
1680
- ? firstNonObjectToken
1681
- : secondNonObjectToken;
1682
-
1683
- if (node.computed) {
1684
- // For computed MemberExpressions, match the closing bracket with the opening bracket.
1685
- offsets.setDesiredOffset(
1686
- sourceCode.getLastToken(node),
1687
- firstNonObjectToken,
1688
- 0,
1689
- );
1690
- offsets.setDesiredOffsets(
1691
- node.property.range,
1692
- firstNonObjectToken,
1693
- 1,
1694
- );
1695
- }
1696
-
1697
- /*
1698
- * If the object ends on the same line that the property starts, match against the last token
1699
- * of the object, to ensure that the MemberExpression is not indented.
1700
- *
1701
- * Otherwise, match against the first token of the object, e.g.
1702
- * foo
1703
- * .bar
1704
- * .baz // <-- offset by 1 from `foo`
1705
- */
1706
- const offsetBase =
1707
- lastObjectToken.loc.end.line ===
1708
- firstPropertyToken.loc.start.line
1709
- ? lastObjectToken
1710
- : firstObjectToken;
1711
-
1712
- if (typeof options.MemberExpression === "number") {
1713
- // Match the dot (for non-computed properties) or the opening bracket (for computed properties) against the object.
1714
- offsets.setDesiredOffset(
1715
- firstNonObjectToken,
1716
- offsetBase,
1717
- options.MemberExpression,
1718
- );
1719
-
1720
- /*
1721
- * For computed MemberExpressions, match the first token of the property against the opening bracket.
1722
- * Otherwise, match the first token of the property against the object.
1723
- */
1724
- offsets.setDesiredOffset(
1725
- secondNonObjectToken,
1726
- node.computed ? firstNonObjectToken : offsetBase,
1727
- options.MemberExpression,
1728
- );
1729
- } else {
1730
- // If the MemberExpression option is off, ignore the dot and the first token of the property.
1731
- offsets.ignoreToken(firstNonObjectToken);
1732
- offsets.ignoreToken(secondNonObjectToken);
1733
-
1734
- // To ignore the property indentation, ensure that the property tokens depend on the ignored tokens.
1735
- offsets.setDesiredOffset(
1736
- firstNonObjectToken,
1737
- offsetBase,
1738
- 0,
1739
- );
1740
- offsets.setDesiredOffset(
1741
- secondNonObjectToken,
1742
- firstNonObjectToken,
1743
- 0,
1744
- );
1745
- }
1746
- },
1747
-
1748
- NewExpression(node) {
1749
- // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
1750
- if (
1751
- node.arguments.length > 0 ||
1752
- (astUtils.isClosingParenToken(
1753
- sourceCode.getLastToken(node),
1754
- ) &&
1755
- astUtils.isOpeningParenToken(
1756
- sourceCode.getLastToken(node, 1),
1757
- ))
1758
- ) {
1759
- addFunctionCallIndent(node);
1760
- }
1761
- },
1762
-
1763
- Property(node) {
1764
- if (!node.shorthand && !node.method && node.kind === "init") {
1765
- const colon = sourceCode.getFirstTokenBetween(
1766
- node.key,
1767
- node.value,
1768
- astUtils.isColonToken,
1769
- );
1770
-
1771
- offsets.ignoreToken(sourceCode.getTokenAfter(colon));
1772
- }
1773
- },
1774
-
1775
- PropertyDefinition(node) {
1776
- const firstToken = sourceCode.getFirstToken(node);
1777
- const maybeSemicolonToken = sourceCode.getLastToken(node);
1778
- let keyLastToken;
1779
-
1780
- // Indent key.
1781
- if (node.computed) {
1782
- const bracketTokenL = sourceCode.getTokenBefore(
1783
- node.key,
1784
- astUtils.isOpeningBracketToken,
1785
- );
1786
- const bracketTokenR = (keyLastToken =
1787
- sourceCode.getTokenAfter(
1788
- node.key,
1789
- astUtils.isClosingBracketToken,
1790
- ));
1791
- const keyRange = [
1792
- bracketTokenL.range[1],
1793
- bracketTokenR.range[0],
1794
- ];
1795
-
1796
- if (bracketTokenL !== firstToken) {
1797
- offsets.setDesiredOffset(bracketTokenL, firstToken, 0);
1798
- }
1799
- offsets.setDesiredOffsets(keyRange, bracketTokenL, 1);
1800
- offsets.setDesiredOffset(bracketTokenR, bracketTokenL, 0);
1801
- } else {
1802
- const idToken = (keyLastToken = sourceCode.getFirstToken(
1803
- node.key,
1804
- ));
1805
-
1806
- if (idToken !== firstToken) {
1807
- offsets.setDesiredOffset(idToken, firstToken, 1);
1808
- }
1809
- }
1810
-
1811
- // Indent initializer.
1812
- if (node.value) {
1813
- const eqToken = sourceCode.getTokenBefore(
1814
- node.value,
1815
- astUtils.isEqToken,
1816
- );
1817
- const valueToken = sourceCode.getTokenAfter(eqToken);
1818
-
1819
- offsets.setDesiredOffset(eqToken, keyLastToken, 1);
1820
- offsets.setDesiredOffset(valueToken, eqToken, 1);
1821
- if (astUtils.isSemicolonToken(maybeSemicolonToken)) {
1822
- offsets.setDesiredOffset(
1823
- maybeSemicolonToken,
1824
- eqToken,
1825
- 1,
1826
- );
1827
- }
1828
- } else if (astUtils.isSemicolonToken(maybeSemicolonToken)) {
1829
- offsets.setDesiredOffset(
1830
- maybeSemicolonToken,
1831
- keyLastToken,
1832
- 1,
1833
- );
1834
- }
1835
- },
1836
-
1837
- StaticBlock(node) {
1838
- const openingCurly = sourceCode.getFirstToken(node, {
1839
- skip: 1,
1840
- }); // skip the `static` token
1841
- const closingCurly = sourceCode.getLastToken(node);
1842
-
1843
- addElementListIndent(
1844
- node.body,
1845
- openingCurly,
1846
- closingCurly,
1847
- options.StaticBlock.body,
1848
- );
1849
- },
1850
-
1851
- SwitchStatement(node) {
1852
- const openingCurly = sourceCode.getTokenAfter(
1853
- node.discriminant,
1854
- astUtils.isOpeningBraceToken,
1855
- );
1856
- const closingCurly = sourceCode.getLastToken(node);
1857
-
1858
- offsets.setDesiredOffsets(
1859
- [openingCurly.range[1], closingCurly.range[0]],
1860
- openingCurly,
1861
- options.SwitchCase,
1862
- );
1863
-
1864
- if (node.cases.length) {
1865
- sourceCode
1866
- .getTokensBetween(node.cases.at(-1), closingCurly, {
1867
- includeComments: true,
1868
- filter: astUtils.isCommentToken,
1869
- })
1870
- .forEach(token => offsets.ignoreToken(token));
1871
- }
1872
- },
1873
-
1874
- SwitchCase(node) {
1875
- if (
1876
- !(
1877
- node.consequent.length === 1 &&
1878
- node.consequent[0].type === "BlockStatement"
1879
- )
1880
- ) {
1881
- const caseKeyword = sourceCode.getFirstToken(node);
1882
- const tokenAfterCurrentCase =
1883
- sourceCode.getTokenAfter(node);
1884
-
1885
- offsets.setDesiredOffsets(
1886
- [caseKeyword.range[1], tokenAfterCurrentCase.range[0]],
1887
- caseKeyword,
1888
- 1,
1889
- );
1890
- }
1891
- },
1892
-
1893
- TemplateLiteral(node) {
1894
- node.expressions.forEach((expression, index) => {
1895
- const previousQuasi = node.quasis[index];
1896
- const nextQuasi = node.quasis[index + 1];
1897
- const tokenToAlignFrom =
1898
- previousQuasi.loc.start.line ===
1899
- previousQuasi.loc.end.line
1900
- ? sourceCode.getFirstToken(previousQuasi)
1901
- : null;
1902
-
1903
- offsets.setDesiredOffsets(
1904
- [previousQuasi.range[1], nextQuasi.range[0]],
1905
- tokenToAlignFrom,
1906
- 1,
1907
- );
1908
- offsets.setDesiredOffset(
1909
- sourceCode.getFirstToken(nextQuasi),
1910
- tokenToAlignFrom,
1911
- 0,
1912
- );
1913
- });
1914
- },
1915
-
1916
- VariableDeclaration(node) {
1917
- let variableIndent = Object.hasOwn(
1918
- options.VariableDeclarator,
1919
- node.kind,
1920
- )
1921
- ? options.VariableDeclarator[node.kind]
1922
- : DEFAULT_VARIABLE_INDENT;
1923
-
1924
- const firstToken = sourceCode.getFirstToken(node),
1925
- lastToken = sourceCode.getLastToken(node);
1926
-
1927
- if (options.VariableDeclarator[node.kind] === "first") {
1928
- if (node.declarations.length > 1) {
1929
- addElementListIndent(
1930
- node.declarations,
1931
- firstToken,
1932
- lastToken,
1933
- "first",
1934
- );
1935
- return;
1936
- }
1937
-
1938
- variableIndent = DEFAULT_VARIABLE_INDENT;
1939
- }
1940
-
1941
- if (
1942
- node.declarations.at(-1).loc.start.line >
1943
- node.loc.start.line
1944
- ) {
1945
- /*
1946
- * VariableDeclarator indentation is a bit different from other forms of indentation, in that the
1947
- * indentation of an opening bracket sometimes won't match that of a closing bracket. For example,
1948
- * the following indentations are correct:
1949
- *
1950
- * var foo = {
1951
- * ok: true
1952
- * };
1953
- *
1954
- * var foo = {
1955
- * ok: true,
1956
- * },
1957
- * bar = 1;
1958
- *
1959
- * Account for when exiting the AST (after indentations have already been set for the nodes in
1960
- * the declaration) by manually increasing the indentation level of the tokens in this declarator
1961
- * on the same line as the start of the declaration, provided that there are declarators that
1962
- * follow this one.
1963
- */
1964
- offsets.setDesiredOffsets(
1965
- node.range,
1966
- firstToken,
1967
- variableIndent,
1968
- true,
1969
- );
1970
- } else {
1971
- offsets.setDesiredOffsets(
1972
- node.range,
1973
- firstToken,
1974
- variableIndent,
1975
- );
1976
- }
1977
-
1978
- if (astUtils.isSemicolonToken(lastToken)) {
1979
- offsets.ignoreToken(lastToken);
1980
- }
1981
- },
1982
-
1983
- VariableDeclarator(node) {
1984
- if (node.init) {
1985
- const equalOperator = sourceCode.getTokenBefore(
1986
- node.init,
1987
- astUtils.isNotOpeningParenToken,
1988
- );
1989
- const tokenAfterOperator =
1990
- sourceCode.getTokenAfter(equalOperator);
1991
-
1992
- offsets.ignoreToken(equalOperator);
1993
- offsets.ignoreToken(tokenAfterOperator);
1994
- offsets.setDesiredOffsets(
1995
- [tokenAfterOperator.range[0], node.range[1]],
1996
- equalOperator,
1997
- 1,
1998
- );
1999
- offsets.setDesiredOffset(
2000
- equalOperator,
2001
- sourceCode.getLastToken(node.id),
2002
- 0,
2003
- );
2004
- }
2005
- },
2006
-
2007
- "JSXAttribute[value]"(node) {
2008
- const equalsToken = sourceCode.getFirstTokenBetween(
2009
- node.name,
2010
- node.value,
2011
- token => token.type === "Punctuator" && token.value === "=",
2012
- );
2013
-
2014
- offsets.setDesiredOffsets(
2015
- [equalsToken.range[0], node.value.range[1]],
2016
- sourceCode.getFirstToken(node.name),
2017
- 1,
2018
- );
2019
- },
2020
-
2021
- JSXElement(node) {
2022
- if (node.closingElement) {
2023
- addElementListIndent(
2024
- node.children,
2025
- sourceCode.getFirstToken(node.openingElement),
2026
- sourceCode.getFirstToken(node.closingElement),
2027
- 1,
2028
- );
2029
- }
2030
- },
2031
-
2032
- JSXOpeningElement(node) {
2033
- const firstToken = sourceCode.getFirstToken(node);
2034
- let closingToken;
2035
-
2036
- if (node.selfClosing) {
2037
- closingToken = sourceCode.getLastToken(node, { skip: 1 });
2038
- offsets.setDesiredOffset(
2039
- sourceCode.getLastToken(node),
2040
- closingToken,
2041
- 0,
2042
- );
2043
- } else {
2044
- closingToken = sourceCode.getLastToken(node);
2045
- }
2046
- offsets.setDesiredOffsets(
2047
- node.name.range,
2048
- sourceCode.getFirstToken(node),
2049
- );
2050
- addElementListIndent(
2051
- node.attributes,
2052
- firstToken,
2053
- closingToken,
2054
- 1,
2055
- );
2056
- },
2057
-
2058
- JSXClosingElement(node) {
2059
- const firstToken = sourceCode.getFirstToken(node);
2060
-
2061
- offsets.setDesiredOffsets(node.name.range, firstToken, 1);
2062
- },
2063
-
2064
- JSXFragment(node) {
2065
- const firstOpeningToken = sourceCode.getFirstToken(
2066
- node.openingFragment,
2067
- );
2068
- const firstClosingToken = sourceCode.getFirstToken(
2069
- node.closingFragment,
2070
- );
2071
-
2072
- addElementListIndent(
2073
- node.children,
2074
- firstOpeningToken,
2075
- firstClosingToken,
2076
- 1,
2077
- );
2078
- },
2079
-
2080
- JSXOpeningFragment(node) {
2081
- const firstToken = sourceCode.getFirstToken(node);
2082
- const closingToken = sourceCode.getLastToken(node);
2083
-
2084
- offsets.setDesiredOffsets(node.range, firstToken, 1);
2085
- offsets.matchOffsetOf(firstToken, closingToken);
2086
- },
2087
-
2088
- JSXClosingFragment(node) {
2089
- const firstToken = sourceCode.getFirstToken(node);
2090
- const slashToken = sourceCode.getLastToken(node, { skip: 1 });
2091
- const closingToken = sourceCode.getLastToken(node);
2092
- const tokenToMatch = astUtils.isTokenOnSameLine(
2093
- slashToken,
2094
- closingToken,
2095
- )
2096
- ? slashToken
2097
- : closingToken;
2098
-
2099
- offsets.setDesiredOffsets(node.range, firstToken, 1);
2100
- offsets.matchOffsetOf(firstToken, tokenToMatch);
2101
- },
2102
-
2103
- JSXExpressionContainer(node) {
2104
- const openingCurly = sourceCode.getFirstToken(node);
2105
- const closingCurly = sourceCode.getLastToken(node);
2106
-
2107
- offsets.setDesiredOffsets(
2108
- [openingCurly.range[1], closingCurly.range[0]],
2109
- openingCurly,
2110
- 1,
2111
- );
2112
- },
2113
-
2114
- JSXSpreadAttribute(node) {
2115
- const openingCurly = sourceCode.getFirstToken(node);
2116
- const closingCurly = sourceCode.getLastToken(node);
2117
-
2118
- offsets.setDesiredOffsets(
2119
- [openingCurly.range[1], closingCurly.range[0]],
2120
- openingCurly,
2121
- 1,
2122
- );
2123
- },
2124
-
2125
- "*"(node) {
2126
- const firstToken = sourceCode.getFirstToken(node);
2127
-
2128
- // Ensure that the children of every node are indented at least as much as the first token.
2129
- if (firstToken && !ignoredNodeFirstTokens.has(firstToken)) {
2130
- offsets.setDesiredOffsets(node.range, firstToken, 0);
2131
- }
2132
- },
2133
- };
2134
-
2135
- const listenerCallQueue = [];
2136
-
2137
- /*
2138
- * To ignore the indentation of a node:
2139
- * 1. Don't call the node's listener when entering it (if it has a listener)
2140
- * 2. Don't set any offsets against the first token of the node.
2141
- * 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets.
2142
- */
2143
- const offsetListeners = {};
2144
-
2145
- for (const [selector, listener] of Object.entries(
2146
- baseOffsetListeners,
2147
- )) {
2148
- /*
2149
- * Offset listener calls are deferred until traversal is finished, and are called as
2150
- * part of the final `Program:exit` listener. This is necessary because a node might
2151
- * be matched by multiple selectors.
2152
- *
2153
- * Example: Suppose there is an offset listener for `Identifier`, and the user has
2154
- * specified in configuration that `MemberExpression > Identifier` should be ignored.
2155
- * Due to selector specificity rules, the `Identifier` listener will get called first. However,
2156
- * if a given Identifier node is supposed to be ignored, then the `Identifier` offset listener
2157
- * should not have been called at all. Without doing extra selector matching, we don't know
2158
- * whether the Identifier matches the `MemberExpression > Identifier` selector until the
2159
- * `MemberExpression > Identifier` listener is called.
2160
- *
2161
- * To avoid this, the `Identifier` listener isn't called until traversal finishes and all
2162
- * ignored nodes are known.
2163
- */
2164
- offsetListeners[selector] = node =>
2165
- listenerCallQueue.push({ listener, node });
2166
- }
2167
-
2168
- // For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set.
2169
- const ignoredNodes = new Set();
2170
-
2171
- /**
2172
- * Ignores a node
2173
- * @param {ASTNode} node The node to ignore
2174
- * @returns {void}
2175
- */
2176
- function addToIgnoredNodes(node) {
2177
- ignoredNodes.add(node);
2178
- ignoredNodeFirstTokens.add(sourceCode.getFirstToken(node));
2179
- }
2180
-
2181
- const ignoredNodeListeners = options.ignoredNodes.reduce(
2182
- (listeners, ignoredSelector) =>
2183
- Object.assign(listeners, {
2184
- [ignoredSelector]: addToIgnoredNodes,
2185
- }),
2186
- {},
2187
- );
2188
-
2189
- /*
2190
- * Join the listeners, and add a listener to verify that all tokens actually have the correct indentation
2191
- * at the end.
2192
- *
2193
- * Using Object.assign will cause some offset listeners to be overwritten if the same selector also appears
2194
- * in `ignoredNodeListeners`. This isn't a problem because all of the matching nodes will be ignored,
2195
- * so those listeners wouldn't be called anyway.
2196
- */
2197
- return Object.assign(offsetListeners, ignoredNodeListeners, {
2198
- "*:exit"(node) {
2199
- // If a node's type is nonstandard, we can't tell how its children should be offset, so ignore it.
2200
- if (!KNOWN_NODES.has(node.type)) {
2201
- addToIgnoredNodes(node);
2202
- }
2203
- },
2204
- "Program:exit"() {
2205
- // If ignoreComments option is enabled, ignore all comment tokens.
2206
- if (options.ignoreComments) {
2207
- sourceCode
2208
- .getAllComments()
2209
- .forEach(comment => offsets.ignoreToken(comment));
2210
- }
2211
-
2212
- // Invoke the queued offset listeners for the nodes that aren't ignored.
2213
- for (let i = 0; i < listenerCallQueue.length; i++) {
2214
- const nodeInfo = listenerCallQueue[i];
2215
-
2216
- if (!ignoredNodes.has(nodeInfo.node)) {
2217
- nodeInfo.listener(nodeInfo.node);
2218
- }
2219
- }
2220
-
2221
- // Update the offsets for ignored nodes to prevent their child tokens from being reported.
2222
- ignoredNodes.forEach(ignoreNode);
2223
-
2224
- addParensIndent(sourceCode.ast.tokens);
2225
-
2226
- /*
2227
- * Create a Map from (tokenOrComment) => (precedingToken).
2228
- * This is necessary because sourceCode.getTokenBefore does not handle a comment as an argument correctly.
2229
- */
2230
- const precedingTokens = new WeakMap();
2231
-
2232
- for (let i = 0; i < sourceCode.ast.comments.length; i++) {
2233
- const comment = sourceCode.ast.comments[i];
2234
-
2235
- const tokenOrCommentBefore = sourceCode.getTokenBefore(
2236
- comment,
2237
- { includeComments: true },
2238
- );
2239
- const hasToken = precedingTokens.has(tokenOrCommentBefore)
2240
- ? precedingTokens.get(tokenOrCommentBefore)
2241
- : tokenOrCommentBefore;
2242
-
2243
- precedingTokens.set(comment, hasToken);
2244
- }
2245
-
2246
- for (let i = 1; i < sourceCode.lines.length + 1; i++) {
2247
- if (!tokenInfo.firstTokensByLineNumber.has(i)) {
2248
- // Don't check indentation on blank lines
2249
- continue;
2250
- }
2251
-
2252
- const firstTokenOfLine =
2253
- tokenInfo.firstTokensByLineNumber.get(i);
2254
-
2255
- if (firstTokenOfLine.loc.start.line !== i) {
2256
- // Don't check the indentation of multi-line tokens (e.g. template literals or block comments) twice.
2257
- continue;
2258
- }
2259
-
2260
- if (astUtils.isCommentToken(firstTokenOfLine)) {
2261
- const tokenBefore =
2262
- precedingTokens.get(firstTokenOfLine);
2263
- const tokenAfter = tokenBefore
2264
- ? sourceCode.getTokenAfter(tokenBefore)
2265
- : sourceCode.ast.tokens[0];
2266
- const mayAlignWithBefore =
2267
- tokenBefore &&
2268
- !hasBlankLinesBetween(
2269
- tokenBefore,
2270
- firstTokenOfLine,
2271
- );
2272
- const mayAlignWithAfter =
2273
- tokenAfter &&
2274
- !hasBlankLinesBetween(firstTokenOfLine, tokenAfter);
2275
-
2276
- /*
2277
- * If a comment precedes a line that begins with a semicolon token, align to that token, i.e.
2278
- *
2279
- * let foo
2280
- * // comment
2281
- * ;(async () => {})()
2282
- */
2283
- if (
2284
- tokenAfter &&
2285
- astUtils.isSemicolonToken(tokenAfter) &&
2286
- !astUtils.isTokenOnSameLine(
2287
- firstTokenOfLine,
2288
- tokenAfter,
2289
- )
2290
- ) {
2291
- offsets.setDesiredOffset(
2292
- firstTokenOfLine,
2293
- tokenAfter,
2294
- 0,
2295
- );
2296
- }
2297
-
2298
- // If a comment matches the expected indentation of the token immediately before or after, don't report it.
2299
- if (
2300
- (mayAlignWithBefore &&
2301
- validateTokenIndent(
2302
- firstTokenOfLine,
2303
- offsets.getDesiredIndent(tokenBefore),
2304
- )) ||
2305
- (mayAlignWithAfter &&
2306
- validateTokenIndent(
2307
- firstTokenOfLine,
2308
- offsets.getDesiredIndent(tokenAfter),
2309
- ))
2310
- ) {
2311
- continue;
2312
- }
2313
- }
2314
-
2315
- // If the token matches the expected indentation, don't report it.
2316
- if (
2317
- validateTokenIndent(
2318
- firstTokenOfLine,
2319
- offsets.getDesiredIndent(firstTokenOfLine),
2320
- )
2321
- ) {
2322
- continue;
2323
- }
2324
-
2325
- // Otherwise, report the token/comment.
2326
- report(
2327
- firstTokenOfLine,
2328
- offsets.getDesiredIndent(firstTokenOfLine),
2329
- );
2330
- }
2331
- },
2332
- });
2333
- },
2334
- };