@antebudimir/eslint-plugin-vanilla-extract 1.4.0 → 1.4.6

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 (68) hide show
  1. package/README.md +7 -3
  2. package/dist/css-rules/alphabetical-order/__tests__/animation.test.js +108 -0
  3. package/dist/css-rules/alphabetical-order/__tests__/font-face.test.js +138 -0
  4. package/dist/css-rules/alphabetical-order/__tests__/global.test.js +51 -0
  5. package/dist/css-rules/alphabetical-order/__tests__/recipe.test.js +91 -0
  6. package/dist/css-rules/alphabetical-order/__tests__/style.test.d.ts +1 -0
  7. package/dist/css-rules/alphabetical-order/__tests__/style.test.js +108 -0
  8. package/dist/css-rules/alphabetical-order/__tests__/variants.test.d.ts +1 -0
  9. package/dist/css-rules/alphabetical-order/__tests__/variants.test.js +63 -0
  10. package/dist/css-rules/concentric-order/__tests__/animation.test.d.ts +1 -0
  11. package/dist/css-rules/concentric-order/__tests__/animation.test.js +69 -0
  12. package/dist/css-rules/concentric-order/__tests__/font-face.test.d.ts +1 -0
  13. package/dist/css-rules/concentric-order/__tests__/font-face.test.js +94 -0
  14. package/dist/css-rules/concentric-order/__tests__/global.test.d.ts +1 -0
  15. package/dist/css-rules/concentric-order/__tests__/global.test.js +57 -0
  16. package/dist/css-rules/concentric-order/__tests__/recipe.test.d.ts +1 -0
  17. package/dist/css-rules/concentric-order/__tests__/recipe.test.js +100 -0
  18. package/dist/css-rules/concentric-order/__tests__/style.test.d.ts +1 -0
  19. package/dist/css-rules/concentric-order/__tests__/style.test.js +126 -0
  20. package/dist/css-rules/concentric-order/__tests__/variants.test.d.ts +1 -0
  21. package/dist/css-rules/concentric-order/__tests__/variants.test.js +133 -0
  22. package/dist/css-rules/custom-order/__tests__/animation.test.d.ts +1 -0
  23. package/dist/css-rules/custom-order/__tests__/animation.test.js +148 -0
  24. package/dist/css-rules/custom-order/__tests__/font-face.test.d.ts +1 -0
  25. package/dist/css-rules/custom-order/__tests__/font-face.test.js +124 -0
  26. package/dist/css-rules/custom-order/__tests__/global.test.d.ts +1 -0
  27. package/dist/css-rules/custom-order/__tests__/global.test.js +124 -0
  28. package/dist/css-rules/custom-order/__tests__/recipe.test.d.ts +1 -0
  29. package/dist/css-rules/custom-order/__tests__/recipe.test.js +208 -0
  30. package/dist/css-rules/custom-order/__tests__/style.test.d.ts +1 -0
  31. package/dist/css-rules/custom-order/__tests__/style.test.js +249 -0
  32. package/dist/css-rules/custom-order/__tests__/variants.test.d.ts +1 -0
  33. package/dist/css-rules/custom-order/__tests__/variants.test.js +184 -0
  34. package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.d.ts +1 -0
  35. package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.js +37 -0
  36. package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.d.ts +1 -0
  37. package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.js +58 -0
  38. package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.d.ts +1 -0
  39. package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.js +125 -0
  40. package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.d.ts +1 -0
  41. package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.js +53 -0
  42. package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.d.ts +1 -0
  43. package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.js +116 -0
  44. package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.d.ts +1 -0
  45. package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.js +55 -0
  46. package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.d.ts +3 -0
  47. package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.js +30 -0
  48. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.d.ts +4 -3
  49. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.js +5 -4
  50. package/dist/css-rules/shared-utils/style-node-processor.js +2 -5
  51. package/dist/index.js +1 -1
  52. package/package.json +10 -3
  53. package/dist/css-rules/shared-utils/font-face-style-processor.d.ts +0 -10
  54. package/dist/css-rules/shared-utils/font-face-style-processor.js +0 -17
  55. package/dist/css-rules/theme-tokens/ast-helpers.d.ts +0 -12
  56. package/dist/css-rules/theme-tokens/ast-helpers.js +0 -80
  57. package/dist/css-rules/theme-tokens/index.d.ts +0 -2
  58. package/dist/css-rules/theme-tokens/index.js +0 -2
  59. package/dist/css-rules/theme-tokens/rule-definition.d.ts +0 -3
  60. package/dist/css-rules/theme-tokens/rule-definition.js +0 -29
  61. package/dist/css-rules/theme-tokens/theme-loader.d.ts +0 -10
  62. package/dist/css-rules/theme-tokens/theme-loader.js +0 -71
  63. package/dist/css-rules/theme-tokens/theme-token-visitor.d.ts +0 -2
  64. package/dist/css-rules/theme-tokens/theme-token-visitor.js +0 -113
  65. /package/dist/css-rules/{theme-tokens/theme-tokens-enforcer.d.ts → alphabetical-order/__tests__/animation.test.d.ts} +0 -0
  66. /package/dist/css-rules/{theme-tokens/theme-tokens-enforcer.js → alphabetical-order/__tests__/font-face.test.d.ts} +0 -0
  67. /package/dist/css-rules/{theme-tokens/value-comparison.d.ts → alphabetical-order/__tests__/global.test.d.ts} +0 -0
  68. /package/dist/css-rules/{theme-tokens/value-comparison.js → alphabetical-order/__tests__/recipe.test.d.ts} +0 -0
