@dhzh/eslint-plugin-better-tailwindcss 0.0.0-stage → 4.9.0-patch

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 (423) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +247 -2
  3. package/lib/api/defaults.d.ts +103 -0
  4. package/lib/api/defaults.d.ts.map +1 -0
  5. package/lib/api/defaults.js +34 -0
  6. package/lib/api/defaults.js.map +1 -0
  7. package/lib/api/types.d.ts +9 -0
  8. package/lib/api/types.d.ts.map +1 -0
  9. package/lib/api/types.js +5 -0
  10. package/lib/api/types.js.map +1 -0
  11. package/lib/async-utils/cache.d.ts +30 -0
  12. package/lib/async-utils/cache.d.ts.map +1 -0
  13. package/lib/async-utils/cache.js +116 -0
  14. package/lib/async-utils/cache.js.map +1 -0
  15. package/lib/async-utils/escape.d.ts +2 -0
  16. package/lib/async-utils/escape.d.ts.map +1 -0
  17. package/lib/async-utils/escape.js +5 -0
  18. package/lib/async-utils/escape.js.map +1 -0
  19. package/lib/async-utils/fs.d.ts +3 -0
  20. package/lib/async-utils/fs.d.ts.map +1 -0
  21. package/lib/async-utils/fs.js +28 -0
  22. package/lib/async-utils/fs.js.map +1 -0
  23. package/lib/async-utils/module.d.ts +3 -0
  24. package/lib/async-utils/module.d.ts.map +1 -0
  25. package/lib/async-utils/module.js +7 -0
  26. package/lib/async-utils/module.js.map +1 -0
  27. package/lib/async-utils/operations.d.ts +23 -0
  28. package/lib/async-utils/operations.d.ts.map +1 -0
  29. package/lib/async-utils/operations.js +2 -0
  30. package/lib/async-utils/operations.js.map +1 -0
  31. package/lib/async-utils/order.d.ts +4 -0
  32. package/lib/async-utils/order.d.ts.map +1 -0
  33. package/lib/async-utils/order.js +5 -0
  34. package/lib/async-utils/order.js.map +1 -0
  35. package/lib/async-utils/path.d.ts +2 -0
  36. package/lib/async-utils/path.d.ts.map +1 -0
  37. package/lib/async-utils/path.js +7 -0
  38. package/lib/async-utils/path.js.map +1 -0
  39. package/lib/async-utils/platform.d.ts +2 -0
  40. package/lib/async-utils/platform.d.ts.map +1 -0
  41. package/lib/async-utils/platform.js +4 -0
  42. package/lib/async-utils/platform.js.map +1 -0
  43. package/lib/async-utils/regex.d.ts +3 -0
  44. package/lib/async-utils/regex.d.ts.map +1 -0
  45. package/lib/async-utils/regex.js +32 -0
  46. package/lib/async-utils/regex.js.map +1 -0
  47. package/lib/async-utils/resolvers.d.ts +7 -0
  48. package/lib/async-utils/resolvers.d.ts.map +1 -0
  49. package/lib/async-utils/resolvers.js +64 -0
  50. package/lib/async-utils/resolvers.js.map +1 -0
  51. package/lib/async-utils/segment.d.ts +2 -0
  52. package/lib/async-utils/segment.d.ts.map +1 -0
  53. package/lib/async-utils/segment.js +82 -0
  54. package/lib/async-utils/segment.js.map +1 -0
  55. package/lib/async-utils/worker.d.ts +3 -0
  56. package/lib/async-utils/worker.d.ts.map +1 -0
  57. package/lib/async-utils/worker.js +17 -0
  58. package/lib/async-utils/worker.js.map +1 -0
  59. package/lib/configs/config.d.ts +3521 -0
  60. package/lib/configs/config.d.ts.map +1 -0
  61. package/lib/configs/config.js +98 -0
  62. package/lib/configs/config.js.map +1 -0
  63. package/lib/options/callees/cc.d.ts +30 -0
  64. package/lib/options/callees/cc.d.ts.map +1 -0
  65. package/lib/options/callees/cc.js +25 -0
  66. package/lib/options/callees/cc.js.map +1 -0
  67. package/lib/options/callees/clb.d.ts +35 -0
  68. package/lib/options/callees/clb.d.ts.map +1 -0
  69. package/lib/options/callees/clb.js +39 -0
  70. package/lib/options/callees/clb.js.map +1 -0
  71. package/lib/options/callees/clsx.d.ts +30 -0
  72. package/lib/options/callees/clsx.d.ts.map +1 -0
  73. package/lib/options/callees/clsx.js +25 -0
  74. package/lib/options/callees/clsx.js.map +1 -0
  75. package/lib/options/callees/cn.d.ts +30 -0
  76. package/lib/options/callees/cn.d.ts.map +1 -0
  77. package/lib/options/callees/cn.js +25 -0
  78. package/lib/options/callees/cn.js.map +1 -0
  79. package/lib/options/callees/cnb.d.ts +30 -0
  80. package/lib/options/callees/cnb.d.ts.map +1 -0
  81. package/lib/options/callees/cnb.js +25 -0
  82. package/lib/options/callees/cnb.js.map +1 -0
  83. package/lib/options/callees/ctl.d.ts +17 -0
  84. package/lib/options/callees/ctl.d.ts.map +1 -0
  85. package/lib/options/callees/ctl.js +15 -0
  86. package/lib/options/callees/ctl.js.map +1 -0
  87. package/lib/options/callees/cva.d.ts +40 -0
  88. package/lib/options/callees/cva.d.ts.map +1 -0
  89. package/lib/options/callees/cva.js +37 -0
  90. package/lib/options/callees/cva.js.map +1 -0
  91. package/lib/options/callees/cx.d.ts +30 -0
  92. package/lib/options/callees/cx.d.ts.map +1 -0
  93. package/lib/options/callees/cx.js +25 -0
  94. package/lib/options/callees/cx.js.map +1 -0
  95. package/lib/options/callees/dcnb.d.ts +30 -0
  96. package/lib/options/callees/dcnb.d.ts.map +1 -0
  97. package/lib/options/callees/dcnb.js +25 -0
  98. package/lib/options/callees/dcnb.js.map +1 -0
  99. package/lib/options/callees/objstr.d.ts +24 -0
  100. package/lib/options/callees/objstr.d.ts.map +1 -0
  101. package/lib/options/callees/objstr.js +24 -0
  102. package/lib/options/callees/objstr.js.map +1 -0
  103. package/lib/options/callees/tv.d.ts +64 -0
  104. package/lib/options/callees/tv.d.ts.map +1 -0
  105. package/lib/options/callees/tv.js +70 -0
  106. package/lib/options/callees/tv.js.map +1 -0
  107. package/lib/options/callees/twJoin.d.ts +17 -0
  108. package/lib/options/callees/twJoin.d.ts.map +1 -0
  109. package/lib/options/callees/twJoin.js +15 -0
  110. package/lib/options/callees/twJoin.js.map +1 -0
  111. package/lib/options/callees/twMerge.d.ts +17 -0
  112. package/lib/options/callees/twMerge.d.ts.map +1 -0
  113. package/lib/options/callees/twMerge.js +15 -0
  114. package/lib/options/callees/twMerge.js.map +1 -0
  115. package/lib/options/default-options.d.ts +114 -0
  116. package/lib/options/default-options.d.ts.map +1 -0
  117. package/lib/options/default-options.js +176 -0
  118. package/lib/options/default-options.js.map +1 -0
  119. package/lib/options/descriptions.d.ts +657 -0
  120. package/lib/options/descriptions.d.ts.map +1 -0
  121. package/lib/options/descriptions.js +22 -0
  122. package/lib/options/descriptions.js.map +1 -0
  123. package/lib/options/migrate.d.ts +16 -0
  124. package/lib/options/migrate.d.ts.map +1 -0
  125. package/lib/options/migrate.js +132 -0
  126. package/lib/options/migrate.js.map +1 -0
  127. package/lib/options/schemas/attributes.d.ts +100 -0
  128. package/lib/options/schemas/attributes.d.ts.map +1 -0
  129. package/lib/options/schemas/attributes.js +19 -0
  130. package/lib/options/schemas/attributes.js.map +1 -0
  131. package/lib/options/schemas/callees.d.ts +101 -0
  132. package/lib/options/schemas/callees.d.ts.map +1 -0
  133. package/lib/options/schemas/callees.js +19 -0
  134. package/lib/options/schemas/callees.js.map +1 -0
  135. package/lib/options/schemas/common.d.ts +30 -0
  136. package/lib/options/schemas/common.d.ts.map +1 -0
  137. package/lib/options/schemas/common.js +30 -0
  138. package/lib/options/schemas/common.js.map +1 -0
  139. package/lib/options/schemas/matchers.d.ts +13 -0
  140. package/lib/options/schemas/matchers.d.ts.map +1 -0
  141. package/lib/options/schemas/matchers.js +14 -0
  142. package/lib/options/schemas/matchers.js.map +1 -0
  143. package/lib/options/schemas/selectors.d.ts +1289 -0
  144. package/lib/options/schemas/selectors.d.ts.map +1 -0
  145. package/lib/options/schemas/selectors.js +100 -0
  146. package/lib/options/schemas/selectors.js.map +1 -0
  147. package/lib/options/schemas/tags.d.ts +101 -0
  148. package/lib/options/schemas/tags.d.ts.map +1 -0
  149. package/lib/options/schemas/tags.js +19 -0
  150. package/lib/options/schemas/tags.js.map +1 -0
  151. package/lib/options/schemas/variables.d.ts +100 -0
  152. package/lib/options/schemas/variables.d.ts.map +1 -0
  153. package/lib/options/schemas/variables.js +19 -0
  154. package/lib/options/schemas/variables.js.map +1 -0
  155. package/lib/options/tags/twc.d.ts +36 -0
  156. package/lib/options/tags/twc.d.ts.map +1 -0
  157. package/lib/options/tags/twc.js +26 -0
  158. package/lib/options/tags/twc.js.map +1 -0
  159. package/lib/options/tags/twx.d.ts +36 -0
  160. package/lib/options/tags/twx.d.ts.map +1 -0
  161. package/lib/options/tags/twx.js +26 -0
  162. package/lib/options/tags/twx.js.map +1 -0
  163. package/lib/parsers/angular.d.ts +11 -0
  164. package/lib/parsers/angular.d.ts.map +1 -0
  165. package/lib/parsers/angular.js +736 -0
  166. package/lib/parsers/angular.js.map +1 -0
  167. package/lib/parsers/css.d.ts +5 -0
  168. package/lib/parsers/css.d.ts.map +1 -0
  169. package/lib/parsers/css.js +100 -0
  170. package/lib/parsers/css.js.map +1 -0
  171. package/lib/parsers/es.d.ts +49 -0
  172. package/lib/parsers/es.d.ts.map +1 -0
  173. package/lib/parsers/es.js +924 -0
  174. package/lib/parsers/es.js.map +1 -0
  175. package/lib/parsers/html.d.ts +8 -0
  176. package/lib/parsers/html.d.ts.map +1 -0
  177. package/lib/parsers/html.js +51 -0
  178. package/lib/parsers/html.js.map +1 -0
  179. package/lib/parsers/jsx.d.ts +9 -0
  180. package/lib/parsers/jsx.d.ts.map +1 -0
  181. package/lib/parsers/jsx.js +118 -0
  182. package/lib/parsers/jsx.js.map +1 -0
  183. package/lib/parsers/svelte.d.ts +11 -0
  184. package/lib/parsers/svelte.d.ts.map +1 -0
  185. package/lib/parsers/svelte.js +204 -0
  186. package/lib/parsers/svelte.js.map +1 -0
  187. package/lib/parsers/vue.d.ts +9 -0
  188. package/lib/parsers/vue.d.ts.map +1 -0
  189. package/lib/parsers/vue.js +155 -0
  190. package/lib/parsers/vue.js.map +1 -0
  191. package/lib/rules/enforce-canonical-classes.d.ts +229 -0
  192. package/lib/rules/enforce-canonical-classes.d.ts.map +1 -0
  193. package/lib/rules/enforce-canonical-classes.js +84 -0
  194. package/lib/rules/enforce-canonical-classes.js.map +1 -0
  195. package/lib/rules/enforce-consistent-class-order.d.ts +229 -0
  196. package/lib/rules/enforce-consistent-class-order.d.ts.map +1 -0
  197. package/lib/rules/enforce-consistent-class-order.js +250 -0
  198. package/lib/rules/enforce-consistent-class-order.js.map +1 -0
  199. package/lib/rules/enforce-consistent-important-position.d.ts +225 -0
  200. package/lib/rules/enforce-consistent-important-position.d.ts.map +1 -0
  201. package/lib/rules/enforce-consistent-important-position.js +68 -0
  202. package/lib/rules/enforce-consistent-important-position.js.map +1 -0
  203. package/lib/rules/enforce-consistent-line-wrapping.d.ts +235 -0
  204. package/lib/rules/enforce-consistent-line-wrapping.d.ts.map +1 -0
  205. package/lib/rules/enforce-consistent-line-wrapping.js +537 -0
  206. package/lib/rules/enforce-consistent-line-wrapping.js.map +1 -0
  207. package/lib/rules/enforce-consistent-variable-syntax.d.ts +225 -0
  208. package/lib/rules/enforce-consistent-variable-syntax.d.ts.map +1 -0
  209. package/lib/rules/enforce-consistent-variable-syntax.js +164 -0
  210. package/lib/rules/enforce-consistent-variable-syntax.js.map +1 -0
  211. package/lib/rules/enforce-consistent-variant-order.d.ts +225 -0
  212. package/lib/rules/enforce-consistent-variant-order.d.ts.map +1 -0
  213. package/lib/rules/enforce-consistent-variant-order.js +77 -0
  214. package/lib/rules/enforce-consistent-variant-order.js.map +1 -0
  215. package/lib/rules/enforce-logical-properties.d.ts +227 -0
  216. package/lib/rules/enforce-logical-properties.d.ts.map +1 -0
  217. package/lib/rules/enforce-logical-properties.js +142 -0
  218. package/lib/rules/enforce-logical-properties.js.map +1 -0
  219. package/lib/rules/enforce-shorthand-classes.d.ts +229 -0
  220. package/lib/rules/enforce-shorthand-classes.d.ts.map +1 -0
  221. package/lib/rules/enforce-shorthand-classes.js +217 -0
  222. package/lib/rules/enforce-shorthand-classes.js.map +1 -0
  223. package/lib/rules/no-concatenated-classes.d.ts +225 -0
  224. package/lib/rules/no-concatenated-classes.d.ts.map +1 -0
  225. package/lib/rules/no-concatenated-classes.js +31 -0
  226. package/lib/rules/no-concatenated-classes.js.map +1 -0
  227. package/lib/rules/no-conflicting-classes.d.ts +225 -0
  228. package/lib/rules/no-conflicting-classes.d.ts.map +1 -0
  229. package/lib/rules/no-conflicting-classes.js +60 -0
  230. package/lib/rules/no-conflicting-classes.js.map +1 -0
  231. package/lib/rules/no-deprecated-classes.d.ts +227 -0
  232. package/lib/rules/no-deprecated-classes.d.ts.map +1 -0
  233. package/lib/rules/no-deprecated-classes.js +103 -0
  234. package/lib/rules/no-deprecated-classes.js.map +1 -0
  235. package/lib/rules/no-duplicate-classes.d.ts +225 -0
  236. package/lib/rules/no-duplicate-classes.d.ts.map +1 -0
  237. package/lib/rules/no-duplicate-classes.js +52 -0
  238. package/lib/rules/no-duplicate-classes.js.map +1 -0
  239. package/lib/rules/no-restricted-classes.d.ts +225 -0
  240. package/lib/rules/no-restricted-classes.d.ts.map +1 -0
  241. package/lib/rules/no-restricted-classes.js +57 -0
  242. package/lib/rules/no-restricted-classes.js.map +1 -0
  243. package/lib/rules/no-unknown-classes.d.ts +225 -0
  244. package/lib/rules/no-unknown-classes.d.ts.map +1 -0
  245. package/lib/rules/no-unknown-classes.js +82 -0
  246. package/lib/rules/no-unknown-classes.js.map +1 -0
  247. package/lib/rules/no-unnecessary-whitespace.d.ts +225 -0
  248. package/lib/rules/no-unnecessary-whitespace.d.ts.map +1 -0
  249. package/lib/rules/no-unnecessary-whitespace.js +141 -0
  250. package/lib/rules/no-unnecessary-whitespace.js.map +1 -0
  251. package/lib/tailwindcss/canonical-classes.async.v4.d.ts +3 -0
  252. package/lib/tailwindcss/canonical-classes.async.v4.d.ts.map +1 -0
  253. package/lib/tailwindcss/canonical-classes.async.v4.js +54 -0
  254. package/lib/tailwindcss/canonical-classes.async.v4.js.map +1 -0
  255. package/lib/tailwindcss/canonical-classes.d.ts +21 -0
  256. package/lib/tailwindcss/canonical-classes.d.ts.map +1 -0
  257. package/lib/tailwindcss/canonical-classes.js +16 -0
  258. package/lib/tailwindcss/canonical-classes.js.map +1 -0
  259. package/lib/tailwindcss/class-order.async.v3.d.ts +3 -0
  260. package/lib/tailwindcss/class-order.async.v3.d.ts.map +1 -0
  261. package/lib/tailwindcss/class-order.async.v3.js +4 -0
  262. package/lib/tailwindcss/class-order.async.v3.js.map +1 -0
  263. package/lib/tailwindcss/class-order.async.v4.d.ts +3 -0
  264. package/lib/tailwindcss/class-order.async.v4.d.ts.map +1 -0
  265. package/lib/tailwindcss/class-order.async.v4.js +4 -0
  266. package/lib/tailwindcss/class-order.async.v4.js.map +1 -0
  267. package/lib/tailwindcss/class-order.d.ts +11 -0
  268. package/lib/tailwindcss/class-order.d.ts.map +1 -0
  269. package/lib/tailwindcss/class-order.js +16 -0
  270. package/lib/tailwindcss/class-order.js.map +1 -0
  271. package/lib/tailwindcss/conflicting-classes.async.v4.d.ts +35 -0
  272. package/lib/tailwindcss/conflicting-classes.async.v4.d.ts.map +1 -0
  273. package/lib/tailwindcss/conflicting-classes.async.v4.js +82 -0
  274. package/lib/tailwindcss/conflicting-classes.async.v4.js.map +1 -0
  275. package/lib/tailwindcss/conflicting-classes.d.ts +19 -0
  276. package/lib/tailwindcss/conflicting-classes.d.ts.map +1 -0
  277. package/lib/tailwindcss/conflicting-classes.js +17 -0
  278. package/lib/tailwindcss/conflicting-classes.js.map +1 -0
  279. package/lib/tailwindcss/context.async.v3.d.ts +3 -0
  280. package/lib/tailwindcss/context.async.v3.d.ts.map +1 -0
  281. package/lib/tailwindcss/context.async.v3.js +13 -0
  282. package/lib/tailwindcss/context.async.v3.js.map +1 -0
  283. package/lib/tailwindcss/context.async.v4.d.ts +3 -0
  284. package/lib/tailwindcss/context.async.v4.d.ts.map +1 -0
  285. package/lib/tailwindcss/context.async.v4.js +82 -0
  286. package/lib/tailwindcss/context.async.v4.js.map +1 -0
  287. package/lib/tailwindcss/custom-component-classes.async.v3.d.ts +4 -0
  288. package/lib/tailwindcss/custom-component-classes.async.v3.d.ts.map +1 -0
  289. package/lib/tailwindcss/custom-component-classes.async.v3.js +4 -0
  290. package/lib/tailwindcss/custom-component-classes.async.v3.js.map +1 -0
  291. package/lib/tailwindcss/custom-component-classes.async.v4.d.ts +4 -0
  292. package/lib/tailwindcss/custom-component-classes.async.v4.d.ts.map +1 -0
  293. package/lib/tailwindcss/custom-component-classes.async.v4.js +101 -0
  294. package/lib/tailwindcss/custom-component-classes.async.v4.js.map +1 -0
  295. package/lib/tailwindcss/custom-component-classes.d.ts +11 -0
  296. package/lib/tailwindcss/custom-component-classes.d.ts.map +1 -0
  297. package/lib/tailwindcss/custom-component-classes.js +16 -0
  298. package/lib/tailwindcss/custom-component-classes.js.map +1 -0
  299. package/lib/tailwindcss/dissect-classes.async.v3.d.ts +4 -0
  300. package/lib/tailwindcss/dissect-classes.async.v3.d.ts.map +1 -0
  301. package/lib/tailwindcss/dissect-classes.async.v3.js +32 -0
  302. package/lib/tailwindcss/dissect-classes.async.v3.js.map +1 -0
  303. package/lib/tailwindcss/dissect-classes.async.v4.d.ts +3 -0
  304. package/lib/tailwindcss/dissect-classes.async.v4.d.ts.map +1 -0
  305. package/lib/tailwindcss/dissect-classes.async.v4.js +39 -0
  306. package/lib/tailwindcss/dissect-classes.async.v4.js.map +1 -0
  307. package/lib/tailwindcss/dissect-classes.d.ts +23 -0
  308. package/lib/tailwindcss/dissect-classes.d.ts.map +1 -0
  309. package/lib/tailwindcss/dissect-classes.js +16 -0
  310. package/lib/tailwindcss/dissect-classes.js.map +1 -0
  311. package/lib/tailwindcss/prefix.async.v3.d.ts +4 -0
  312. package/lib/tailwindcss/prefix.async.v3.d.ts.map +1 -0
  313. package/lib/tailwindcss/prefix.async.v3.js +7 -0
  314. package/lib/tailwindcss/prefix.async.v3.js.map +1 -0
  315. package/lib/tailwindcss/prefix.async.v4.d.ts +4 -0
  316. package/lib/tailwindcss/prefix.async.v4.d.ts.map +1 -0
  317. package/lib/tailwindcss/prefix.async.v4.js +7 -0
  318. package/lib/tailwindcss/prefix.async.v4.js.map +1 -0
  319. package/lib/tailwindcss/prefix.d.ts +13 -0
  320. package/lib/tailwindcss/prefix.d.ts.map +1 -0
  321. package/lib/tailwindcss/prefix.js +15 -0
  322. package/lib/tailwindcss/prefix.js.map +1 -0
  323. package/lib/tailwindcss/tailwind.async.worker.v3.d.ts +2 -0
  324. package/lib/tailwindcss/tailwind.async.worker.v3.d.ts.map +1 -0
  325. package/lib/tailwindcss/tailwind.async.worker.v3.js +57 -0
  326. package/lib/tailwindcss/tailwind.async.worker.v3.js.map +1 -0
  327. package/lib/tailwindcss/tailwind.async.worker.v4.d.ts +2 -0
  328. package/lib/tailwindcss/tailwind.async.worker.v4.d.ts.map +1 -0
  329. package/lib/tailwindcss/tailwind.async.worker.v4.js +56 -0
  330. package/lib/tailwindcss/tailwind.async.worker.v4.js.map +1 -0
  331. package/lib/tailwindcss/unknown-classes.async.v3.d.ts +4 -0
  332. package/lib/tailwindcss/unknown-classes.async.v3.d.ts.map +1 -0
  333. package/lib/tailwindcss/unknown-classes.async.v3.js +10 -0
  334. package/lib/tailwindcss/unknown-classes.async.v3.js.map +1 -0
  335. package/lib/tailwindcss/unknown-classes.async.v4.d.ts +3 -0
  336. package/lib/tailwindcss/unknown-classes.async.v4.d.ts.map +1 -0
  337. package/lib/tailwindcss/unknown-classes.async.v4.js +5 -0
  338. package/lib/tailwindcss/unknown-classes.async.v4.js.map +1 -0
  339. package/lib/tailwindcss/unknown-classes.d.ts +11 -0
  340. package/lib/tailwindcss/unknown-classes.d.ts.map +1 -0
  341. package/lib/tailwindcss/unknown-classes.js +21 -0
  342. package/lib/tailwindcss/unknown-classes.js.map +1 -0
  343. package/lib/tailwindcss/variant-order.async.v3.d.ts +3 -0
  344. package/lib/tailwindcss/variant-order.async.v3.d.ts.map +1 -0
  345. package/lib/tailwindcss/variant-order.async.v3.js +4 -0
  346. package/lib/tailwindcss/variant-order.async.v3.js.map +1 -0
  347. package/lib/tailwindcss/variant-order.async.v4.d.ts +3 -0
  348. package/lib/tailwindcss/variant-order.async.v4.d.ts.map +1 -0
  349. package/lib/tailwindcss/variant-order.async.v4.js +34 -0
  350. package/lib/tailwindcss/variant-order.async.v4.js.map +1 -0
  351. package/lib/tailwindcss/variant-order.d.ts +11 -0
  352. package/lib/tailwindcss/variant-order.d.ts.map +1 -0
  353. package/lib/tailwindcss/variant-order.js +16 -0
  354. package/lib/tailwindcss/variant-order.js.map +1 -0
  355. package/lib/types/ast.d.ts +79 -0
  356. package/lib/types/ast.d.ts.map +1 -0
  357. package/lib/types/ast.js +2 -0
  358. package/lib/types/ast.js.map +1 -0
  359. package/lib/types/async.d.ts +7 -0
  360. package/lib/types/async.d.ts.map +1 -0
  361. package/lib/types/async.js +2 -0
  362. package/lib/types/async.js.map +1 -0
  363. package/lib/types/estree.d.ts +7 -0
  364. package/lib/types/estree.d.ts.map +1 -0
  365. package/lib/types/estree.js +2 -0
  366. package/lib/types/estree.js.map +1 -0
  367. package/lib/types/rule.d.ts +163 -0
  368. package/lib/types/rule.d.ts.map +1 -0
  369. package/lib/types/rule.js +24 -0
  370. package/lib/types/rule.js.map +1 -0
  371. package/lib/utils/ast.d.ts +4 -0
  372. package/lib/utils/ast.d.ts.map +1 -0
  373. package/lib/utils/ast.js +9 -0
  374. package/lib/utils/ast.js.map +1 -0
  375. package/lib/utils/class.d.ts +12 -0
  376. package/lib/utils/class.d.ts.map +1 -0
  377. package/lib/utils/class.js +19 -0
  378. package/lib/utils/class.js.map +1 -0
  379. package/lib/utils/context.d.ts +20 -0
  380. package/lib/utils/context.d.ts.map +1 -0
  381. package/lib/utils/context.js +91 -0
  382. package/lib/utils/context.js.map +1 -0
  383. package/lib/utils/lint.d.ts +17 -0
  384. package/lib/utils/lint.d.ts.map +1 -0
  385. package/lib/utils/lint.js +40 -0
  386. package/lib/utils/lint.js.map +1 -0
  387. package/lib/utils/matchers.d.ts +24 -0
  388. package/lib/utils/matchers.d.ts.map +1 -0
  389. package/lib/utils/matchers.js +154 -0
  390. package/lib/utils/matchers.js.map +1 -0
  391. package/lib/utils/quotes.d.ts +3 -0
  392. package/lib/utils/quotes.d.ts.map +1 -0
  393. package/lib/utils/quotes.js +9 -0
  394. package/lib/utils/quotes.js.map +1 -0
  395. package/lib/utils/rule.d.ts +31 -0
  396. package/lib/utils/rule.d.ts.map +1 -0
  397. package/lib/utils/rule.js +349 -0
  398. package/lib/utils/rule.js.map +1 -0
  399. package/lib/utils/selectors.d.ts +3 -0
  400. package/lib/utils/selectors.d.ts.map +1 -0
  401. package/lib/utils/selectors.js +4 -0
  402. package/lib/utils/selectors.js.map +1 -0
  403. package/lib/utils/utils.d.ts +49 -0
  404. package/lib/utils/utils.d.ts.map +1 -0
  405. package/lib/utils/utils.js +203 -0
  406. package/lib/utils/utils.js.map +1 -0
  407. package/lib/utils/valibot.d.ts +4 -0
  408. package/lib/utils/valibot.d.ts.map +1 -0
  409. package/lib/utils/valibot.js +12 -0
  410. package/lib/utils/valibot.js.map +1 -0
  411. package/lib/utils/version.d.ts +7 -0
  412. package/lib/utils/version.d.ts.map +1 -0
  413. package/lib/utils/version.js +6 -0
  414. package/lib/utils/version.js.map +1 -0
  415. package/lib/utils/visitedNodes.d.ts +4 -0
  416. package/lib/utils/visitedNodes.d.ts.map +1 -0
  417. package/lib/utils/visitedNodes.js +11 -0
  418. package/lib/utils/visitedNodes.js.map +1 -0
  419. package/lib/utils/warn.d.ts +2 -0
  420. package/lib/utils/warn.d.ts.map +1 -0
  421. package/lib/utils/warn.js +8 -0
  422. package/lib/utils/warn.js.map +1 -0
  423. package/package.json +163 -4
