@tenphi/eslint-plugin-tasty 0.1.0 → 0.2.1

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 (114) hide show
  1. package/dist/{config.mjs → config.js} +3 -3
  2. package/dist/config.js.map +1 -0
  3. package/dist/{configs.d.mts → configs.d.ts} +1 -1
  4. package/dist/{configs.mjs → configs.js} +1 -1
  5. package/dist/configs.js.map +1 -0
  6. package/dist/{constants.mjs → constants.js} +1 -1
  7. package/dist/constants.js.map +1 -0
  8. package/dist/{context.mjs → context.js} +3 -3
  9. package/dist/context.js.map +1 -0
  10. package/dist/{create-rule.mjs → create-rule.js} +1 -1
  11. package/dist/create-rule.js.map +1 -0
  12. package/dist/{index.d.mts → index.d.ts} +3 -3
  13. package/dist/{index.mjs → index.js} +29 -29
  14. package/dist/index.js.map +1 -0
  15. package/dist/{parser.mjs → parser.js} +3 -3
  16. package/dist/parser.js.map +1 -0
  17. package/dist/{property-expectations.mjs → property-expectations.js} +1 -1
  18. package/dist/property-expectations.js.map +1 -0
  19. package/dist/rules/{consistent-token-usage.mjs → consistent-token-usage.js} +4 -4
  20. package/dist/rules/consistent-token-usage.js.map +1 -0
  21. package/dist/rules/{known-property.mjs → known-property.js} +5 -5
  22. package/dist/rules/known-property.js.map +1 -0
  23. package/dist/rules/{no-duplicate-state.mjs → no-duplicate-state.js} +4 -4
  24. package/dist/rules/no-duplicate-state.js.map +1 -0
  25. package/dist/rules/{no-important.mjs → no-important.js} +4 -4
  26. package/dist/rules/no-important.js.map +1 -0
  27. package/dist/rules/{no-nested-selector.mjs → no-nested-selector.js} +4 -4
  28. package/dist/rules/no-nested-selector.js.map +1 -0
  29. package/dist/rules/{no-nested-state-map.mjs → no-nested-state-map.js} +4 -4
  30. package/dist/rules/no-nested-state-map.js.map +1 -0
  31. package/dist/rules/{no-raw-color-values.mjs → no-raw-color-values.js} +4 -4
  32. package/dist/rules/no-raw-color-values.js.map +1 -0
  33. package/dist/rules/{no-runtime-styles-mutation.mjs → no-runtime-styles-mutation.js} +4 -4
  34. package/dist/rules/no-runtime-styles-mutation.js.map +1 -0
  35. package/dist/rules/{no-styles-prop.mjs → no-styles-prop.js} +2 -2
  36. package/dist/rules/no-styles-prop.js.map +1 -0
  37. package/dist/rules/{no-unknown-state-alias.mjs → no-unknown-state-alias.js} +4 -4
  38. package/dist/rules/no-unknown-state-alias.js.map +1 -0
  39. package/dist/rules/{prefer-shorthand-property.mjs → prefer-shorthand-property.js} +5 -5
  40. package/dist/rules/prefer-shorthand-property.js.map +1 -0
  41. package/dist/rules/{require-default-state.mjs → require-default-state.js} +4 -4
  42. package/dist/rules/require-default-state.js.map +1 -0
  43. package/dist/rules/{static-no-dynamic-values.mjs → static-no-dynamic-values.js} +4 -4
  44. package/dist/rules/static-no-dynamic-values.js.map +1 -0
  45. package/dist/rules/{static-valid-selector.mjs → static-valid-selector.js} +4 -4
  46. package/dist/rules/static-valid-selector.js.map +1 -0
  47. package/dist/rules/{valid-boolean-property.mjs → valid-boolean-property.js} +5 -5
  48. package/dist/rules/valid-boolean-property.js.map +1 -0
  49. package/dist/rules/{valid-color-token.mjs → valid-color-token.js} +4 -4
  50. package/dist/rules/valid-color-token.js.map +1 -0
  51. package/dist/rules/{valid-custom-property.mjs → valid-custom-property.js} +4 -4
  52. package/dist/rules/valid-custom-property.js.map +1 -0
  53. package/dist/rules/{valid-custom-unit.mjs → valid-custom-unit.js} +4 -4
  54. package/dist/rules/valid-custom-unit.js.map +1 -0
  55. package/dist/rules/{valid-directional-modifier.mjs → valid-directional-modifier.js} +5 -5
  56. package/dist/rules/valid-directional-modifier.js.map +1 -0
  57. package/dist/rules/{valid-preset.mjs → valid-preset.js} +5 -5
  58. package/dist/rules/valid-preset.js.map +1 -0
  59. package/dist/rules/{valid-radius-shape.mjs → valid-radius-shape.js} +5 -5
  60. package/dist/rules/valid-radius-shape.js.map +1 -0
  61. package/dist/rules/{valid-recipe.mjs → valid-recipe.js} +6 -6
  62. package/dist/rules/valid-recipe.js.map +1 -0
  63. package/dist/rules/valid-state-key.js +142 -0
  64. package/dist/rules/valid-state-key.js.map +1 -0
  65. package/dist/rules/{valid-styles-structure.mjs → valid-styles-structure.js} +4 -4
  66. package/dist/rules/valid-styles-structure.js.map +1 -0
  67. package/dist/rules/{valid-sub-element.mjs → valid-sub-element.js} +4 -4
  68. package/dist/rules/valid-sub-element.js.map +1 -0
  69. package/dist/rules/{valid-transition.mjs → valid-transition.js} +5 -5
  70. package/dist/rules/valid-transition.js.map +1 -0
  71. package/dist/rules/{valid-value.mjs → valid-value.js} +6 -6
  72. package/dist/rules/valid-value.js.map +1 -0
  73. package/dist/{types.d.mts → types.d.ts} +1 -1
  74. package/dist/{utils.mjs → utils.js} +3 -40
  75. package/dist/utils.js.map +1 -0
  76. package/package.json +17 -24
  77. package/dist/config.mjs.map +0 -1
  78. package/dist/configs.mjs.map +0 -1
  79. package/dist/constants.mjs.map +0 -1
  80. package/dist/context.mjs.map +0 -1
  81. package/dist/create-rule.mjs.map +0 -1
  82. package/dist/index.mjs.map +0 -1
  83. package/dist/parser.mjs.map +0 -1
  84. package/dist/property-expectations.mjs.map +0 -1
  85. package/dist/rules/consistent-token-usage.mjs.map +0 -1
  86. package/dist/rules/known-property.mjs.map +0 -1
  87. package/dist/rules/no-duplicate-state.mjs.map +0 -1
  88. package/dist/rules/no-important.mjs.map +0 -1
  89. package/dist/rules/no-nested-selector.mjs.map +0 -1
  90. package/dist/rules/no-nested-state-map.mjs.map +0 -1
  91. package/dist/rules/no-raw-color-values.mjs.map +0 -1
  92. package/dist/rules/no-runtime-styles-mutation.mjs.map +0 -1
  93. package/dist/rules/no-styles-prop.mjs.map +0 -1
  94. package/dist/rules/no-unknown-state-alias.mjs.map +0 -1
  95. package/dist/rules/prefer-shorthand-property.mjs.map +0 -1
  96. package/dist/rules/require-default-state.mjs.map +0 -1
  97. package/dist/rules/static-no-dynamic-values.mjs.map +0 -1
  98. package/dist/rules/static-valid-selector.mjs.map +0 -1
  99. package/dist/rules/valid-boolean-property.mjs.map +0 -1
  100. package/dist/rules/valid-color-token.mjs.map +0 -1
  101. package/dist/rules/valid-custom-property.mjs.map +0 -1
  102. package/dist/rules/valid-custom-unit.mjs.map +0 -1
  103. package/dist/rules/valid-directional-modifier.mjs.map +0 -1
  104. package/dist/rules/valid-preset.mjs.map +0 -1
  105. package/dist/rules/valid-radius-shape.mjs.map +0 -1
  106. package/dist/rules/valid-recipe.mjs.map +0 -1
  107. package/dist/rules/valid-state-key.mjs +0 -71
  108. package/dist/rules/valid-state-key.mjs.map +0 -1
  109. package/dist/rules/valid-styles-structure.mjs.map +0 -1
  110. package/dist/rules/valid-sub-element.mjs.map +0 -1
  111. package/dist/rules/valid-transition.mjs.map +0 -1
  112. package/dist/rules/valid-value.mjs.map +0 -1
  113. package/dist/utils.mjs.map +0 -1
  114. /package/dist/_virtual/_rolldown/{runtime.mjs → runtime.js} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"valid-radius-shape.mjs","names":[],"sources":["../../src/rules/valid-radius-shape.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName, getStringValue } from '../utils.js';\nimport { RADIUS_SHAPES } from '../constants.js';\n\ntype MessageIds = 'unknownShape';\n\nconst SHAPE_LIKE = /^[a-z]+$/;\n\nexport default createRule<[], MessageIds>({\n name: 'valid-radius-shape',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Validate special shape keywords used with the radius property',\n },\n messages: {\n unknownShape:\n \"Unknown radius shape '{{shape}}'. Valid shapes: {{valid}}.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n function checkRadiusValue(value: string, node: TSESTree.Node): void {\n const trimmed = value.trim();\n // Only check single-word values that look like keywords\n if (!SHAPE_LIKE.test(trimmed)) return;\n\n // Known valid keywords\n if (RADIUS_SHAPES.has(trimmed)) return;\n if (trimmed === 'true' || trimmed === 'false') return;\n if (trimmed === 'none' || trimmed === 'inherit' || trimmed === 'initial')\n return;\n\n // Check if it's a directional modifier (handled elsewhere)\n const directions = new Set([\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right',\n ]);\n if (directions.has(trimmed)) return;\n\n // It looks like they tried to use a shape keyword\n const suggestion = findClosestShape(trimmed);\n const validList = [...RADIUS_SHAPES].join(', ');\n\n context.report({\n node,\n messageId: 'unknownShape',\n data: {\n shape: trimmed,\n valid:\n validList + (suggestion ? `. Did you mean '${suggestion}'?` : ''),\n },\n });\n }\n\n function findClosestShape(input: string): string | null {\n for (const shape of RADIUS_SHAPES) {\n if (\n shape.startsWith(input.slice(0, 3)) ||\n input.startsWith(shape.slice(0, 3))\n ) {\n return shape;\n }\n }\n return null;\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key !== 'radius') continue;\n\n const str = getStringValue(prop.value);\n if (str) {\n checkRadiusValue(str, prop.value);\n continue;\n }\n\n if (prop.value.type === 'ObjectExpression') {\n for (const stateProp of prop.value.properties) {\n if (stateProp.type !== 'Property') continue;\n const stateStr = getStringValue(stateProp.value);\n if (stateStr) {\n checkRadiusValue(stateStr, stateProp.value);\n }\n }\n }\n }\n },\n };\n },\n});\n"],"mappings":";;;;;;AAQA,MAAM,aAAa;AAEnB,iCAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,iEACH;EACD,UAAU,EACR,cACE,8DACH;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;EAErC,S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MAAM;;;;GAMtD;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"valid-recipe.mjs","names":[],"sources":["../../src/rules/valid-recipe.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName, getStringValue } from '../utils.js';\n\ntype MessageIds = 'unknownRecipe';\n\nexport default createRule<[], MessageIds>({\n name: 'valid-recipe',\n meta: {\n type: 'problem',\n docs: {\n description: 'Validate recipe property values against config',\n },\n messages: {\n unknownRecipe: \"Unknown recipe '{{name}}'.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n function checkRecipeValue(value: string, node: TSESTree.Node): void {\n if (ctx.config.recipes.length === 0) return;\n\n // Split by | for pre/post merge separation\n const sections = value.split('|');\n for (const section of sections) {\n const names = section.trim().split(/\\s+/);\n for (const name of names) {\n if (name.length === 0) continue;\n if (!ctx.config.recipes.includes(name)) {\n context.report({\n node,\n messageId: 'unknownRecipe',\n data: { name },\n });\n }\n }\n }\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key !== 'recipe') continue;\n\n const str = getStringValue(prop.value);\n if (str) {\n checkRecipeValue(str, prop.value);\n }\n }\n },\n };\n },\n});\n"],"mappings":";;;;;AAOA,2BAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aAAa,kDACd;EACD,UAAU,EACR,eAAe,8BAChB;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;EAErC,SAAS,iBAAiB,OAAe,MAA2B;AAClE,OAAI,IAAI,OAAO,QAAQ,WAAW,EAAG;GAGrC,MAAM,WAAW,MAAM,MAAM,IAAI;AACjC,QAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,QAAQ,QAAQ,MAAM,CAAC,MAAM,MAAM;AACzC,SAAK,MAAM,QAAQ,OAAO;AACxB,SAAI,KAAK,WAAW,EAAG;AACvB,SAAI,CAAC,IAAI,OAAO,QAAQ,SAAS,KAAK,CACpC,SAAQ,OAAO;MACb;MACA,WAAW;MACX,MAAM,EAAE,MAAM;MACf,CAAC;;;;AAMV,SAAO;GACL,kBAAkB,MAAM;AACtB,QAAI,YAAY,KAAK;;GAGvB,kCAAkC,MAAiC;AACjE,QAAI,CAAC,IAAI,cAAc,KAAK,CAAE;AAE9B,SAAK,MAAM,QAAQ,KAAK,YAAY;AAClC,SAAI,KAAK,SAAS,cAAc,KAAK,SAAU;AAG/C,SADY,WAAW,KAAK,IAAI,KACpB,SAAU;KAEtB,MAAM,MAAM,eAAe,KAAK,MAAM;AACtC,SAAI,IACF,kBAAiB,KAAK,KAAK,MAAM;;;GAIxC;;CAEJ,CAAC"}
@@ -1,71 +0,0 @@
1
- import { createRule } from "../create-rule.mjs";
2
- import { TastyContext } from "../context.mjs";
3
- import { getKeyName, getStringValue, validateStateKey } from "../utils.mjs";
4
-
5
- //#region src/rules/valid-state-key.ts
6
- var valid_state_key_default = createRule({
7
- name: "valid-state-key",
8
- meta: {
9
- type: "problem",
10
- docs: { description: "Validate state key syntax in style mapping objects" },
11
- messages: {
12
- invalidStateKey: "{{reason}}",
13
- ownOutsideSubElement: "@own() can only be used inside sub-element styles."
14
- },
15
- schema: []
16
- },
17
- defaultOptions: [],
18
- create(context) {
19
- const ctx = new TastyContext(context);
20
- function isInsideSubElement(node) {
21
- let current = node.parent;
22
- while (current) {
23
- if (current.type === "Property" && !current.computed && current.key.type === "Identifier" && /^[A-Z]/.test(current.key.name)) return true;
24
- current = current.parent;
25
- }
26
- return false;
27
- }
28
- function checkStateMapKeys(obj, insideSubElement) {
29
- for (const prop of obj.properties) {
30
- if (prop.type !== "Property") continue;
31
- const key = !prop.computed ? getKeyName(prop.key) : getStringValue(prop.key);
32
- if (key === null) continue;
33
- const error = validateStateKey(key);
34
- if (error) {
35
- context.report({
36
- node: prop.key,
37
- messageId: "invalidStateKey",
38
- data: { reason: error }
39
- });
40
- continue;
41
- }
42
- if (key.includes("@own(") && !insideSubElement) context.report({
43
- node: prop.key,
44
- messageId: "ownOutsideSubElement"
45
- });
46
- }
47
- }
48
- return {
49
- ImportDeclaration(node) {
50
- ctx.trackImport(node);
51
- },
52
- "CallExpression ObjectExpression"(node) {
53
- if (!ctx.isStyleObject(node)) return;
54
- const insideSubElement = isInsideSubElement(node);
55
- for (const prop of node.properties) {
56
- if (prop.type !== "Property" || prop.computed) continue;
57
- const key = getKeyName(prop.key);
58
- if (key === null) continue;
59
- if (/^[A-Z]/.test(key) || key.startsWith("@") || key.startsWith("&")) continue;
60
- if (prop.value.type === "ObjectExpression") {
61
- if (!/^[A-Z]/.test(key)) checkStateMapKeys(prop.value, insideSubElement);
62
- }
63
- }
64
- }
65
- };
66
- }
67
- });
68
-
69
- //#endregion
70
- export { valid_state_key_default as default };
71
- //# sourceMappingURL=valid-state-key.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"valid-state-key.mjs","names":[],"sources":["../../src/rules/valid-state-key.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName, getStringValue, validateStateKey } from '../utils.js';\n\ntype MessageIds = 'invalidStateKey' | 'ownOutsideSubElement';\n\nexport default createRule<[], MessageIds>({\n name: 'valid-state-key',\n meta: {\n type: 'problem',\n docs: {\n description: 'Validate state key syntax in style mapping objects',\n },\n messages: {\n invalidStateKey: '{{reason}}',\n ownOutsideSubElement:\n '@own() can only be used inside sub-element styles.',\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n function isInsideSubElement(node: TSESTree.Node): boolean {\n let current: TSESTree.Node | undefined = node.parent;\n while (current) {\n if (\n current.type === 'Property' &&\n !current.computed &&\n current.key.type === 'Identifier' &&\n /^[A-Z]/.test(current.key.name)\n ) {\n return true;\n }\n current = current.parent;\n }\n return false;\n }\n\n function checkStateMapKeys(\n obj: TSESTree.ObjectExpression,\n insideSubElement: boolean,\n ): void {\n for (const prop of obj.properties) {\n if (prop.type !== 'Property') continue;\n\n const key = !prop.computed\n ? getKeyName(prop.key)\n : getStringValue(prop.key);\n if (key === null) continue;\n\n // Validate syntax\n const error = validateStateKey(key);\n if (error) {\n context.report({\n node: prop.key,\n messageId: 'invalidStateKey',\n data: { reason: error },\n });\n continue;\n }\n\n // Check @own() usage\n if (key.includes('@own(') && !insideSubElement) {\n context.report({\n node: prop.key,\n messageId: 'ownOutsideSubElement',\n });\n }\n }\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n const insideSubElement = isInsideSubElement(node);\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key === null) continue;\n\n // Skip non-style-property keys\n if (/^[A-Z]/.test(key) || key.startsWith('@') || key.startsWith('&'))\n continue;\n\n // If value is an object, check state map keys\n if (prop.value.type === 'ObjectExpression') {\n // Determine if this is actually a sub-element\n const isSubEl = /^[A-Z]/.test(key);\n if (!isSubEl) {\n checkStateMapKeys(prop.value, insideSubElement);\n }\n }\n }\n },\n };\n },\n});\n"],"mappings":";;;;;AAOA,8BAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aAAa,sDACd;EACD,UAAU;GACR,iBAAiB;GACjB,sBACE;GACH;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM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1
- {"version":3,"file":"valid-styles-structure.mjs","names":[],"sources":["../../src/rules/valid-styles-structure.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName, getStringValue } from '../utils.js';\n\ntype MessageIds =\n | 'stateKeyAtTopLevel'\n | 'invalidKeyframesStructure'\n | 'invalidPropertiesStructure'\n | 'recipeNotString';\n\nexport default createRule<[], MessageIds>({\n name: 'valid-styles-structure',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Validate overall structure of styles object passed to tasty APIs',\n },\n messages: {\n stateKeyAtTopLevel:\n \"State key '{{key}}' at top level is not valid. State maps belong inside property values, not at the root of the styles object.\",\n invalidKeyframesStructure:\n '@keyframes value must be an object of { name: { step: styles } }.',\n invalidPropertiesStructure:\n '@properties value must be an object of { name: { syntax, inherits, initialValue } }.',\n recipeNotString: \"'recipe' value must be a string.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n const STATE_KEY_PATTERNS = [\n /^:/, // pseudo-class\n /^\\./, // class selector\n /^\\[/, // attribute selector\n ];\n\n function looksLikeStateKey(key: string): boolean {\n if (key === '') return true;\n return STATE_KEY_PATTERNS.some((p) => p.test(key));\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key === null) continue;\n\n // Check for state keys at top level (common mistake)\n if (looksLikeStateKey(key)) {\n context.report({\n node: prop.key,\n messageId: 'stateKeyAtTopLevel',\n data: { key },\n });\n continue;\n }\n\n // Validate @keyframes structure\n if (key === '@keyframes') {\n if (prop.value.type !== 'ObjectExpression') {\n context.report({\n node: prop.value,\n messageId: 'invalidKeyframesStructure',\n });\n }\n continue;\n }\n\n // Validate @properties structure\n if (key === '@properties') {\n if (prop.value.type !== 'ObjectExpression') {\n context.report({\n node: prop.value,\n messageId: 'invalidPropertiesStructure',\n });\n }\n continue;\n }\n\n // Validate recipe is a string\n if (key === 'recipe') {\n const str = getStringValue(prop.value);\n if (str === null && prop.value.type !== 'Literal') {\n // Allow string literals, template literals without expressions\n if (\n prop.value.type !== 'TemplateLiteral' ||\n prop.value.expressions.length > 0\n ) {\n context.report({\n node: prop.value,\n messageId: 'recipeNotString',\n });\n }\n }\n }\n }\n },\n };\n },\n});\n"],"mappings":";;;;;AAWA,qCAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,oEACH;EACD,UAAU;GACR,oBACE;GACF,2BACE;GACF,4BACE;GACF,iBAAiB;GAClB;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;EAErC,MAAM,qBAAqB;GACzB;GACA;GACA;GACD;EAED,SAAS,kBAAkB,KAAsB;AAC/C,OAAI,QAAQ,GAAI,QAAO;AACvB,UAAO,mBAAmB,MAAM,MAAM,EAAE,KAAK,IAAI,CAAC;;AAGpD,SAAO;GACL,kBAAkB,MAAM;AACtB,QAAI,YAAY,KAAK;;GAGvB,kCAAkC,MAAiC;AACjE,QAAI,CAAC,IAAI,cAAc,KAAK,CAAE;AAE9B,SAAK,MAAM,QAAQ,KAAK,YAAY;AAClC,SAAI,KAAK,SAAS,cAAc,KAAK,SAAU;KAE/C,MAAM,MAAM,WAAW,KAAK,IAAI;AAChC,SAAI,QAAQ,KAAM;AAGlB,SAAI,kBAAkB,IAAI,EAAE;AAC1B,cAAQ,OAAO;OACb,MAAM,KAAK;OACX,WAAW;OACX,MAAM,EAAE,KAAK;OACd,CAAC;AACF;;AAIF,SAAI,QAAQ,cAAc;AACxB,UAAI,KAAK,MAAM,SAAS,mBACtB,SAAQ,OAAO;OACb,MAAM,KAAK;OACX,WAAW;OACZ,CAAC;AAEJ;;AAIF,SAAI,QAAQ,eAAe;AACzB,UAAI,KAAK,MAAM,SAAS,mBACtB,SAAQ,OAAO;OACb,MAAM,KAAK;OACX,WAAW;OACZ,CAAC;AAEJ;;AAIF,SAAI,QAAQ,UAEV;UADY,eAAe,KAAK,MAAM,KAC1B,QAAQ,KAAK,MAAM,SAAS,WAEtC;WACE,KAAK,MAAM,SAAS,qBACpB,KAAK,MAAM,YAAY,SAAS,EAEhC,SAAQ,OAAO;QACb,MAAM,KAAK;QACX,WAAW;QACZ,CAAC;;;;;GAMb;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"valid-sub-element.mjs","names":[],"sources":["../../src/rules/valid-sub-element.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName } from '../utils.js';\n\ntype MessageIds = 'subElementNotObject';\n\nexport default createRule<[], MessageIds>({\n name: 'valid-sub-element',\n meta: {\n type: 'problem',\n docs: {\n description: 'Validate sub-element key format in style objects',\n },\n messages: {\n subElementNotObject:\n \"Sub-element '{{name}}' value must be a style object, not a {{type}}.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key === null || !/^[A-Z]/.test(key)) continue;\n\n if (prop.value.type !== 'ObjectExpression') {\n const valueType =\n prop.value.type === 'Literal'\n ? typeof prop.value.value\n : prop.value.type;\n\n context.report({\n node: prop.value,\n messageId: 'subElementNotObject',\n data: { name: key, type: valueType },\n });\n }\n }\n },\n };\n },\n});\n"],"mappings":";;;;;AAOA,gCAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aAAa,oDACd;EACD,UAAU,EACR,qBACE,wEACH;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;AAErC,SAAO;GACL,kBAAkB,MAAM;AACtB,QAAI,YAAY,KAAK;;GAGvB,kCAAkC,MAAiC;AACjE,QAAI,CAAC,IAAI,cAAc,KAAK,CAAE;AAE9B,SAAK,MAAM,QAAQ,KAAK,YAAY;AAClC,SAAI,KAAK,SAAS,cAAc,KAAK,SAAU;KAE/C,MAAM,MAAM,WAAW,KAAK,IAAI;AAChC,SAAI,QAAQ,QAAQ,CAAC,SAAS,KAAK,IAAI,CAAE;AAEzC,SAAI,KAAK,MAAM,SAAS,oBAAoB;MAC1C,MAAM,YACJ,KAAK,MAAM,SAAS,YAChB,OAAO,KAAK,MAAM,QAClB,KAAK,MAAM;AAEjB,cAAQ,OAAO;OACb,MAAM,KAAK;OACX,WAAW;OACX,MAAM;QAAE,MAAM;QAAK,MAAM;QAAW;OACrC,CAAC;;;;GAIT;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"valid-transition.mjs","names":[],"sources":["../../src/rules/valid-transition.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName, getStringValue } from '../utils.js';\nimport { SEMANTIC_TRANSITIONS, KNOWN_CSS_PROPERTIES } from '../constants.js';\n\ntype MessageIds = 'unknownTransition';\n\nexport default createRule<[], MessageIds>({\n name: 'valid-transition',\n meta: {\n type: 'suggestion',\n docs: {\n description:\n 'Validate transition property values use valid semantic transition names',\n },\n messages: {\n unknownTransition:\n \"Unknown transition name '{{name}}'. Use a semantic name ({{known}}) or a CSS property name.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n function checkTransitionValue(value: string, node: TSESTree.Node): void {\n const groups = value.split(',');\n\n for (const group of groups) {\n const parts = group.trim().split(/\\s+/);\n if (parts.length === 0) continue;\n\n const name = parts[0];\n\n // $$ prefix is always valid (custom property reference)\n if (name.startsWith('$$')) continue;\n\n if (\n !SEMANTIC_TRANSITIONS.has(name) &&\n !KNOWN_CSS_PROPERTIES.has(name) &&\n name !== 'all' &&\n name !== 'none'\n ) {\n context.report({\n node,\n messageId: 'unknownTransition',\n data: {\n name,\n known: [...SEMANTIC_TRANSITIONS].join(', '),\n },\n });\n }\n }\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.computed) continue;\n\n const key = getKeyName(prop.key);\n if (key !== 'transition') continue;\n\n const str = getStringValue(prop.value);\n if (str) {\n checkTransitionValue(str, prop.value);\n continue;\n }\n\n if (prop.value.type === 'ObjectExpression') {\n for (const stateProp of prop.value.properties) {\n if (stateProp.type !== 'Property') continue;\n const stateStr = getStringValue(stateProp.value);\n if (stateStr) {\n checkTransitionValue(stateStr, stateProp.value);\n }\n }\n }\n }\n },\n };\n },\n});\n"],"mappings":";;;;;;AAQA,+BAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,2EACH;EACD,UAAU,EACR,mBACE,+FACH;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;EAErC,SAAS,qBAAqB,OAAe,MAA2B;GACtE,MAAM,SAAS,MAAM,MAAM,IAAI;AAE/B,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,QAAQ,MAAM,MAAM,CAAC,MAAM,MAAM;AACvC,QAAI,MAAM,WAAW,EAAG;IAExB,MAAM,OAAO,MAAM;AAGnB,QAAI,KAAK,WAAW,KAAK,CAAE;AAE3B,QACE,CAAC,qBAAqB,IAAI,KAAK,IAC/B,CAAC,qBAAqB,IAAI,KAAK,IAC/B,SAAS,SACT,SAAS,OAET,SAAQ,OAAO;KACb;KACA,WAAW;KACX,MAAM;MACJ;MACA,OAAO,CAAC,GAAG,qBAAqB,CAAC,KAAK,KAAK;MAC5C;KACF,CAAC;;;AAKR,SAAO;GACL,kBAAkB,MAAM;AACtB,QAAI,YAAY,KAAK;;GAGvB,kCAAkC,MAAiC;AACjE,QAAI,CAAC,IAAI,cAAc,KAAK,CAAE;AAE9B,SAAK,MAAM,QAAQ,KAAK,YAAY;AAClC,SAAI,KAAK,SAAS,cAAc,KAAK,SAAU;AAG/C,SADY,WAAW,KAAK,IAAI,KACpB,aAAc;KAE1B,MAAM,MAAM,eAAe,KAAK,MAAM;AACtC,SAAI,KAAK;AACP,2BAAqB,KAAK,KAAK,MAAM;AACrC;;AAGF,SAAI,KAAK,MAAM,SAAS,mBACtB,MAAK,MAAM,aAAa,KAAK,MAAM,YAAY;AAC7C,UAAI,UAAU,SAAS,WAAY;MACnC,MAAM,WAAW,eAAe,UAAU,MAAM;AAChD,UAAI,SACF,sBAAqB,UAAU,UAAU,MAAM;;;;GAM1D;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"valid-value.mjs","names":[],"sources":["../../src/rules/valid-value.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { createRule } from '../create-rule.js';\nimport { TastyContext } from '../context.js';\nimport { getKeyName, getStringValue } from '../utils.js';\nimport { getParser } from '../parser.js';\nimport { getExpectation } from '../property-expectations.js';\n\ntype MessageIds =\n | 'unbalancedParens'\n | 'importantNotAllowed'\n | 'unexpectedMod'\n | 'unexpectedColor'\n | 'invalidMod';\n\nexport default createRule<[], MessageIds>({\n name: 'valid-value',\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Parse style values through the tasty parser and validate against per-property expectations',\n },\n messages: {\n unbalancedParens: 'Unbalanced parentheses in value.',\n importantNotAllowed:\n 'Do not use !important in tasty styles. Use state specificity instead.',\n unexpectedMod:\n \"Unrecognized token '{{mod}}' in '{{property}}' value. This may be a typo.\",\n unexpectedColor:\n \"Property '{{property}}' does not accept color tokens, but found '{{color}}'.\",\n invalidMod:\n \"Modifier '{{mod}}' is not valid for '{{property}}'. Accepted: {{accepted}}.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n const ctx = new TastyContext(context);\n\n function checkParenBalance(value: string, node: TSESTree.Node): boolean {\n let depth = 0;\n for (const char of value) {\n if (char === '(') depth++;\n if (char === ')') depth--;\n if (depth < 0) {\n context.report({ node, messageId: 'unbalancedParens' });\n return false;\n }\n }\n if (depth !== 0) {\n context.report({ node, messageId: 'unbalancedParens' });\n return false;\n }\n return true;\n }\n\n function checkValue(\n value: string,\n property: string | null,\n node: TSESTree.Node,\n ): void {\n if (!checkParenBalance(value, node)) return;\n\n if (value.includes('!important')) {\n context.report({ node, messageId: 'importantNotAllowed' });\n return;\n }\n\n if (!property) return;\n\n const parser = getParser(ctx.config);\n const result = parser.process(value);\n const expectation = getExpectation(property);\n\n for (const group of result.groups) {\n if (!expectation.acceptsColor && group.colors.length > 0) {\n for (const color of group.colors) {\n context.report({\n node,\n messageId: 'unexpectedColor',\n data: { property, color },\n });\n }\n }\n\n if (expectation.acceptsMods === false && group.mods.length > 0) {\n for (const mod of group.mods) {\n context.report({\n node,\n messageId: 'unexpectedMod',\n data: { property, mod },\n });\n }\n } else if (\n Array.isArray(expectation.acceptsMods) &&\n group.mods.length > 0\n ) {\n const allowed = new Set(expectation.acceptsMods);\n for (const mod of group.mods) {\n if (!allowed.has(mod)) {\n context.report({\n node,\n messageId: 'invalidMod',\n data: {\n property,\n mod,\n accepted: expectation.acceptsMods.join(', '),\n },\n });\n }\n }\n }\n }\n }\n\n function processProperty(prop: TSESTree.Property): void {\n const key = !prop.computed ? getKeyName(prop.key) : null;\n\n if (key && (/^[A-Z]/.test(key) || key.startsWith('@'))) return;\n if (key && (key.startsWith('$') || key.startsWith('#'))) return;\n if (key && key.startsWith('&')) return;\n\n const str = getStringValue(prop.value);\n if (str) {\n checkValue(str, key, prop.value);\n return;\n }\n\n // State map\n if (prop.value.type === 'ObjectExpression') {\n for (const stateProp of prop.value.properties) {\n if (stateProp.type !== 'Property') continue;\n const stateStr = getStringValue(stateProp.value);\n if (stateStr) {\n checkValue(stateStr, key, stateProp.value);\n }\n }\n }\n }\n\n return {\n ImportDeclaration(node) {\n ctx.trackImport(node);\n },\n\n 'CallExpression ObjectExpression'(node: TSESTree.ObjectExpression) {\n if (!ctx.isStyleObject(node)) return;\n\n for (const prop of node.properties) {\n if (prop.type !== 'Property') continue;\n processProperty(prop);\n }\n },\n };\n },\n});\n"],"mappings":";;;;;;;AAcA,0BAAe,WAA2B;CACxC,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,8FACH;EACD,UAAU;GACR,kBAAkB;GAClB,qBACE;GACF,eACE;GACF,iBACE;GACF,YACE;GACH;EACD,QAAQ,EAAE;EACX;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACd,MAAM,MAAM,IAAI,aAAa,QAAQ;EAErC,SAAS,kBAAkB,OAAe,MAA8B;GACtE,IAAI,QAAQ;AACZ,QAAK,MAAM,QAAQ,OAAO;AACxB,QAAI,SAAS,IAAK;AAClB,QAAI,SAAS,IAAK;AAClB,QAAI,QAAQ,GAAG;AACb,aAAQ,OAAO;MAAE;MAAM,WAAW;MAAoB,CAAC;AACvD,YAAO;;;AAGX,OAAI,UAAU,GAAG;AACf,YAAQ,OAAO;KAAE;KAAM,WAAW;KAAoB,CAAC;AACvD,WAAO;;AAET,UAAO;;EAGT,SAAS,WACP,OACA,UACA,MACM;AACN,OAAI,CAAC,kBAAkB,OAAO,KAAK,CAAE;AAErC,OAAI,MAAM,SAAS,aAAa,EAAE;AAChC,YAAQ,OAAO;KAAE;KAAM,WAAW;KAAu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ACnC,MAAM,WAAW,eAAe,UAAU,MAAM;AAChD,QAAI,SACF,YAAW,UAAU,KAAK,UAAU,MAAM;;;AAMlD,SAAO;GACL,kBAAkB,MAAM;AACtB,QAAI,YAAY,KAAK;;GAGvB,kCAAkC,MAAiC;AACjE,QAAI,CAAC,IAAI,cAAc,KAAK,CAAE;AAE9B,SAAK,MAAM,QAAQ,KAAK,YAAY;AAClC,SAAI,KAAK,SAAS,WAAY;AAC9B,qBAAgB,KAAK;;;GAG1B;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport {\n BUILT_IN_UNITS,\n CSS_UNITS,\n BUILT_IN_STATE_PREFIXES,\n} from './constants.js';\nimport type { ResolvedConfig } from './types.js';\n\n/**\n * Gets the string value of a property key node.\n */\nexport function getKeyName(key: TSESTree.Node): string | null {\n if (key.type === 'Identifier') return key.name;\n if (key.type === 'Literal' && typeof key.value === 'string') return key.value;\n if (key.type === 'Literal' && typeof key.value === 'number')\n return String(key.value);\n return null;\n}\n\n/**\n * Gets the string value of a node if it is a string literal.\n */\nexport function getStringValue(node: TSESTree.Node): string | null {\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n if (node.type === 'TemplateLiteral' && node.expressions.length === 0) {\n return node.quasis[0].value.cooked ?? null;\n }\n return null;\n}\n\n/**\n * Checks if a value node is a static literal.\n */\nexport function isStaticValue(node: TSESTree.Node): boolean {\n if (node.type === 'Literal') return true;\n if (\n node.type === 'UnaryExpression' &&\n node.operator === '-' &&\n node.argument.type === 'Literal'\n ) {\n return true;\n }\n if (node.type === 'TemplateLiteral' && node.expressions.length === 0) {\n return true;\n }\n if (node.type === 'ArrayExpression') {\n return node.elements.every((el) => el !== null && isStaticValue(el));\n }\n if (node.type === 'ObjectExpression') {\n return node.properties.every(\n (prop) =>\n prop.type === 'Property' && !prop.computed && isStaticValue(prop.value),\n );\n }\n return false;\n}\n\n/**\n * Validates color token syntax.\n * Returns null if valid, or an error message if invalid.\n */\nexport function validateColorTokenSyntax(token: string): string | null {\n // Strip leading # or ##\n let name = token;\n if (name.startsWith('##')) {\n name = name.slice(2);\n } else if (name.startsWith('#')) {\n name = name.slice(1);\n } else {\n return 'Color token must start with #';\n }\n\n if (name.length === 0) return 'Empty color token name';\n\n // Check for opacity suffix\n const dotIndex = name.indexOf('.');\n if (dotIndex !== -1) {\n const tokenName = name.slice(0, dotIndex);\n const opacitySuffix = name.slice(dotIndex + 1);\n\n if (tokenName.length === 0) return 'Empty color token name before opacity';\n\n if (opacitySuffix.startsWith('$')) {\n // Dynamic opacity from CSS custom property — always valid\n return null;\n }\n\n if (opacitySuffix.length === 0) return 'Trailing dot with no opacity value';\n\n const opacity = Number(opacitySuffix);\n if (isNaN(opacity)) return `Invalid opacity value '${opacitySuffix}'`;\n if (opacity < 0) return 'Opacity cannot be negative';\n if (opacity > 100) return `Opacity '${opacitySuffix}' exceeds 100`;\n }\n\n return null;\n}\n\n/**\n * Checks if a string looks like a raw hex color (not a token).\n * Hex colors: #fff, #ffff, #ffffff, #ffffffff (3, 4, 6, or 8 hex chars).\n */\nexport function isRawHexColor(value: string): boolean {\n if (!value.startsWith('#')) return false;\n const hex = value.slice(1).split('.')[0];\n if (![3, 4, 6, 8].includes(hex.length)) return false;\n return /^[0-9a-fA-F]+$/.test(hex);\n}\n\n/**\n * Extracts custom unit from a value token like \"2x\", \"1.5r\", \"3cols\".\n * Returns the unit name, or null if not a custom-unit value.\n */\nexport function extractCustomUnit(token: string): string | null {\n const match = token.match(/^-?[\\d.]+([a-zA-Z]+)$/);\n if (!match) return null;\n return match[1];\n}\n\n/**\n * Checks if a unit is valid (built-in, CSS, or in config).\n */\nexport function isValidUnit(unit: string, config: ResolvedConfig): boolean {\n if (config.units === false) return true;\n if (BUILT_IN_UNITS.has(unit)) return true;\n if (CSS_UNITS.has(unit)) return true;\n if (Array.isArray(config.units) && config.units.includes(unit)) return true;\n return false;\n}\n\n/**\n * Validates a state key string.\n * Returns null if valid, or an error message if invalid.\n */\nexport function validateStateKey(key: string): string | null {\n if (key === '') return null; // Default state\n\n // Pseudo-class/element\n if (key.startsWith(':') || key.startsWith('::')) return null;\n\n // Class selector\n if (key.startsWith('.')) {\n if (key.length <= 1) return 'Empty class selector';\n return null;\n }\n\n // Attribute selector\n if (key.startsWith('[') && key.endsWith(']')) return null;\n\n // @ prefixed — check for built-in or alias\n if (key.startsWith('@')) {\n // Built-in functional state prefix: @media(...), @root(...), etc.\n for (const prefix of BUILT_IN_STATE_PREFIXES) {\n if (key === prefix || key.startsWith(prefix + '(')) return null;\n }\n // Container query shorthand: @(...)\n if (key.startsWith('@(')) return null;\n // Otherwise it's an alias — validated elsewhere\n return null;\n }\n\n // Combined expressions with operators\n if (key.includes('&') || key.includes('|') || key.includes('^')) {\n return validateCombinedStateKey(key);\n }\n\n // Negation\n if (key.startsWith('!')) {\n if (key.length <= 1) return 'Empty negated state';\n return null;\n }\n\n // Parenthesized group\n if (key.startsWith('(') && key.endsWith(')')) return null;\n\n // Boolean modifier: simple identifier like 'hovered'\n if (/^[a-zA-Z][a-zA-Z0-9-]*$/.test(key)) return null;\n\n // Value modifier: name=value or name^=value etc.\n if (/^[a-zA-Z][a-zA-Z0-9-]*[\\^$*]?=/.test(key)) return null;\n\n return `Invalid state key syntax '${key}'`;\n}\n\nfunction validateCombinedStateKey(key: string): string | null {\n // Split by & and | operators, validate each part\n const parts = key.split(/\\s*[&|^]\\s*/);\n for (const part of parts) {\n const trimmed = part.trim();\n if (trimmed.length === 0) return 'Empty part in combined state expression';\n // Each part should be a valid individual state\n const partError = validateStateKey(\n trimmed.startsWith('!') ? trimmed : trimmed,\n );\n if (partError) return partError;\n }\n return null;\n}\n\n/**\n * Checks if a state alias key (starting with @) is known.\n */\nexport function isKnownStateAlias(\n key: string,\n config: ResolvedConfig,\n): boolean {\n // Built-in prefixes\n for (const prefix of BUILT_IN_STATE_PREFIXES) {\n if (key === prefix || key.startsWith(prefix + '(')) return true;\n }\n // Container query shorthand\n if (key.startsWith('@(')) return true;\n // Config aliases\n return config.states.includes(key);\n}\n\n/**\n * Checks if a CSS selector string is basically valid.\n */\nexport function isValidSelector(selector: string): string | null {\n if (selector.length === 0) return 'Selector cannot be empty';\n\n // Check balanced brackets\n let depth = 0;\n for (const char of selector) {\n if (char === '(' || char === '[') depth++;\n if (char === ')' || char === ']') depth--;\n if (depth < 0) return 'Unbalanced brackets in selector';\n }\n if (depth !== 0) return 'Unbalanced brackets in selector';\n\n return null;\n}\n\n/**\n * Finds a property by key name in an object expression.\n */\nexport function findProperty(\n obj: TSESTree.ObjectExpression,\n name: string,\n): TSESTree.Property | undefined {\n for (const prop of obj.properties) {\n if (prop.type === 'Property' && !prop.computed) {\n const keyName = getKeyName(prop.key);\n if (keyName === name) return prop;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;AAWA,SAAgB,WAAW,KAAmC;AAC5D,KAAI,IAAI,SAAS,aAAc,QAAO,IAAI;AAC1C,KAAI,IAAI,SAAS,aAAa,OAAO,IAAI,UAAU,SAAU,QAAO,IAAI;AACxE,KAAI,IAAI,SAAS,aAAa,OAAO,IAAI,UAAU,SACjD,QAAO,OAAO,IAAI,MAAM;AAC1B,QAAO;;;;;AAMT,SAAgB,eAAe,MAAoC;AACjE,KAAI,KAAK,SAAS,aAAa,OAAO,KAAK,UAAU,SACnD,QAAO,KAAK;AAEd,KAAI,KAAK,SAAS,qBAAqB,KAAK,YAAY,WAAW,EACjE,QAAO,KAAK,OAAO,GAAG,MAAM,UAAU;AAExC,QAAO;;;;;AAMT,SAAgB,cAAc,MAA8B;AAC1D,KAAI,KAAK,SAAS,UAAW,QAAO;AACpC,KACE,KAAK,SAAS,qBACd,KAAK,aAAa,OAClB,KAAK,SAAS,SAAS,UAEvB,QAAO;AAET,KAAI,KAAK,SAAS,qBAAqB,KAAK,YAAY,WAAW,EACjE,QAAO;AAET,KAAI,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