boss-css 0.0.1 → 0.0.2

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 (268) hide show
  1. package/README.md +1 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  3. package/dist/_virtual/rolldown_runtime.mjs +20 -0
  4. package/dist/api/browser.cjs +54 -0
  5. package/dist/api/browser.mjs +48 -0
  6. package/dist/api/config.cjs +94 -0
  7. package/dist/api/config.mjs +91 -0
  8. package/dist/api/css.cjs +304 -0
  9. package/dist/api/css.mjs +303 -0
  10. package/dist/api/dictionary.cjs +218 -0
  11. package/dist/api/dictionary.mjs +215 -0
  12. package/dist/api/file/dts.cjs +21 -0
  13. package/dist/api/file/dts.mjs +21 -0
  14. package/dist/api/file/file.cjs +123 -0
  15. package/dist/api/file/file.mjs +120 -0
  16. package/dist/api/file/js.cjs +118 -0
  17. package/dist/api/file/js.mjs +116 -0
  18. package/dist/api/names.cjs +52 -0
  19. package/dist/api/names.mjs +46 -0
  20. package/dist/api/noopCss.cjs +37 -0
  21. package/dist/api/noopCss.mjs +36 -0
  22. package/dist/api/propTree.cjs +54 -0
  23. package/dist/api/propTree.mjs +48 -0
  24. package/dist/api/server.cjs +112 -0
  25. package/dist/api/server.mjs +106 -0
  26. package/dist/cli/build.cjs +1 -0
  27. package/dist/cli/build.mjs +3 -0
  28. package/dist/cli/index.cjs +30 -0
  29. package/dist/cli/index.mjs +29 -0
  30. package/dist/cli/tasks/build.cjs +24 -0
  31. package/dist/cli/tasks/build.mjs +23 -0
  32. package/dist/cli/tasks/choose.cjs +47 -0
  33. package/dist/cli/tasks/choose.mjs +46 -0
  34. package/dist/cli/tasks/compile.cjs +68 -0
  35. package/dist/cli/tasks/compile.mjs +67 -0
  36. package/dist/cli/tasks/dev.cjs +51 -0
  37. package/dist/cli/tasks/dev.mjs +48 -0
  38. package/dist/cli/tasks/init.cjs +1835 -0
  39. package/dist/cli/tasks/init.mjs +1831 -0
  40. package/dist/cli/tasks/watch.cjs +38 -0
  41. package/dist/cli/tasks/watch.mjs +37 -0
  42. package/dist/cli/templates/init.cjs +82 -0
  43. package/dist/cli/templates/init.mjs +78 -0
  44. package/dist/cli/types.cjs +13 -0
  45. package/dist/cli/types.mjs +13 -0
  46. package/dist/cli/utils.cjs +43 -0
  47. package/dist/cli/utils.mjs +41 -0
  48. package/dist/compile/classname-strategy.cjs +79 -0
  49. package/dist/compile/classname-strategy.mjs +77 -0
  50. package/dist/compile/classname.cjs +366 -0
  51. package/dist/compile/classname.mjs +360 -0
  52. package/dist/compile/index.cjs +238 -0
  53. package/dist/compile/index.mjs +235 -0
  54. package/dist/compile/jsx.cjs +803 -0
  55. package/dist/compile/jsx.mjs +800 -0
  56. package/dist/compile/prepared.cjs +88 -0
  57. package/dist/compile/prepared.mjs +87 -0
  58. package/dist/compile/runtime.cjs +33 -0
  59. package/dist/compile/runtime.mjs +32 -0
  60. package/dist/compile/transform.cjs +371 -0
  61. package/dist/compile/transform.mjs +369 -0
  62. package/dist/cx/index.cjs +93 -0
  63. package/dist/cx/index.mjs +85 -0
  64. package/dist/detect-fw/index.cjs +384 -0
  65. package/dist/detect-fw/index.mjs +379 -0
  66. package/dist/dev/client.cjs +39 -0
  67. package/dist/dev/client.mjs +38 -0
  68. package/dist/dev/plugin/browser.cjs +11 -0
  69. package/dist/dev/plugin/browser.mjs +9 -0
  70. package/dist/dev/plugin/server.cjs +86 -0
  71. package/dist/dev/plugin/server.mjs +78 -0
  72. package/dist/dev/port.cjs +46 -0
  73. package/dist/dev/port.mjs +43 -0
  74. package/dist/dev/runtime.cjs +28 -0
  75. package/dist/dev/runtime.mjs +29 -0
  76. package/dist/dev/server.cjs +808 -0
  77. package/dist/dev/server.mjs +805 -0
  78. package/dist/dev/shared.cjs +6 -0
  79. package/dist/dev/shared.mjs +5 -0
  80. package/dist/eslint-plugin/index.cjs +66 -0
  81. package/dist/eslint-plugin/index.mjs +66 -0
  82. package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
  83. package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
  84. package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
  85. package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
  86. package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
  87. package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
  88. package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
  89. package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
  90. package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
  91. package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
  92. package/dist/eslint-plugin/rules/props-only.cjs +115 -0
  93. package/dist/eslint-plugin/rules/props-only.mjs +115 -0
  94. package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
  95. package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
  96. package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
  97. package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
  98. package/dist/eslint-plugin/utils/api.cjs +30 -0
  99. package/dist/eslint-plugin/utils/api.mjs +29 -0
  100. package/dist/eslint-plugin/utils/ast.cjs +119 -0
  101. package/dist/eslint-plugin/utils/ast.mjs +112 -0
  102. package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
  103. package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
  104. package/dist/eslint-plugin/utils/defaults.cjs +99 -0
  105. package/dist/eslint-plugin/utils/defaults.mjs +93 -0
  106. package/dist/eslint-plugin/utils/format.cjs +20 -0
  107. package/dist/eslint-plugin/utils/format.mjs +19 -0
  108. package/dist/eslint-plugin/utils/order.cjs +76 -0
  109. package/dist/eslint-plugin/utils/order.mjs +76 -0
  110. package/dist/eslint-plugin/utils/property-order.cjs +449 -0
  111. package/dist/eslint-plugin/utils/property-order.mjs +448 -0
  112. package/dist/eslint-plugin/utils/static.cjs +36 -0
  113. package/dist/eslint-plugin/utils/static.mjs +35 -0
  114. package/dist/fontsource/directory.cjs +39588 -0
  115. package/dist/fontsource/directory.mjs +39587 -0
  116. package/dist/fontsource/server.cjs +291 -0
  117. package/dist/fontsource/server.mjs +282 -0
  118. package/dist/index.cjs +10 -0
  119. package/dist/index.mjs +6 -0
  120. package/dist/log/browser.cjs +28 -0
  121. package/dist/log/browser.mjs +28 -0
  122. package/dist/log/server.cjs +32 -0
  123. package/dist/log/server.mjs +30 -0
  124. package/dist/merge/index.cjs +590 -0
  125. package/dist/merge/index.mjs +586 -0
  126. package/dist/native/browser.cjs +78 -0
  127. package/dist/native/browser.mjs +77 -0
  128. package/dist/native/server.cjs +180 -0
  129. package/dist/native/server.mjs +176 -0
  130. package/dist/native/styleTypes.cjs +168 -0
  131. package/dist/native/styleTypes.mjs +164 -0
  132. package/dist/parser/classname/server.cjs +239 -0
  133. package/dist/parser/classname/server.mjs +232 -0
  134. package/dist/parser/jsx/browser.cjs +66 -0
  135. package/dist/parser/jsx/browser.mjs +63 -0
  136. package/dist/parser/jsx/extractCode.cjs +99 -0
  137. package/dist/parser/jsx/extractCode.mjs +98 -0
  138. package/dist/parser/jsx/extractPrepared.cjs +123 -0
  139. package/dist/parser/jsx/extractPrepared.mjs +122 -0
  140. package/dist/parser/jsx/extractProps.cjs +234 -0
  141. package/dist/parser/jsx/extractProps.mjs +232 -0
  142. package/dist/parser/jsx/isDOMProp.cjs +17 -0
  143. package/dist/parser/jsx/isDOMProp.mjs +15 -0
  144. package/dist/parser/jsx/native.cjs +110 -0
  145. package/dist/parser/jsx/native.mjs +108 -0
  146. package/dist/parser/jsx/runtime.cjs +4 -0
  147. package/dist/parser/jsx/runtime.mjs +3 -0
  148. package/dist/parser/jsx/server.cjs +278 -0
  149. package/dist/parser/jsx/server.mjs +268 -0
  150. package/dist/postcss/index.cjs +16 -0
  151. package/dist/postcss/index.mjs +16 -0
  152. package/dist/prop/at/runtime-only.cjs +90 -0
  153. package/dist/prop/at/runtime-only.mjs +88 -0
  154. package/dist/prop/at/server.cjs +282 -0
  155. package/dist/prop/at/server.mjs +268 -0
  156. package/dist/prop/at/shared.cjs +153 -0
  157. package/dist/prop/at/shared.mjs +144 -0
  158. package/dist/prop/bosswind/browser.cjs +18 -0
  159. package/dist/prop/bosswind/browser.mjs +16 -0
  160. package/dist/prop/bosswind/runtime-only.cjs +18 -0
  161. package/dist/prop/bosswind/runtime-only.mjs +16 -0
  162. package/dist/prop/bosswind/server.cjs +81 -0
  163. package/dist/prop/bosswind/server.mjs +72 -0
  164. package/dist/prop/bosswind/shared.cjs +861 -0
  165. package/dist/prop/bosswind/shared.mjs +855 -0
  166. package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
  167. package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
  168. package/dist/prop/child/runtime-only.cjs +18 -0
  169. package/dist/prop/child/runtime-only.mjs +15 -0
  170. package/dist/prop/child/server.cjs +81 -0
  171. package/dist/prop/child/server.mjs +72 -0
  172. package/dist/prop/css/getDtsTemplate.cjs +65 -0
  173. package/dist/prop/css/getDtsTemplate.mjs +63 -0
  174. package/dist/prop/css/runtime-only.cjs +14 -0
  175. package/dist/prop/css/runtime-only.mjs +13 -0
  176. package/dist/prop/css/server.cjs +99 -0
  177. package/dist/prop/css/server.mjs +90 -0
  178. package/dist/prop/pseudo/runtime-only.cjs +23 -0
  179. package/dist/prop/pseudo/runtime-only.mjs +21 -0
  180. package/dist/prop/pseudo/server.cjs +91 -0
  181. package/dist/prop/pseudo/server.mjs +82 -0
  182. package/dist/prop/pseudo/shared.cjs +61 -0
  183. package/dist/prop/pseudo/shared.mjs +60 -0
  184. package/dist/reset/server.cjs +34 -0
  185. package/dist/reset/server.mjs +26 -0
  186. package/dist/runtime/index.cjs +119 -0
  187. package/dist/runtime/index.mjs +118 -0
  188. package/dist/runtime/preact.cjs +4 -0
  189. package/dist/runtime/preact.mjs +3 -0
  190. package/dist/runtime/qwik.cjs +21 -0
  191. package/dist/runtime/qwik.mjs +18 -0
  192. package/dist/runtime/react.cjs +4 -0
  193. package/dist/runtime/react.mjs +3 -0
  194. package/dist/runtime/solid.cjs +15 -0
  195. package/dist/runtime/solid.mjs +14 -0
  196. package/dist/runtime/stencil.cjs +25 -0
  197. package/dist/runtime/stencil.mjs +21 -0
  198. package/dist/runtime/style.cjs +14 -0
  199. package/dist/runtime/style.mjs +13 -0
  200. package/dist/shared/boundaries.cjs +288 -0
  201. package/dist/shared/boundaries.mjs +285 -0
  202. package/dist/shared/customCss.cjs +212 -0
  203. package/dist/shared/customCss.mjs +211 -0
  204. package/dist/shared/debug.cjs +76 -0
  205. package/dist/shared/debug.mjs +74 -0
  206. package/dist/shared/file.cjs +21 -0
  207. package/dist/shared/file.mjs +19 -0
  208. package/dist/shared/framework.cjs +10 -0
  209. package/dist/shared/framework.mjs +9 -0
  210. package/dist/shared/json.cjs +58 -0
  211. package/dist/shared/json.mjs +57 -0
  212. package/dist/shared/types.cjs +11 -0
  213. package/dist/shared/types.mjs +10 -0
  214. package/dist/strategy/classic/runtime-only.cjs +190 -0
  215. package/dist/strategy/classic/runtime-only.mjs +186 -0
  216. package/dist/strategy/classname-first/runtime-only.cjs +138 -0
  217. package/dist/strategy/classname-first/runtime-only.mjs +134 -0
  218. package/dist/strategy/classname-first/server.cjs +139 -0
  219. package/dist/strategy/classname-first/server.mjs +133 -0
  220. package/dist/strategy/classname-only/server.cjs +43 -0
  221. package/dist/strategy/classname-only/server.mjs +35 -0
  222. package/dist/strategy/inline-first/browser.cjs +61 -0
  223. package/dist/strategy/inline-first/browser.mjs +58 -0
  224. package/dist/strategy/inline-first/runtime-only.cjs +159 -0
  225. package/dist/strategy/inline-first/runtime-only.mjs +155 -0
  226. package/dist/strategy/inline-first/server.cjs +92 -0
  227. package/dist/strategy/inline-first/server.mjs +83 -0
  228. package/dist/strategy/runtime/runtime-only.cjs +24 -0
  229. package/dist/strategy/runtime/runtime-only.mjs +22 -0
  230. package/dist/strategy/runtime/server.cjs +72 -0
  231. package/dist/strategy/runtime/server.mjs +63 -0
  232. package/dist/strategy/runtime-only/css.cjs +183 -0
  233. package/dist/strategy/runtime-only/css.mjs +181 -0
  234. package/dist/tasks/build.cjs +88 -0
  235. package/dist/tasks/build.mjs +84 -0
  236. package/dist/tasks/compile.cjs +12 -0
  237. package/dist/tasks/compile.mjs +12 -0
  238. package/dist/tasks/postcss.cjs +116 -0
  239. package/dist/tasks/postcss.mjs +113 -0
  240. package/dist/tasks/session.cjs +46 -0
  241. package/dist/tasks/session.mjs +42 -0
  242. package/dist/tasks/watch.cjs +102 -0
  243. package/dist/tasks/watch.mjs +99 -0
  244. package/dist/transform/cache.cjs +24 -0
  245. package/dist/transform/cache.mjs +21 -0
  246. package/dist/transform/processFile.cjs +26 -0
  247. package/dist/transform/processFile.mjs +24 -0
  248. package/dist/use/token/browser.cjs +65 -0
  249. package/dist/use/token/browser.mjs +61 -0
  250. package/dist/use/token/runtime-only.cjs +245 -0
  251. package/dist/use/token/runtime-only.mjs +239 -0
  252. package/dist/use/token/server.cjs +325 -0
  253. package/dist/use/token/server.mjs +313 -0
  254. package/dist/use/token/vars.cjs +47 -0
  255. package/dist/use/token/vars.mjs +46 -0
  256. package/package.json +300 -4
  257. package/src/api/config.d.ts +1 -0
  258. package/src/fontsource/types.d.ts +50 -0
  259. package/src/packages/document-create-element/createElement.browser.js +3 -0
  260. package/src/packages/document-create-element/createElement.js +7 -0
  261. package/src/packages/document-create-element/package.json +17 -0
  262. package/src/packages/is-css-prop/browser.js +13 -0
  263. package/src/packages/is-css-prop/index.js +13 -0
  264. package/src/packages/is-css-prop/package-lock.json +52 -0
  265. package/src/packages/is-css-prop/package.json +17 -0
  266. package/src/prop/css/csstype.json +4387 -0
  267. package/src/prop/css/package.json +3 -0
  268. package/src/reset/reset.css +259 -0