@@ -0,0 +1,736 @@
1
+ import { MATCHER_RESULT, MatcherType } from "../types/rule.js";
2
+ import { getLocByRange } from "../utils/ast.js";
3
+ import { getLiteralNodesByMatchers, matchesPathPattern } from "../utils/matchers.js";
4
+ import { addAttribute, createObjectPathElement, deduplicateLiterals, getIndentation, getQuotes, getWhitespace, matchesName } from "../utils/utils.js";
5
+ import { createVisitedNodes, visitNode } from "../utils/visitedNodes.js";
6
+ // https://angular.dev/api/common/NgClass
7
+ // https://angular.dev/guide/templates/binding#css-class-and-style-property-bindings
8
+ export function getAttributesByAngularElement(ctx, node) {
9
+ return [
10
+ ...node.attributes,
11
+ ...node.inputs
12
+ ];
13
+ }
14
+ export function getLiteralsByAngularAttribute(ctx, attribute, selectors) {
15
+ const name = getAttributeName(attribute);
16
+ const literals = selectors.reduce((literals, selector) => {
17
+ if (!matchesName(selector.name.toLowerCase(), name.toLowerCase())) {
18
+ return literals;
19
+ }
20
+ if (!selector.match) {
21
+ literals.push(...createLiteralsByAngularAttribute(ctx, attribute));
22
+ return literals;
23
+ }
24
+ if (isTextAttribute(attribute) && selector.match.some(matcher => matcher.type === MatcherType.String)) {
25
+ literals.push(...createLiteralsByAngularTextAttribute(ctx, attribute));
26
+ }
27
+ if (isBoundAttribute(attribute)) {
28
+ if (isBoundAttributeName(attribute)) {
29
+ literals.push(...getLiteralsByAngularMatchers(ctx, attribute, selector.match));
30
+ }
31
+ else if (isASTWithSource(attribute.value)) {
32
+ literals.push(...getLiteralsByAngularMatchers(ctx, attribute.value.ast, selector.match));
33
+ }
34
+ }
35
+ return literals;
36
+ }, []);
37
+ return literals
38
+ .filter(deduplicateLiterals)
39
+ .map(addAttribute(name));
40
+ }
41
+ function createLiteralsByAngularAst(ctx, ast) {
42
+ if (isInterpolation(ast)) {
43
+ return ast.expressions.flatMap(expression => {
44
+ return createLiteralsByAngularAst(ctx, expression);
45
+ });
46
+ }
47
+ if (isLiteralArray(ast)) {
48
+ return ast.expressions.flatMap(expression => {
49
+ return createLiteralsByAngularAst(ctx, expression);
50
+ });
51
+ }
52
+ if (isObjectKey(ast)) {
53
+ return createLiteralByLiteralMapKey(ctx, ast);
54
+ }
55
+ if (isConditional(ast)) {
56
+ return createLiteralsByAngularConditional(ctx, ast);
57
+ }
58
+ if (isLiteralPrimitive(ast)) {
59
+ return createLiteralByAngularLiteralPrimitive(ctx, ast);
60
+ }
61
+ if (isTemplateLiteralElement(ast)) {
62
+ return createLiteralByAngularTemplateLiteralElement(ctx, ast);
63
+ }
64
+ if (isBoundAttribute(ast) && isBoundAttributeName(ast)) {
65
+ return createLiteralsByAngularBoundAttributeName(ctx, ast);
66
+ }
67
+ return [];
68
+ }
69
+ function createLiteralsByAngularConditional(ctx, conditional) {
70
+ const literals = [];
71
+ literals.push(...createLiteralsByAngularAst(ctx, conditional.trueExp));
72
+ literals.push(...createLiteralsByAngularAst(ctx, conditional.falseExp));
73
+ return literals;
74
+ }
75
+ function createLiteralsByAngularAttribute(ctx, attribute) {
76
+ if (isTextAttribute(attribute)) {
77
+ return createLiteralsByAngularTextAttribute(ctx, attribute);
78
+ }
79
+ if (isBoundAttribute(attribute) && isASTWithSource(attribute.value) && isLiteralPrimitive(attribute.value.ast)) {
80
+ return createLiteralsByAngularAst(ctx, attribute.value.ast);
81
+ }
82
+ return [];
83
+ }
84
+ function getLiteralsByAngularMatchers(ctx, ast, matchers) {
85
+ const matcherFunctions = getAngularMatcherFunctions(ctx, matchers);
86
+ const matchingAstNodes = getLiteralNodesByMatchers(ctx, ast, matcherFunctions);
87
+ const literals = matchingAstNodes.flatMap(ast => createLiteralsByAngularAst(ctx, ast));
88
+ return literals.filter(deduplicateLiterals);
89
+ }
90
+ function getAngularMatcherFunctions(ctx, matchers) {
91
+ return matchers.reduce((matcherFunctions, matcher) => {
92
+ switch (matcher.type) {
93
+ case MatcherType.String: {
94
+ matcherFunctions.push(ast => {
95
+ if (isAST(ast) &&
96
+ isCallExpression(ast)) {
97
+ return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
98
+ }
99
+ if (!isAST(ast) ||
100
+ isInsideConditionalExpressionCondition(ctx, ast) ||
101
+ isInsideLogicalExpressionLeft(ctx, ast) ||
102
+ isObjectKey(ast) ||
103
+ isInsideObjectValue(ctx, ast)) {
104
+ return MATCHER_RESULT.NO_MATCH;
105
+ }
106
+ return isStringLike(ast) || isBoundAttributeName(ast);
107
+ });
108
+ break;
109
+ }
110
+ case MatcherType.ObjectKey: {
111
+ matcherFunctions.push(ast => {
112
+ if (isAST(ast) && (isCallExpression(ast) ||
113
+ isBoundAttributeName(ast))) {
114
+ return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
115
+ }
116
+ if (!isAST(ast) ||
117
+ !isObjectKey(ast) ||
118
+ isInsideConditionalExpressionCondition(ctx, ast) ||
119
+ isInsideLogicalExpressionLeft(ctx, ast)) {
120
+ return MATCHER_RESULT.NO_MATCH;
121
+ }
122
+ const path = getAngularObjectPath(ctx, ast);
123
+ if (!path || !matcher.path) {
124
+ return MATCHER_RESULT.MATCH;
125
+ }
126
+ return matchesPathPattern(path, matcher.path);
127
+ });
128
+ break;
129
+ }
130
+ case MatcherType.ObjectValue: {
131
+ matcherFunctions.push(ast => {
132
+ if (isAST(ast) && (isCallExpression(ast) ||
133
+ isBoundAttributeName(ast))) {
134
+ return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
135
+ }
136
+ if (!isAST(ast) ||
137
+ !hasParent(ast) ||
138
+ !isInsideObjectValue(ctx, ast) ||
139
+ isInsideConditionalExpressionCondition(ctx, ast) ||
140
+ isInsideLogicalExpressionLeft(ctx, ast) ||
141
+ isObjectKey(ast) ||
142
+ !isStringLike(ast)) {
143
+ return MATCHER_RESULT.NO_MATCH;
144
+ }
145
+ const path = getAngularObjectPath(ctx, ast);
146
+ if (!path || !matcher.path) {
147
+ return MATCHER_RESULT.MATCH;
148
+ }
149
+ return matchesPathPattern(path, matcher.path);
150
+ });
151
+ break;
152
+ }
153
+ }
154
+ return matcherFunctions;
155
+ }, []);
156
+ }
157
+ function getAngularObjectPath(ctx, ast) {
158
+ const parent = findParent(ctx, ast);
159
+ if (!parent) {
160
+ return;
161
+ }
162
+ const paths = [];
163
+ if (isObjectKey(ast)) {
164
+ paths.unshift(createObjectPathElement(ast.key));
165
+ }
166
+ if (isLiteralArray(parent)) {
167
+ const index = parent.expressions.indexOf(ast);
168
+ paths.unshift(`[${index}]`);
169
+ }
170
+ if (isLiteralMap(parent) && isInsideObjectValue(ctx, ast)) {
171
+ const keyIndex = parent.values.indexOf(ast);
172
+ const objectKey = parent.keys[keyIndex];
173
+ if (objectKey && isObjectKey(objectKey)) {
174
+ paths.unshift(createObjectPathElement(objectKey.key));
175
+ }
176
+ }
177
+ paths.unshift(getAngularObjectPath(ctx, parent));
178
+ return paths.reduce((paths, currentPath) => {
179
+ if (!currentPath) {
180
+ return paths;
181
+ }
182
+ if (paths.length === 0) {
183
+ return [currentPath];
184
+ }
185
+ if (currentPath.startsWith("[") && currentPath.endsWith("]")) {
186
+ return [...paths, currentPath];
187
+ }
188
+ return [...paths, ".", currentPath];
189
+ }, []).join("");
190
+ }
191
+ function createLiteralsByAngularBoundAttributeName(ctx, attribute) {
192
+ if (!attribute.keySpan) {
193
+ return [];
194
+ }
195
+ const content = attribute.name;
196
+ const startOffset = attribute.keySpan.toString()?.indexOf(content) ?? 0;
197
+ const start = attribute.keySpan.fullStart;
198
+ const end = attribute.keySpan.end;
199
+ const range = [start.offset + startOffset, end.offset];
200
+ const raw = attribute.sourceSpan.start.file.content.slice(...range);
201
+ const quotes = getQuotes(raw);
202
+ const whitespaces = getWhitespace(content);
203
+ const loc = convertParseSourceSpanToLoc(attribute.keySpan);
204
+ loc.start.column += startOffset;
205
+ loc.end.column = loc.start.column + content.length;
206
+ const line = ctx.sourceCode.lines[loc.start.line - 1];
207
+ const indentation = getIndentation(line);
208
+ const supportsMultiline = false;
209
+ const concatenation = {
210
+ isConcatenatedLeft: false,
211
+ isConcatenatedRight: false
212
+ };
213
+ return [{
214
+ ...quotes,
215
+ ...whitespaces,
216
+ ...concatenation,
217
+ content,
218
+ indentation,
219
+ loc,
220
+ range,
221
+ raw,
222
+ supportsMultiline,
223
+ type: "StringLiteral"
224
+ }];
225
+ }
226
+ function createLiteralByLiteralMapKey(ctx, key) {
227
+ // @ts-expect-error - angular types are faulty
228
+ const literalMap = key?.parent;
229
+ // @ts-expect-error - angular types are faulty
230
+ const objectContent = literalMap?.parent?.source;
231
+ const keyContent = key?.key;
232
+ const keyIndex = literalMap?.keys.indexOf(key);
233
+ if (keyIndex === undefined || keyIndex === -1) {
234
+ return [];
235
+ }
236
+ const previousValue = literalMap?.values[keyIndex - 1];
237
+ const value = literalMap?.values[keyIndex];
238
+ if (!literalMap?.sourceSpan || typeof objectContent !== "string" || typeof keyContent !== "string") {
239
+ return [];
240
+ }
241
+ const rangeStart = previousValue?.span?.end ?? 0;
242
+ const rangeEnd = value?.span?.start ?? objectContent.length;
243
+ const slice = objectContent.slice(rangeStart, rangeEnd);
244
+ const start = rangeStart + slice.indexOf(keyContent) - (key.quoted ? 1 : 0);
245
+ const end = start + keyContent.length + (key.quoted ? 1 : 0);
246
+ const raw = objectContent.slice(start, end);
247
+ const quotes = getQuotes(raw);
248
+ const whitespaces = getWhitespace(keyContent);
249
+ const range = [literalMap.sourceSpan.start + start, literalMap.sourceSpan.start + end];
250
+ const loc = getLocByRange(ctx, range);
251
+ const line = ctx.sourceCode.lines[loc.start.line - 1] ?? "";
252
+ const indentation = getIndentation(line);
253
+ const concatenation = {
254
+ isConcatenatedLeft: false,
255
+ isConcatenatedRight: false
256
+ };
257
+ return [{
258
+ ...quotes,
259
+ ...whitespaces,
260
+ ...concatenation,
261
+ content: keyContent,
262
+ indentation,
263
+ loc,
264
+ range,
265
+ raw,
266
+ supportsMultiline: false,
267
+ type: "StringLiteral"
268
+ }];
269
+ }
270
+ function createLiteralsByAngularTextAttribute(ctx, attribute) {
271
+ const content = attribute.value;
272
+ if (!attribute.valueSpan) {
273
+ return [];
274
+ }
275
+ const start = attribute.valueSpan.fullStart;
276
+ const end = attribute.valueSpan.end;
277
+ const range = [start.offset - 1, end.offset + 1];
278
+ const raw = attribute.sourceSpan.start.file.content.slice(...range);
279
+ const quotes = getQuotes(raw);
280
+ const whitespaces = getWhitespace(content);
281
+ const loc = convertParseSourceSpanToLoc(attribute.valueSpan);
282
+ const line = ctx.sourceCode.lines[loc.start.line - 1];
283
+ const indentation = getIndentation(line);
284
+ const supportsMultiline = true;
285
+ const concatenation = {
286
+ isConcatenatedLeft: false,
287
+ isConcatenatedRight: false
288
+ };
289
+ return [{
290
+ ...quotes,
291
+ ...whitespaces,
292
+ ...concatenation,
293
+ content,
294
+ indentation,
295
+ loc,
296
+ range,
297
+ raw,
298
+ supportsMultiline,
299
+ type: "StringLiteral"
300
+ }];
301
+ }
302
+ function createLiteralByAngularLiteralPrimitive(ctx, literal) {
303
+ return createLiteralByAngularLiteralPrimitiveInternal(ctx, literal, createVisitedNodes());
304
+ }
305
+ function createLiteralByAngularLiteralPrimitiveInternal(ctx, literal, visitedNodes) {
306
+ const content = literal.value;
307
+ if (!literal.sourceSpan || typeof content !== "string") {
308
+ return [];
309
+ }
310
+ const start = literal.sourceSpan.start;
311
+ const end = literal.sourceSpan.end;
312
+ const range = [start, end];
313
+ const raw = ctx.sourceCode.text.slice(...range);
314
+ const quotes = getQuotes(raw);
315
+ const whitespaces = getWhitespace(content);
316
+ const loc = getLocByRange(ctx, range);
317
+ const line = ctx.sourceCode.lines[loc.start.line - 1];
318
+ const indentation = getIndentation(line);
319
+ const concatenation = getStringConcatenationMeta(ctx, literal, visitedNodes);
320
+ const supportsMultiline = true;
321
+ return [{
322
+ ...quotes,
323
+ ...whitespaces,
324
+ ...concatenation,
325
+ content,
326
+ indentation,
327
+ loc,
328
+ range,
329
+ raw,
330
+ supportsMultiline,
331
+ type: "StringLiteral"
332
+ }];
333
+ }
334
+ function createLiteralByAngularTemplateLiteralElement(ctx, literal) {
335
+ return createLiteralByAngularTemplateLiteralElementInternal(ctx, literal, createVisitedNodes());
336
+ }
337
+ function createLiteralByAngularTemplateLiteralElementInternal(ctx, literal, visitedNodes) {
338
+ const content = literal.text;
339
+ if (!literal.sourceSpan || !hasParent(literal)) {
340
+ return [];
341
+ }
342
+ const braces = getBraces(literal);
343
+ const isInterpolated = getIsInterpolated(literal);
344
+ const start = literal.sourceSpan.start - (braces.closingBraces?.length ?? 0);
345
+ const end = literal.sourceSpan.end + (braces.openingBraces?.length ?? 0);
346
+ const range = [start, end];
347
+ const raw = ctx.sourceCode.text.slice(...range);
348
+ const quotes = getQuotes(raw);
349
+ const whitespaces = getWhitespace(content);
350
+ const loc = getLocByRange(ctx, range);
351
+ const parent = literal.parent;
352
+ const parentStart = parent.sourceSpan?.start;
353
+ const parentEnd = parent.sourceSpan?.end;
354
+ const parentRange = [parentStart, parentEnd];
355
+ const parentLoc = getLocByRange(ctx, parentRange);
356
+ const parentLine = ctx.sourceCode.lines[parentLoc.start.line - 1];
357
+ const indentation = getIndentation(parentLine);
358
+ const supportsMultiline = true;
359
+ const concatenation = getStringConcatenationMeta(ctx, literal, visitedNodes);
360
+ return [{
361
+ ...quotes,
362
+ ...whitespaces,
363
+ ...braces,
364
+ ...concatenation,
365
+ content,
366
+ indentation,
367
+ isInterpolated,
368
+ loc,
369
+ range,
370
+ raw,
371
+ supportsMultiline,
372
+ type: "TemplateLiteral"
373
+ }];
374
+ }
375
+ function convertParseSourceSpanToLoc(sourceSpan) {
376
+ return {
377
+ end: {
378
+ column: sourceSpan.end.col,
379
+ line: sourceSpan.end.line + 1
380
+ },
381
+ start: {
382
+ column: sourceSpan.fullStart.col,
383
+ line: sourceSpan.fullStart.line + 1
384
+ }
385
+ };
386
+ }
387
+ function isInsideInlineTemplate(ctx) {
388
+ return getInlineTemplateComponentIndex(ctx) !== undefined;
389
+ }
390
+ function getInlineTemplateComponentIndex(ctx) {
391
+ const matches = ctx.filename.match(/^.*_inline-template-[\w.-]+-(\d+)\.component\.html$/);
392
+ if (matches) {
393
+ const [, index] = matches;
394
+ return +index;
395
+ }
396
+ }
397
+ function getBraces(literal) {
398
+ if (!hasParent(literal)) {
399
+ return {};
400
+ }
401
+ const parent = literal.parent;
402
+ const index = parent.elements.indexOf(literal);
403
+ if (parent.elements.length === 1) {
404
+ return {};
405
+ }
406
+ return {
407
+ closingBraces: index >= 1 ? "}" : undefined,
408
+ openingBraces: index < parent.elements.length - 1 ? "${" : undefined
409
+ };
410
+ }
411
+ function getIsInterpolated(literal) {
412
+ const braces = getBraces(literal);
413
+ return !!braces.closingBraces || !!braces.openingBraces;
414
+ }
415
+ function getAttributeName(node) {
416
+ if (!node.keySpan) {
417
+ return node.name;
418
+ }
419
+ return node.sourceSpan.start.offset !== node.keySpan.start.offset
420
+ ? node.sourceSpan.fullStart.file.content.slice(node.sourceSpan.start.offset, node.keySpan.end.offset + 1)
421
+ : node.keySpan.toString() ?? node.name;
422
+ }
423
+ function isInsideConditionalExpressionCondition(ctx, ast) {
424
+ const parent = findParent(ctx, ast);
425
+ if (!parent) {
426
+ return false;
427
+ }
428
+ if (isConditional(parent) && parent.condition === ast) {
429
+ return true;
430
+ }
431
+ return isInsideConditionalExpressionCondition(ctx, parent);
432
+ }
433
+ function isInsideLogicalExpressionLeft(ctx, ast) {
434
+ const parent = findParent(ctx, ast);
435
+ if (!parent) {
436
+ return false;
437
+ }
438
+ if (isBinary(parent) && parent.operation === "&&" && parent.left === ast) {
439
+ return true;
440
+ }
441
+ return isInsideConditionalExpressionCondition(ctx, parent);
442
+ }
443
+ function getStringConcatenationMeta(ctx, ast, visitedNodes) {
444
+ const { isConcatenatedLeft, isConcatenatedRight } = getStringConcatenationDirection(ctx, ast);
445
+ const visited = createVisitedNodes(visitedNodes);
446
+ visitNode(visited, ast);
447
+ const leftNodes = findAdjacentInterpolatedExpressionNodes(ctx, ast, "left") ??
448
+ findAdjacentTemplateQuasiNodes(ctx, ast, "left") ??
449
+ findAdjacentPlusConcatenatedLiteralNodes(ctx, ast, "left");
450
+ const leftLiterals = isConcatenatedLeft
451
+ ? buildConcatenationNeighborLiterals(ctx, leftNodes, visited)
452
+ : undefined;
453
+ const rightNodes = findAdjacentInterpolatedExpressionNodes(ctx, ast, "right") ??
454
+ findAdjacentTemplateQuasiNodes(ctx, ast, "right") ??
455
+ findAdjacentPlusConcatenatedLiteralNodes(ctx, ast, "right");
456
+ const rightLiterals = isConcatenatedRight
457
+ ? buildConcatenationNeighborLiterals(ctx, rightNodes, visited)
458
+ : undefined;
459
+ return { isConcatenatedLeft, isConcatenatedRight, leftLiterals, rightLiterals };
460
+ }
461
+ function buildConcatenationNeighborLiterals(ctx, nodes, visited) {
462
+ if (!nodes) {
463
+ return;
464
+ }
465
+ return nodes
466
+ .filter(adjacentNode => visitNode(visited, adjacentNode))
467
+ .map(adjacentNode => buildConcatenationNeighborLiteral(ctx, adjacentNode, visited))
468
+ .filter((literal) => literal !== undefined);
469
+ }
470
+ function getStringConcatenationDirection(ctx, ast, isConcatenatedLeft = false, isConcatenatedRight = false) {
471
+ const parent = findParent(ctx, ast);
472
+ if (!parent) {
473
+ return {
474
+ isConcatenatedLeft,
475
+ isConcatenatedRight
476
+ };
477
+ }
478
+ if (isCallExpression(parent)) {
479
+ return {
480
+ isConcatenatedLeft,
481
+ isConcatenatedRight
482
+ };
483
+ }
484
+ if (isTemplateLiteral(parent) && !isTemplateLiteralElement(ast)) {
485
+ return {
486
+ isConcatenatedLeft: true,
487
+ isConcatenatedRight: true
488
+ };
489
+ }
490
+ // a template element is concatenated with the interpolation adjacent to it (`}` before, `${` after)
491
+ if (isTemplateLiteralElement(ast) && isTemplateLiteral(parent)) {
492
+ const index = parent.elements.indexOf(ast);
493
+ return getStringConcatenationDirection(ctx, parent, isConcatenatedLeft || index > 0, isConcatenatedRight || index < parent.elements.length - 1);
494
+ }
495
+ if (isBinary(parent) && parent.operation === "+") {
496
+ return getStringConcatenationDirection(ctx, parent, isConcatenatedLeft || parent.right === ast, isConcatenatedRight || parent.left === ast);
497
+ }
498
+ return getStringConcatenationDirection(ctx, parent, isConcatenatedLeft, isConcatenatedRight);
499
+ }
500
+ // resolves the literal nodes adjacent to `ast` on the given side of a `+` concatenation chain
501
+ function findAdjacentPlusConcatenatedLiteralNodes(ctx, ast, direction) {
502
+ const sibling = findConcatenationCounterpart(ctx, ast, direction);
503
+ if (!sibling) {
504
+ return;
505
+ }
506
+ const leafNodes = findConcatenationLeafNodes(sibling, direction === "left" ? "right" : "left");
507
+ return leafNodes.length > 0 ? leafNodes : undefined;
508
+ }
509
+ // resolves the leaf literal nodes of the interpolation expression adjacent to a template element (through conditional branches)
510
+ function findAdjacentInterpolatedExpressionNodes(ctx, ast, direction) {
511
+ if (!isTemplateLiteralElement(ast)) {
512
+ return;
513
+ }
514
+ const parent = findParent(ctx, ast);
515
+ if (!parent || !isTemplateLiteral(parent)) {
516
+ return;
517
+ }
518
+ const index = parent.elements.indexOf(ast);
519
+ if (index === -1) {
520
+ return;
521
+ }
522
+ const expression = direction === "left" ? parent.expressions[index - 1] : parent.expressions[index];
523
+ if (!expression) {
524
+ return;
525
+ }
526
+ const leafNodes = findConcatenationLeafNodes(expression, direction);
527
+ return leafNodes.length > 0 ? leafNodes : undefined;
528
+ }
529
+ // resolves the template elements directly adjacent to an interpolation expression (through conditional branches)
530
+ function findAdjacentTemplateQuasiNodes(ctx, ast, direction) {
531
+ let current = ast;
532
+ while (true) {
533
+ const parent = findParent(ctx, current);
534
+ if (!parent) {
535
+ break;
536
+ }
537
+ if (isTemplateLiteral(parent)) {
538
+ if (isTemplateLiteralElement(current)) {
539
+ current = parent;
540
+ continue;
541
+ }
542
+ const index = parent.expressions.indexOf(current);
543
+ if (index === -1) {
544
+ return;
545
+ }
546
+ const element = direction === "left" ? parent.elements[index] : parent.elements[index + 1];
547
+ return element ? [element] : undefined;
548
+ }
549
+ if (isParenthesizedExpression(parent)) {
550
+ current = parent;
551
+ continue;
552
+ }
553
+ if (isConditional(parent) && (parent.trueExp === current || parent.falseExp === current)) {
554
+ current = parent;
555
+ continue;
556
+ }
557
+ if (isBinary(parent) && parent.operation === "&&" && parent.right === current) {
558
+ current = parent;
559
+ continue;
560
+ }
561
+ break;
562
+ }
563
+ }
564
+ function findConcatenationCounterpart(ctx, ast, direction) {
565
+ let current = ast;
566
+ while (true) {
567
+ const parent = findParent(ctx, current);
568
+ if (!parent) {
569
+ break;
570
+ }
571
+ if (isCallExpression(parent)) {
572
+ break;
573
+ }
574
+ // parenthesized expressions are transparent wrappers in the angular AST
575
+ if (isParenthesizedExpression(parent)) {
576
+ current = parent;
577
+ continue;
578
+ }
579
+ // conditionals are transparent: an operand's neighbor lives outside the branch
580
+ if (isConditional(parent) && (parent.trueExp === current || parent.falseExp === current)) {
581
+ current = parent;
582
+ continue;
583
+ }
584
+ // an edge element's `+` neighbor lives outside the template literal
585
+ if (isTemplateLiteral(parent)) {
586
+ const elements = parent.elements;
587
+ const isEdge = direction === "left"
588
+ ? elements[0] === current
589
+ : elements[elements.length - 1] === current;
590
+ if (isEdge) {
591
+ current = parent;
592
+ continue;
593
+ }
594
+ break;
595
+ }
596
+ if (isBinary(parent) && parent.operation === "+") {
597
+ if (direction === "left" && parent.right === current) {
598
+ return parent.left;
599
+ }
600
+ if (direction === "right" && parent.left === current) {
601
+ return parent.right;
602
+ }
603
+ current = parent;
604
+ continue;
605
+ }
606
+ if (isBinary(parent) && parent.operation === "&&" && parent.right === current) {
607
+ current = parent;
608
+ continue;
609
+ }
610
+ break;
611
+ }
612
+ }
613
+ function findConcatenationLeafNodes(ast, edge) {
614
+ if (isParenthesizedExpression(ast)) {
615
+ return findConcatenationLeafNodes(ast.expression, edge);
616
+ }
617
+ if (isLiteralPrimitive(ast)) {
618
+ return [ast];
619
+ }
620
+ if (isTemplateLiteral(ast)) {
621
+ const elements = ast.elements;
622
+ const edgeElement = edge === "left" ? elements[0] : elements[elements.length - 1];
623
+ return edgeElement ? [edgeElement] : [];
624
+ }
625
+ if (isBinary(ast) && ast.operation === "+") {
626
+ return findConcatenationLeafNodes(edge === "left" ? ast.left : ast.right, edge);
627
+ }
628
+ if (isConditional(ast)) {
629
+ return [
630
+ ...findConcatenationLeafNodes(ast.trueExp, edge),
631
+ ...findConcatenationLeafNodes(ast.falseExp, edge)
632
+ ];
633
+ }
634
+ if (isBinary(ast) && ast.operation === "&&") {
635
+ return findConcatenationLeafNodes(ast.right, "left");
636
+ }
637
+ return [];
638
+ }
639
+ function buildConcatenationNeighborLiteral(ctx, ast, visitedNodes) {
640
+ if (!ast) {
641
+ return;
642
+ }
643
+ if (isStringLiteral(ast)) {
644
+ return createLiteralByAngularLiteralPrimitiveInternal(ctx, ast, visitedNodes)[0];
645
+ }
646
+ if (isTemplateLiteralElement(ast)) {
647
+ return createLiteralByAngularTemplateLiteralElementInternal(ctx, ast, visitedNodes)[0];
648
+ }
649
+ }
650
+ function isInsideObjectValue(ctx, ast) {
651
+ const parent = findParent(ctx, ast);
652
+ if (!parent) {
653
+ return false;
654
+ }
655
+ // #34 allow call expressions as object values
656
+ if (isCallExpression(ast)) {
657
+ return false;
658
+ }
659
+ if (isObjectValue(ast)) {
660
+ return true;
661
+ }
662
+ if (isLiteralMap(parent) && parent.values.includes(ast)) {
663
+ return true;
664
+ }
665
+ return isInsideObjectValue(ctx, parent);
666
+ }
667
+ function isStringLike(ast) {
668
+ return isStringLiteral(ast) || isTemplateLiteralElement(ast);
669
+ }
670
+ function hasParent(ast) {
671
+ return "parent" in ast && ast.parent !== undefined;
672
+ }
673
+ /**
674
+ * The angular parser doesn't provide parent references for all nodes. This function traverses the entire AST
675
+ * to find the parent node of the given AST reference.
676
+ *
677
+ * @param ctx The ESLint rule context.
678
+ * @param astNode The AST node to find the parent for.
679
+ * @returns The parent AST node, or undefined if not found.
680
+ */
681
+ function findParent(ctx, astNode) {
682
+ if (hasParent(astNode)) {
683
+ return astNode.parent;
684
+ }
685
+ const ast = ctx.sourceCode.ast;
686
+ const visitChildNode = (childNode) => {
687
+ if (!childNode || typeof childNode !== "object") {
688
+ return;
689
+ }
690
+ for (const key in childNode) {
691
+ if (key === "parent") {
692
+ continue;
693
+ }
694
+ if (childNode[key] === astNode) {
695
+ return childNode;
696
+ }
697
+ const result = visitChildNode(childNode[key]);
698
+ if (result) {
699
+ return result;
700
+ }
701
+ }
702
+ };
703
+ return visitChildNode(ast);
704
+ }
705
+ function isBoundAttributeName(ast) {
706
+ return isBoundAttribute(ast) && getAttributeName(ast)?.startsWith("[class.");
707
+ }
708
+ function isObjectValue(ast) {
709
+ return isStringLiteral(ast) && hasParent(ast) && isLiteralMap(ast.parent);
710
+ }
711
+ function isObjectKey(ast) {
712
+ return "type" in ast && ast.type === "Object" && "key" in ast && ast.key !== undefined;
713
+ }
714
+ function isStringLiteral(ast) {
715
+ return isLiteralPrimitive(ast) && typeof ast.value === "string";
716
+ }
717
+ export function isAST(ast) {
718
+ return typeof ast === "object" && ast !== null && "type" in ast;
719
+ }
720
+ function is(ast, type) {
721
+ return "type" in ast && typeof ast.type === "string" && ast.type === type;
722
+ }
723
+ const isCallExpression = (ast) => is(ast, "Call");
724
+ const isASTWithSource = (ast) => is(ast, "ASTWithSource");
725
+ const isInterpolation = (ast) => is(ast, "Interpolation");
726
+ const isConditional = (ast) => is(ast, "Conditional");
727
+ const isParenthesizedExpression = (ast) => is(ast, "ParenthesizedExpression");
728
+ const isBinary = (ast) => is(ast, "Binary");
729
+ const isLiteralArray = (ast) => is(ast, "LiteralArray");
730
+ const isLiteralMap = (ast) => is(ast, "LiteralMap");
731
+ const isTemplateLiteral = (ast) => is(ast, "TemplateLiteral");
732
+ const isTemplateLiteralElement = (ast) => is(ast, "TemplateLiteralElement");
733
+ const isLiteralPrimitive = (ast) => is(ast, "LiteralPrimitive");
734
+ const isTextAttribute = (ast) => is(ast, "TextAttribute");
735
+ const isBoundAttribute = (ast) => is(ast, "BoundAttribute");
736
+ //# sourceMappingURL=angular.js.map