@@ -1,113 +0,0 @@
1
- // /* eslint-disable no-console */
2
- // import type { Rule } from 'eslint';
3
- // import { TSESTree } from '@typescript-eslint/utils';
4
- // import { isVanillaExtractStyleCall, findThemeTokenForValue } from './ast-helpers.js';
5
- // import { loadThemeTokens } from './theme-loader.js';
6
- import { TSESTree } from '@typescript-eslint/utils';
7
- import { createNodeVisitors } from '../shared-utils/order-strategy-visitor-creator.js';
8
- import { isVanillaExtractStyleCall, findThemeTokenForValue, findThemeTokenForPropertyValue, } from './ast-helpers.js';
9
- import { loadThemeTokens } from './theme-loader.js';
10
- /**
11
- * Helper to extract a static property name from a node’s key.
12
- */
13
- function getStaticPropertyKey(key) {
14
- if (key.type === 'Identifier') {
15
- return key.name;
16
- }
17
- if (key.type === 'Literal' && typeof key.value === 'string') {
18
- return key.value;
19
- }
20
- return null;
21
- }
22
- /**
23
- * Recursively traverse an AST node representing a style definition.
24
- */
25
- function traverseStyleNode(node, themeTokens, context, themeVarName, propertyContext) {
26
- switch (node.type) {
27
- case 'ObjectExpression':
28
- node.properties.forEach((prop) => {
29
- if (prop.type === 'Property') {
30
- const propKey = getStaticPropertyKey(prop.key);
31
- const newContext = propKey && !propKey.startsWith(':') && !propKey.startsWith('@') ? propKey : propertyContext;
32
- if (prop.value.type === 'Literal') {
33
- const value = prop.value.value;
34
- if (typeof value === 'string' || typeof value === 'number') {
35
- const matchingToken = newContext && themeTokens
36
- ? findThemeTokenForPropertyValue(newContext, value, themeTokens)
37
- : findThemeTokenForValue(value, themeTokens);
38
- if (matchingToken) {
39
- context.report({
40
- node: prop.value,
41
- messageId: 'preferThemeTokens',
42
- data: {
43
- token: matchingToken.token,
44
- value: String(value),
45
- },
46
- fix(fixer) {
47
- const tokenRef = `${themeVarName}.${matchingToken.token}`;
48
- return fixer.replaceText(prop.value, tokenRef);
49
- },
50
- });
51
- }
52
- }
53
- }
54
- else {
55
- traverseStyleNode(prop.value, themeTokens, context, themeVarName, newContext);
56
- }
57
- }
58
- });
59
- break;
60
- case 'ArrayExpression':
61
- node.elements.forEach((element) => {
62
- if (element) {
63
- traverseStyleNode(element, themeTokens, context, themeVarName, propertyContext);
64
- }
65
- });
66
- break;
67
- case 'ConditionalExpression':
68
- traverseStyleNode(node.consequent, themeTokens, context, themeVarName, propertyContext);
69
- traverseStyleNode(node.alternate, themeTokens, context, themeVarName, propertyContext);
70
- break;
71
- case 'LogicalExpression':
72
- traverseStyleNode(node.left, themeTokens, context, themeVarName, propertyContext);
73
- traverseStyleNode(node.right, themeTokens, context, themeVarName, propertyContext);
74
- break;
75
- default:
76
- break;
77
- }
78
- }
79
- export function createThemeTokenVisitor(context) {
80
- const options = context.options[0] || {};
81
- const themeImportPath = options.themeImportPath ?? './src/css-sample/themes/light-theme.css.ts';
82
- const themeVarName = options.themeVarName ?? 'theme';
83
- const orderingStrategy = options.orderingStrategy ?? 'alphabetical';
84
- const userDefinedGroupOrder = options.userDefinedGroupOrder;
85
- const sortRemainingProperties = options.sortRemainingProperties;
86
- let themeTokens = null;
87
- const nodeVisitors = createNodeVisitors(context, orderingStrategy, userDefinedGroupOrder, sortRemainingProperties);
88
- return {
89
- ...nodeVisitors,
90
- Program() {
91
- themeTokens = loadThemeTokens(themeImportPath);
92
- },
93
- CallExpression(node) {
94
- if (node.callee.type !== 'Identifier') {
95
- return;
96
- }
97
- if (isVanillaExtractStyleCall(node)) {
98
- const styleArg = node.arguments[0];
99
- if (styleArg) {
100
- traverseStyleNode(styleArg, themeTokens, context, themeVarName);
101
- }
102
- }
103
- if ((node.callee.name === 'globalKeyframes' || node.callee.name === 'globalStyle') &&
104
- node.arguments.length >= 2) {
105
- const styleArg = node.arguments[1];
106
- if (styleArg) {
107
- traverseStyleNode(styleArg, themeTokens, context, themeVarName);
108
- }
109
- }
110
- nodeVisitors.CallExpression?.(node);
111
- },
112
- };
113
- }