@@ -0,0 +1,119 @@
1
+
2
+ //#region src/eslint-plugin/utils/ast.js
3
+ const isStringLiteral = (node) => node && node.type === "Literal" && typeof node.value === "string" || node && node.type === "StringLiteral" && typeof node.value === "string";
4
+ const isTemplateLiteral = (node) => node && node.type === "TemplateLiteral";
5
+ const getLiteralInfo = (node, sourceCode) => {
6
+ if (isStringLiteral(node)) return {
7
+ value: node.value,
8
+ node,
9
+ raw: sourceCode.getText(node),
10
+ canFix: true
11
+ };
12
+ if (isTemplateLiteral(node) && node.expressions.length === 0) {
13
+ const quasi = node.quasis[0];
14
+ return {
15
+ value: quasi?.value?.cooked ?? quasi?.value?.raw ?? "",
16
+ node,
17
+ raw: sourceCode.getText(node),
18
+ canFix: true
19
+ };
20
+ }
21
+ return null;
22
+ };
23
+ const getPropertyKeyInfo = (property, sourceCode) => {
24
+ if (!property || property.type !== "Property") return null;
25
+ if (property.computed) return null;
26
+ const key = property.key;
27
+ if (isStringLiteral(key)) return {
28
+ value: key.value,
29
+ node: key,
30
+ raw: sourceCode.getText(key),
31
+ canFix: false
32
+ };
33
+ if (key && key.type === "Identifier") return {
34
+ value: key.name,
35
+ node: key,
36
+ raw: sourceCode.getText(key),
37
+ canFix: false
38
+ };
39
+ return null;
40
+ };
41
+ const collectClassLiteralsFromExpression = (expression, sourceCode, results) => {
42
+ if (!expression) return;
43
+ if (expression.type === "JSXExpressionContainer") {
44
+ collectClassLiteralsFromExpression(expression.expression, sourceCode, results);
45
+ return;
46
+ }
47
+ const literal = getLiteralInfo(expression, sourceCode);
48
+ if (literal) {
49
+ results.push(literal);
50
+ return;
51
+ }
52
+ if (expression.type === "ArrayExpression") {
53
+ for (const element of expression.elements) if (element) collectClassLiteralsFromExpression(element, sourceCode, results);
54
+ return;
55
+ }
56
+ if (expression.type === "LogicalExpression") {
57
+ collectClassLiteralsFromExpression(expression.left, sourceCode, results);
58
+ collectClassLiteralsFromExpression(expression.right, sourceCode, results);
59
+ return;
60
+ }
61
+ if (expression.type === "ConditionalExpression") {
62
+ collectClassLiteralsFromExpression(expression.consequent, sourceCode, results);
63
+ collectClassLiteralsFromExpression(expression.alternate, sourceCode, results);
64
+ return;
65
+ }
66
+ if (expression.type === "BinaryExpression" && expression.operator === "+") {
67
+ collectClassLiteralsFromExpression(expression.left, sourceCode, results);
68
+ collectClassLiteralsFromExpression(expression.right, sourceCode, results);
69
+ return;
70
+ }
71
+ if (expression.type === "SequenceExpression") {
72
+ for (const item of expression.expressions) collectClassLiteralsFromExpression(item, sourceCode, results);
73
+ return;
74
+ }
75
+ if (expression.type === "ObjectExpression") {
76
+ for (const property of expression.properties) if (property && property.type === "Property") {
77
+ const keyInfo = getPropertyKeyInfo(property, sourceCode);
78
+ if (keyInfo) results.push(keyInfo);
79
+ }
80
+ }
81
+ };
82
+ const compilePatterns = (patterns) => {
83
+ if (!Array.isArray(patterns)) return [];
84
+ return patterns.map((pattern) => new RegExp(pattern));
85
+ };
86
+ const matchesPattern = (compiled, name) => compiled.some((pattern) => pattern.test(name));
87
+ const getCalleeName = (node) => {
88
+ if (!node) return null;
89
+ if (node.type === "ChainExpression") return getCalleeName(node.expression);
90
+ if (node.type === "Identifier") return node.name;
91
+ if (node.type === "MemberExpression" && !node.computed) {
92
+ const objectName = getCalleeName(node.object);
93
+ const propertyName = getCalleeName(node.property);
94
+ if (!objectName || !propertyName) return null;
95
+ return `${objectName}.${propertyName}`;
96
+ }
97
+ return null;
98
+ };
99
+ const getJSXRootName = (node) => {
100
+ if (!node) return null;
101
+ if (node.type === "JSXIdentifier") return node.name;
102
+ if (node.type === "JSXMemberExpression") return getJSXRootName(node.object);
103
+ return null;
104
+ };
105
+ const getJSXAttributeName = (node) => {
106
+ if (!node || node.type !== "JSXAttribute") return null;
107
+ if (!node.name) return null;
108
+ if (node.name.type === "JSXIdentifier") return node.name.name;
109
+ return null;
110
+ };
111
+
112
+ //#endregion
113
+ exports.collectClassLiteralsFromExpression = collectClassLiteralsFromExpression;
114
+ exports.compilePatterns = compilePatterns;
115
+ exports.getCalleeName = getCalleeName;
116
+ exports.getJSXAttributeName = getJSXAttributeName;
117
+ exports.getJSXRootName = getJSXRootName;
118
+ exports.getLiteralInfo = getLiteralInfo;
119
+ exports.matchesPattern = matchesPattern;
@@ -0,0 +1,112 @@
1
+ //#region src/eslint-plugin/utils/ast.js
2
+ const isStringLiteral = (node) => node && node.type === "Literal" && typeof node.value === "string" || node && node.type === "StringLiteral" && typeof node.value === "string";
3
+ const isTemplateLiteral = (node) => node && node.type === "TemplateLiteral";
4
+ const getLiteralInfo = (node, sourceCode) => {
5
+ if (isStringLiteral(node)) return {
6
+ value: node.value,
7
+ node,
8
+ raw: sourceCode.getText(node),
9
+ canFix: true
10
+ };
11
+ if (isTemplateLiteral(node) && node.expressions.length === 0) {
12
+ const quasi = node.quasis[0];
13
+ return {
14
+ value: quasi?.value?.cooked ?? quasi?.value?.raw ?? "",
15
+ node,
16
+ raw: sourceCode.getText(node),
17
+ canFix: true
18
+ };
19
+ }
20
+ return null;
21
+ };
22
+ const getPropertyKeyInfo = (property, sourceCode) => {
23
+ if (!property || property.type !== "Property") return null;
24
+ if (property.computed) return null;
25
+ const key = property.key;
26
+ if (isStringLiteral(key)) return {
27
+ value: key.value,
28
+ node: key,
29
+ raw: sourceCode.getText(key),
30
+ canFix: false
31
+ };
32
+ if (key && key.type === "Identifier") return {
33
+ value: key.name,
34
+ node: key,
35
+ raw: sourceCode.getText(key),
36
+ canFix: false
37
+ };
38
+ return null;
39
+ };
40
+ const collectClassLiteralsFromExpression = (expression, sourceCode, results) => {
41
+ if (!expression) return;
42
+ if (expression.type === "JSXExpressionContainer") {
43
+ collectClassLiteralsFromExpression(expression.expression, sourceCode, results);
44
+ return;
45
+ }
46
+ const literal = getLiteralInfo(expression, sourceCode);
47
+ if (literal) {
48
+ results.push(literal);
49
+ return;
50
+ }
51
+ if (expression.type === "ArrayExpression") {
52
+ for (const element of expression.elements) if (element) collectClassLiteralsFromExpression(element, sourceCode, results);
53
+ return;
54
+ }
55
+ if (expression.type === "LogicalExpression") {
56
+ collectClassLiteralsFromExpression(expression.left, sourceCode, results);
57
+ collectClassLiteralsFromExpression(expression.right, sourceCode, results);
58
+ return;
59
+ }
60
+ if (expression.type === "ConditionalExpression") {
61
+ collectClassLiteralsFromExpression(expression.consequent, sourceCode, results);
62
+ collectClassLiteralsFromExpression(expression.alternate, sourceCode, results);
63
+ return;
64
+ }
65
+ if (expression.type === "BinaryExpression" && expression.operator === "+") {
66
+ collectClassLiteralsFromExpression(expression.left, sourceCode, results);
67
+ collectClassLiteralsFromExpression(expression.right, sourceCode, results);
68
+ return;
69
+ }
70
+ if (expression.type === "SequenceExpression") {
71
+ for (const item of expression.expressions) collectClassLiteralsFromExpression(item, sourceCode, results);
72
+ return;
73
+ }
74
+ if (expression.type === "ObjectExpression") {
75
+ for (const property of expression.properties) if (property && property.type === "Property") {
76
+ const keyInfo = getPropertyKeyInfo(property, sourceCode);
77
+ if (keyInfo) results.push(keyInfo);
78
+ }
79
+ }
80
+ };
81
+ const compilePatterns = (patterns) => {
82
+ if (!Array.isArray(patterns)) return [];
83
+ return patterns.map((pattern) => new RegExp(pattern));
84
+ };
85
+ const matchesPattern = (compiled, name) => compiled.some((pattern) => pattern.test(name));
86
+ const getCalleeName = (node) => {
87
+ if (!node) return null;
88
+ if (node.type === "ChainExpression") return getCalleeName(node.expression);
89
+ if (node.type === "Identifier") return node.name;
90
+ if (node.type === "MemberExpression" && !node.computed) {
91
+ const objectName = getCalleeName(node.object);
92
+ const propertyName = getCalleeName(node.property);
93
+ if (!objectName || !propertyName) return null;
94
+ return `${objectName}.${propertyName}`;
95
+ }
96
+ return null;
97
+ };
98
+ const getJSXRootName = (node) => {
99
+ if (!node) return null;
100
+ if (node.type === "JSXIdentifier") return node.name;
101
+ if (node.type === "JSXMemberExpression") return getJSXRootName(node.object);
102
+ return null;
103
+ };
104
+ const getJSXAttributeName = (node) => {
105
+ if (!node || node.type !== "JSXAttribute") return null;
106
+ if (!node.name) return null;
107
+ if (node.name.type === "JSXIdentifier") return node.name.name;
108
+ return null;
109
+ };
110
+
111
+ //#endregion
112
+ export { collectClassLiteralsFromExpression, compilePatterns, getCalleeName, getJSXAttributeName, getJSXRootName, getLiteralInfo, matchesPattern };
@@ -0,0 +1,185 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_defaults = require('./defaults.cjs');
3
+ const require_api = require('./api.cjs');
4
+ let _boss_css_is_css_prop = require("@boss-css/is-css-prop");
5
+ _boss_css_is_css_prop = require_rolldown_runtime.__toESM(_boss_css_is_css_prop);
6
+
7
+ //#region src/eslint-plugin/utils/boss-classes.js
8
+ const whitespaceRegexp = /\s/;
9
+ const cssPropCache = /* @__PURE__ */ new Map();
10
+ const dashToCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
11
+ const getDictionary = () => {
12
+ const { api } = require_api.getApi();
13
+ return api?.dictionary ?? null;
14
+ };
15
+ const getDictionaryEntry = (name) => {
16
+ const dictionary = getDictionary();
17
+ if (!dictionary) return null;
18
+ if (typeof dictionary.resolve === "function") return dictionary.resolve(name).descriptor || dictionary.resolve(dashToCamelCase(name)).descriptor || null;
19
+ return dictionary.get(name) || dictionary.get(dashToCamelCase(name)) || null;
20
+ };
21
+ const isCssPropName = (name, extraProps) => {
22
+ if (!name) return false;
23
+ if (extraProps && extraProps.has(name)) return true;
24
+ const dictionaryEntry = getDictionaryEntry(name);
25
+ if (dictionaryEntry) return Boolean(dictionaryEntry.isCSSProp);
26
+ const cached = cssPropCache.get(name);
27
+ if (cached !== void 0) return cached;
28
+ const camelName = dashToCamelCase(name);
29
+ const result = (0, _boss_css_is_css_prop.default)("div", name) || (0, _boss_css_is_css_prop.default)("div", camelName);
30
+ cssPropCache.set(name, result);
31
+ return result;
32
+ };
33
+ const splitClassList = (input) => {
34
+ const results = [];
35
+ let current = "";
36
+ let braceDepth = 0;
37
+ let bracketDepth = 0;
38
+ for (const char of input) {
39
+ if (char === "{") braceDepth += 1;
40
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
41
+ if (char === "[") bracketDepth += 1;
42
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
43
+ if (braceDepth === 0 && bracketDepth === 0 && whitespaceRegexp.test(char)) {
44
+ if (current) results.push(current);
45
+ current = "";
46
+ continue;
47
+ }
48
+ current += char;
49
+ }
50
+ if (current) results.push(current);
51
+ return results;
52
+ };
53
+ const splitFragments = (selector) => splitOutside(selector, ":");
54
+ const parseGroupedSelector = (selector) => {
55
+ if (!selector.endsWith("}")) return null;
56
+ const groupStart = findGroupStart(selector);
57
+ if (groupStart === -1) return null;
58
+ const prefix = selector.slice(0, groupStart);
59
+ const entries = splitOutside(selector.slice(groupStart + 2, -1), ";").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
60
+ const parts = splitOnceOutside(entry, ":");
61
+ if (!parts) return null;
62
+ const [name, rawValue] = parts;
63
+ return {
64
+ name: name.trim(),
65
+ rawValue: rawValue.trim()
66
+ };
67
+ }).filter(Boolean);
68
+ if (!entries.length) return null;
69
+ return {
70
+ prefix,
71
+ entries
72
+ };
73
+ };
74
+ const splitOutside = (input, delimiter) => {
75
+ const results = [];
76
+ let current = "";
77
+ let braceDepth = 0;
78
+ let bracketDepth = 0;
79
+ for (const char of input) {
80
+ if (char === "{") braceDepth += 1;
81
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
82
+ if (char === "[") bracketDepth += 1;
83
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
84
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) {
85
+ if (current) results.push(current);
86
+ current = "";
87
+ continue;
88
+ }
89
+ current += char;
90
+ }
91
+ if (current) results.push(current);
92
+ return results;
93
+ };
94
+ const splitOnceOutside = (input, delimiter) => {
95
+ let braceDepth = 0;
96
+ let bracketDepth = 0;
97
+ for (let i = 0; i < input.length; i += 1) {
98
+ const char = input[i];
99
+ if (char === "{") braceDepth += 1;
100
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
101
+ if (char === "[") bracketDepth += 1;
102
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
103
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) return [input.slice(0, i), input.slice(i + 1)];
104
+ }
105
+ return null;
106
+ };
107
+ const findGroupStart = (selector) => {
108
+ let bracketDepth = 0;
109
+ for (let i = 0; i < selector.length - 1; i += 1) {
110
+ const char = selector[i];
111
+ if (char === "[") bracketDepth += 1;
112
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
113
+ if (bracketDepth === 0 && selector[i] === ":" && selector[i + 1] === "{") return i;
114
+ }
115
+ return -1;
116
+ };
117
+ const isArbitrarySelectorContext = (context) => context.startsWith("[") && context.endsWith("]");
118
+ const isContainerContext = (context) => context === "container" || context.startsWith("container ") || context.startsWith("container_");
119
+ const getContextSet = (options) => {
120
+ const contexts = require_defaults.getDefaultContexts();
121
+ const dictionary = getDictionary();
122
+ if (dictionary) for (const [name, entry] of dictionary.entries()) {
123
+ if (entry?.isCSSProp) continue;
124
+ contexts.add(name);
125
+ }
126
+ if (options?.additionalContexts) for (const context of options.additionalContexts) contexts.add(context);
127
+ return contexts;
128
+ };
129
+ const hasValidContexts = (contexts, options, contextSet) => {
130
+ if (options?.allowCustomContexts) return true;
131
+ return contexts.every((context) => isArbitrarySelectorContext(context) || contextSet.has(context) || contextSet.has("container") && isContainerContext(context));
132
+ };
133
+ const isValidBossToken = (token, options = {}) => {
134
+ if (!token) return false;
135
+ const contextSet = getContextSet(options);
136
+ const extraProps = options.additionalProps ? new Set(options.additionalProps) : null;
137
+ const singleProps = options.singleProps ? new Set(options.singleProps) : null;
138
+ const grouped = parseGroupedSelector(token);
139
+ if (grouped) {
140
+ if (!hasValidContexts(splitFragments(grouped.prefix), options, contextSet)) return false;
141
+ for (const entry of grouped.entries) {
142
+ if (!entry.name) return false;
143
+ if (!isCssPropName(entry.name, extraProps)) return false;
144
+ }
145
+ return true;
146
+ }
147
+ const fragments = splitFragments(token);
148
+ if (!fragments.length) return false;
149
+ let propIndex = -1;
150
+ for (let i = 0; i < fragments.length; i += 1) if (isCssPropName(fragments[i], extraProps)) {
151
+ propIndex = i;
152
+ break;
153
+ }
154
+ if (propIndex === -1) return false;
155
+ if (!hasValidContexts(fragments.slice(0, propIndex), options, contextSet)) return false;
156
+ if (!(propIndex < fragments.length - 1)) {
157
+ if (getDictionaryEntry(fragments[propIndex])?.single) return true;
158
+ if (!singleProps) return false;
159
+ if (!singleProps.has(fragments[propIndex])) return false;
160
+ }
161
+ return true;
162
+ };
163
+ const findInvalidTokens = (classList, options) => {
164
+ const tokens = splitClassList(classList);
165
+ const invalid = [];
166
+ for (const token of tokens) {
167
+ if (!token) continue;
168
+ if (!isValidBossToken(token, options)) invalid.push(token);
169
+ }
170
+ return invalid;
171
+ };
172
+ const containsBossToken = (classList, options) => {
173
+ return splitClassList(classList).some((token) => isValidBossToken(token, options));
174
+ };
175
+
176
+ //#endregion
177
+ exports.containsBossToken = containsBossToken;
178
+ exports.findInvalidTokens = findInvalidTokens;
179
+ exports.getContextSet = getContextSet;
180
+ exports.getDictionary = getDictionary;
181
+ exports.getDictionaryEntry = getDictionaryEntry;
182
+ exports.isCssPropName = isCssPropName;
183
+ exports.parseGroupedSelector = parseGroupedSelector;
184
+ exports.splitClassList = splitClassList;
185
+ exports.splitFragments = splitFragments;
@@ -0,0 +1,175 @@
1
+ import { getDefaultContexts } from "./defaults.mjs";
2
+ import { getApi } from "./api.mjs";
3
+ import isCSSProp from "@boss-css/is-css-prop";
4
+
5
+ //#region src/eslint-plugin/utils/boss-classes.js
6
+ const whitespaceRegexp = /\s/;
7
+ const cssPropCache = /* @__PURE__ */ new Map();
8
+ const dashToCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
9
+ const getDictionary = () => {
10
+ const { api } = getApi();
11
+ return api?.dictionary ?? null;
12
+ };
13
+ const getDictionaryEntry = (name) => {
14
+ const dictionary = getDictionary();
15
+ if (!dictionary) return null;
16
+ if (typeof dictionary.resolve === "function") return dictionary.resolve(name).descriptor || dictionary.resolve(dashToCamelCase(name)).descriptor || null;
17
+ return dictionary.get(name) || dictionary.get(dashToCamelCase(name)) || null;
18
+ };
19
+ const isCssPropName = (name, extraProps) => {
20
+ if (!name) return false;
21
+ if (extraProps && extraProps.has(name)) return true;
22
+ const dictionaryEntry = getDictionaryEntry(name);
23
+ if (dictionaryEntry) return Boolean(dictionaryEntry.isCSSProp);
24
+ const cached = cssPropCache.get(name);
25
+ if (cached !== void 0) return cached;
26
+ const camelName = dashToCamelCase(name);
27
+ const result = isCSSProp("div", name) || isCSSProp("div", camelName);
28
+ cssPropCache.set(name, result);
29
+ return result;
30
+ };
31
+ const splitClassList = (input) => {
32
+ const results = [];
33
+ let current = "";
34
+ let braceDepth = 0;
35
+ let bracketDepth = 0;
36
+ for (const char of input) {
37
+ if (char === "{") braceDepth += 1;
38
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
39
+ if (char === "[") bracketDepth += 1;
40
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
41
+ if (braceDepth === 0 && bracketDepth === 0 && whitespaceRegexp.test(char)) {
42
+ if (current) results.push(current);
43
+ current = "";
44
+ continue;
45
+ }
46
+ current += char;
47
+ }
48
+ if (current) results.push(current);
49
+ return results;
50
+ };
51
+ const splitFragments = (selector) => splitOutside(selector, ":");
52
+ const parseGroupedSelector = (selector) => {
53
+ if (!selector.endsWith("}")) return null;
54
+ const groupStart = findGroupStart(selector);
55
+ if (groupStart === -1) return null;
56
+ const prefix = selector.slice(0, groupStart);
57
+ const entries = splitOutside(selector.slice(groupStart + 2, -1), ";").map((entry) => entry.trim()).filter(Boolean).map((entry) => {
58
+ const parts = splitOnceOutside(entry, ":");
59
+ if (!parts) return null;
60
+ const [name, rawValue] = parts;
61
+ return {
62
+ name: name.trim(),
63
+ rawValue: rawValue.trim()
64
+ };
65
+ }).filter(Boolean);
66
+ if (!entries.length) return null;
67
+ return {
68
+ prefix,
69
+ entries
70
+ };
71
+ };
72
+ const splitOutside = (input, delimiter) => {
73
+ const results = [];
74
+ let current = "";
75
+ let braceDepth = 0;
76
+ let bracketDepth = 0;
77
+ for (const char of input) {
78
+ if (char === "{") braceDepth += 1;
79
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
80
+ if (char === "[") bracketDepth += 1;
81
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
82
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) {
83
+ if (current) results.push(current);
84
+ current = "";
85
+ continue;
86
+ }
87
+ current += char;
88
+ }
89
+ if (current) results.push(current);
90
+ return results;
91
+ };
92
+ const splitOnceOutside = (input, delimiter) => {
93
+ let braceDepth = 0;
94
+ let bracketDepth = 0;
95
+ for (let i = 0; i < input.length; i += 1) {
96
+ const char = input[i];
97
+ if (char === "{") braceDepth += 1;
98
+ if (char === "}") braceDepth = Math.max(0, braceDepth - 1);
99
+ if (char === "[") bracketDepth += 1;
100
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
101
+ if (char === delimiter && braceDepth === 0 && bracketDepth === 0) return [input.slice(0, i), input.slice(i + 1)];
102
+ }
103
+ return null;
104
+ };
105
+ const findGroupStart = (selector) => {
106
+ let bracketDepth = 0;
107
+ for (let i = 0; i < selector.length - 1; i += 1) {
108
+ const char = selector[i];
109
+ if (char === "[") bracketDepth += 1;
110
+ if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
111
+ if (bracketDepth === 0 && selector[i] === ":" && selector[i + 1] === "{") return i;
112
+ }
113
+ return -1;
114
+ };
115
+ const isArbitrarySelectorContext = (context) => context.startsWith("[") && context.endsWith("]");
116
+ const isContainerContext = (context) => context === "container" || context.startsWith("container ") || context.startsWith("container_");
117
+ const getContextSet = (options) => {
118
+ const contexts = getDefaultContexts();
119
+ const dictionary = getDictionary();
120
+ if (dictionary) for (const [name, entry] of dictionary.entries()) {
121
+ if (entry?.isCSSProp) continue;
122
+ contexts.add(name);
123
+ }
124
+ if (options?.additionalContexts) for (const context of options.additionalContexts) contexts.add(context);
125
+ return contexts;
126
+ };
127
+ const hasValidContexts = (contexts, options, contextSet) => {
128
+ if (options?.allowCustomContexts) return true;
129
+ return contexts.every((context) => isArbitrarySelectorContext(context) || contextSet.has(context) || contextSet.has("container") && isContainerContext(context));
130
+ };
131
+ const isValidBossToken = (token, options = {}) => {
132
+ if (!token) return false;
133
+ const contextSet = getContextSet(options);
134
+ const extraProps = options.additionalProps ? new Set(options.additionalProps) : null;
135
+ const singleProps = options.singleProps ? new Set(options.singleProps) : null;
136
+ const grouped = parseGroupedSelector(token);
137
+ if (grouped) {
138
+ if (!hasValidContexts(splitFragments(grouped.prefix), options, contextSet)) return false;
139
+ for (const entry of grouped.entries) {
140
+ if (!entry.name) return false;
141
+ if (!isCssPropName(entry.name, extraProps)) return false;
142
+ }
143
+ return true;
144
+ }
145
+ const fragments = splitFragments(token);
146
+ if (!fragments.length) return false;
147
+ let propIndex = -1;
148
+ for (let i = 0; i < fragments.length; i += 1) if (isCssPropName(fragments[i], extraProps)) {
149
+ propIndex = i;
150
+ break;
151
+ }
152
+ if (propIndex === -1) return false;
153
+ if (!hasValidContexts(fragments.slice(0, propIndex), options, contextSet)) return false;
154
+ if (!(propIndex < fragments.length - 1)) {
155
+ if (getDictionaryEntry(fragments[propIndex])?.single) return true;
156
+ if (!singleProps) return false;
157
+ if (!singleProps.has(fragments[propIndex])) return false;
158
+ }
159
+ return true;
160
+ };
161
+ const findInvalidTokens = (classList, options) => {
162
+ const tokens = splitClassList(classList);
163
+ const invalid = [];
164
+ for (const token of tokens) {
165
+ if (!token) continue;
166
+ if (!isValidBossToken(token, options)) invalid.push(token);
167
+ }
168
+ return invalid;
169
+ };
170
+ const containsBossToken = (classList, options) => {
171
+ return splitClassList(classList).some((token) => isValidBossToken(token, options));
172
+ };
173
+
174
+ //#endregion
175
+ export { containsBossToken, findInvalidTokens, getContextSet, getDictionary, getDictionaryEntry, isCssPropName, parseGroupedSelector, splitClassList, splitFragments };
@@ -0,0 +1,99 @@
1
+
2
+ //#region src/eslint-plugin/utils/defaults.js
3
+ const DEFAULT_ATTRIBUTE_PATTERNS = ["^class(?:Name)?$"];
4
+ const DEFAULT_CALLEE_PATTERNS = [
5
+ "^cx$",
6
+ "^merge$",
7
+ "^\\$\\$\\.cx$",
8
+ "^\\$\\$\\.merge$"
9
+ ];
10
+ const DEFAULT_VARIABLE_PATTERNS = ["^classNames?$", "^classes$"];
11
+ const DEFAULT_TAG_PATTERNS = [];
12
+ const DEFAULT_COMPONENTS = ["$$"];
13
+ const DEFAULT_BREAKPOINTS = {
14
+ micro: [null, 375],
15
+ mobile: [376, 639],
16
+ tablet: [640, 1023],
17
+ small: [1024, 1439],
18
+ medium: [1440, 1919],
19
+ large: [1920, null],
20
+ device: [null, 1023]
21
+ };
22
+ const DEFAULT_PSEUDO_CONTEXTS = [
23
+ "defined",
24
+ "any-link",
25
+ "link",
26
+ "visited",
27
+ "local-link",
28
+ "target",
29
+ "target-within",
30
+ "scope",
31
+ "hover",
32
+ "active",
33
+ "focus",
34
+ "focus-visible",
35
+ "focus-within",
36
+ "current",
37
+ "past",
38
+ "future",
39
+ "playing",
40
+ "paused",
41
+ "seeking",
42
+ "buffering",
43
+ "stalled",
44
+ "muted",
45
+ "volume-locked",
46
+ "open",
47
+ "closed",
48
+ "modal",
49
+ "fullscreen",
50
+ "picture-in-picture",
51
+ "enabled",
52
+ "disabled",
53
+ "read-write",
54
+ "read-only",
55
+ "placeholder-shown",
56
+ "autofill",
57
+ "default",
58
+ "checked",
59
+ "indeterminate",
60
+ "blank",
61
+ "valid",
62
+ "invalid",
63
+ "in-range",
64
+ "out-of-range",
65
+ "user-valid",
66
+ "root",
67
+ "empty",
68
+ "first-child",
69
+ "last-child",
70
+ "only-child",
71
+ "first-of-type",
72
+ "last-of-type",
73
+ "only-of-type",
74
+ "after",
75
+ "before"
76
+ ];
77
+ const getDefaultContexts = () => {
78
+ const contexts = new Set(DEFAULT_PSEUDO_CONTEXTS);
79
+ const breakpointNames = Object.keys(DEFAULT_BREAKPOINTS);
80
+ for (const name of breakpointNames) {
81
+ contexts.add(name);
82
+ contexts.add(`${name}+`);
83
+ contexts.add(`${name}-`);
84
+ }
85
+ contexts.add("at");
86
+ contexts.add("container");
87
+ contexts.add("dark");
88
+ contexts.add("light");
89
+ contexts.add("hdpi");
90
+ return contexts;
91
+ };
92
+
93
+ //#endregion
94
+ exports.DEFAULT_ATTRIBUTE_PATTERNS = DEFAULT_ATTRIBUTE_PATTERNS;
95
+ exports.DEFAULT_CALLEE_PATTERNS = DEFAULT_CALLEE_PATTERNS;
96
+ exports.DEFAULT_COMPONENTS = DEFAULT_COMPONENTS;
97
+ exports.DEFAULT_TAG_PATTERNS = DEFAULT_TAG_PATTERNS;
98
+ exports.DEFAULT_VARIABLE_PATTERNS = DEFAULT_VARIABLE_PATTERNS;
99
+ exports.getDefaultContexts = getDefaultContexts;