@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
@@ -0,0 +1,124 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import customGroupOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/custom-order/font-face',
6
+ rule: customGroupOrderRule,
7
+ configs: {
8
+ languageOptions: {
9
+ parser: tsParser,
10
+ parserOptions: {
11
+ ecmaVersion: 2022,
12
+ sourceType: 'module',
13
+ },
14
+ },
15
+ },
16
+ valid: [
17
+ // fontFace
18
+ {
19
+ code: `
20
+ import { fontFace } from '@vanilla-extract/css';
21
+
22
+ const myFont = fontFace({
23
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
24
+ ascentOverride: '90%',
25
+ descentOverride: '10%',
26
+ fontDisplay: 'swap',
27
+ fontFeatureSettings: '"liga" 1',
28
+ fontStretch: 'normal',
29
+ fontStyle: 'normal',
30
+ fontVariant: 'normal',
31
+ fontWeight: '400'
32
+ });
33
+ `,
34
+ options: [
35
+ {
36
+ groupOrder: ['dimensions', 'margin', 'font'],
37
+ sortRemainingProperties: 'concentric',
38
+ },
39
+ ],
40
+ },
41
+ // globalFontFace
42
+ {
43
+ code: `
44
+ import { globalFontFace } from '@vanilla-extract/css';
45
+
46
+ globalFontFace('GlobalFont', {
47
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
48
+ ascentOverride: '90%',
49
+ descentOverride: '10%',
50
+ fontDisplay: 'swap',
51
+ fontFeatureSettings: '"liga" 1',
52
+ fontStretch: 'normal',
53
+ fontStyle: 'normal',
54
+ fontVariant: 'normal',
55
+ fontWeight: '400'
56
+ });
57
+ `,
58
+ options: [
59
+ {
60
+ groupOrder: ['dimensions', 'margin', 'font'],
61
+ sortRemainingProperties: 'concentric',
62
+ },
63
+ ],
64
+ },
65
+ ],
66
+ invalid: [
67
+ // fontFace with src not first
68
+ {
69
+ code: `
70
+ import { fontFace } from '@vanilla-extract/css';
71
+ const myFont = fontFace({
72
+ fontWeight: '400',
73
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
74
+ ascentOverride: '90%',
75
+ fontStyle: 'normal'
76
+ });
77
+ `,
78
+ options: [
79
+ {
80
+ groupOrder: ['dimensions', 'margin', 'font'],
81
+ sortRemainingProperties: 'concentric',
82
+ },
83
+ ],
84
+ errors: [{ messageId: 'fontFaceOrder' }],
85
+ output: `
86
+ import { fontFace } from '@vanilla-extract/css';
87
+ const myFont = fontFace({
88
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
89
+ ascentOverride: '90%',
90
+ fontStyle: 'normal',
91
+ fontWeight: '400'
92
+ });
93
+ `,
94
+ },
95
+ // globalFontFace with src not first
96
+ {
97
+ code: `
98
+ import { globalFontFace } from '@vanilla-extract/css';
99
+ globalFontFace('GlobalFont', {
100
+ fontWeight: '400',
101
+ fontStyle: 'normal',
102
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
103
+ ascentOverride: '90%'
104
+ });
105
+ `,
106
+ options: [
107
+ {
108
+ groupOrder: ['dimensions', 'margin', 'font'],
109
+ sortRemainingProperties: 'concentric',
110
+ },
111
+ ],
112
+ errors: [{ messageId: 'fontFaceOrder' }],
113
+ output: `
114
+ import { globalFontFace } from '@vanilla-extract/css';
115
+ globalFontFace('GlobalFont', {
116
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
117
+ ascentOverride: '90%',
118
+ fontStyle: 'normal',
119
+ fontWeight: '400'
120
+ });
121
+ `,
122
+ },
123
+ ],
124
+ });
@@ -0,0 +1,124 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import customGroupOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/custom-order/global',
6
+ rule: customGroupOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // globalStyle with custom group ordering (concentric for remaining)
16
+ {
17
+ code: `
18
+ import { globalStyle } from '@vanilla-extract/css';
19
+
20
+ globalStyle('body', {
21
+ margin: 0,
22
+ position: 'relative',
23
+ display: 'block',
24
+ backgroundColor: 'white',
25
+ padding: 0,
26
+ color: 'black'
27
+ });
28
+ `,
29
+ options: [
30
+ {
31
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
32
+ sortRemainingProperties: 'concentric',
33
+ },
34
+ ],
35
+ },
36
+ // globalStyle with custom group ordering (alphabetical for remaining)
37
+ {
38
+ code: `
39
+ import { globalStyle } from '@vanilla-extract/css';
40
+
41
+ globalStyle('body', {
42
+ margin: 0,
43
+ backgroundColor: 'white',
44
+ color: 'black',
45
+ display: 'block',
46
+ padding: 0,
47
+ position: 'relative'
48
+ });
49
+ `,
50
+ options: [
51
+ {
52
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
53
+ sortRemainingProperties: 'alphabetical',
54
+ },
55
+ ],
56
+ },
57
+ ],
58
+ invalid: [
59
+ // globalStyle with incorrect ordering (concentric for remaining)
60
+ {
61
+ code: `
62
+ import { globalStyle } from '@vanilla-extract/css';
63
+ globalStyle('body', {
64
+ color: 'black',
65
+ margin: 0,
66
+ backgroundColor: 'white',
67
+ padding: 0,
68
+ display: 'block',
69
+ position: 'relative'
70
+ });
71
+ `,
72
+ options: [
73
+ {
74
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
75
+ sortRemainingProperties: 'concentric',
76
+ },
77
+ ],
78
+ errors: [{ messageId: 'incorrectOrder' }],
79
+ output: `
80
+ import { globalStyle } from '@vanilla-extract/css';
81
+ globalStyle('body', {
82
+ margin: 0,
83
+ position: 'relative',
84
+ display: 'block',
85
+ backgroundColor: 'white',
86
+ padding: 0,
87
+ color: 'black'
88
+ });
89
+ `,
90
+ },
91
+ // globalStyle with incorrect ordering (alphabetical for remaining)
92
+ {
93
+ code: `
94
+ import { globalStyle } from '@vanilla-extract/css';
95
+ globalStyle('body', {
96
+ position: 'relative',
97
+ display: 'block',
98
+ margin: 0,
99
+ backgroundColor: 'white',
100
+ padding: 0,
101
+ color: 'black'
102
+ });
103
+ `,
104
+ options: [
105
+ {
106
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
107
+ sortRemainingProperties: 'alphabetical',
108
+ },
109
+ ],
110
+ errors: [{ messageId: 'incorrectOrder' }],
111
+ output: `
112
+ import { globalStyle } from '@vanilla-extract/css';
113
+ globalStyle('body', {
114
+ margin: 0,
115
+ backgroundColor: 'white',
116
+ color: 'black',
117
+ display: 'block',
118
+ padding: 0,
119
+ position: 'relative'
120
+ });
121
+ `,
122
+ },
123
+ ],
124
+ });
@@ -0,0 +1,208 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import customGroupOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/custom-order/recipe',
6
+ rule: customGroupOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // Recipe with custom group ordering (concentric for remaining)
16
+ {
17
+ code: `
18
+ import { recipe } from '@vanilla-extract/recipes';
19
+
20
+ const myRecipe = recipe({
21
+ base: {
22
+ width: '100%',
23
+ margin: 0,
24
+ position: 'relative',
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ backgroundColor: 'white'
28
+ },
29
+ variants: {
30
+ color: {
31
+ blue: {
32
+ position: 'relative',
33
+ backgroundColor: 'blue',
34
+ color: 'white'
35
+ },
36
+ red: {
37
+ position: 'relative',
38
+ backgroundColor: 'red',
39
+ color: 'black'
40
+ }
41
+ }
42
+ }
43
+ });
44
+ `,
45
+ options: [
46
+ {
47
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
48
+ sortRemainingProperties: 'concentric',
49
+ },
50
+ ],
51
+ },
52
+ // Recipe with custom group ordering (alphabetical for remaining)
53
+ {
54
+ code: `
55
+ import { recipe } from '@vanilla-extract/recipes';
56
+
57
+ const myRecipe = recipe({
58
+ base: {
59
+ width: '100%',
60
+ margin: 0,
61
+ alignItems: 'center',
62
+ backgroundColor: 'white',
63
+ display: 'flex',
64
+ position: 'relative'
65
+ },
66
+ variants: {
67
+ color: {
68
+ blue: {
69
+ backgroundColor: 'blue',
70
+ color: 'white',
71
+ position: 'relative'
72
+ },
73
+ red: {
74
+ backgroundColor: 'red',
75
+ color: 'black',
76
+ position: 'relative'
77
+ }
78
+ }
79
+ }
80
+ });
81
+ `,
82
+ options: [
83
+ {
84
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
85
+ sortRemainingProperties: 'alphabetical',
86
+ },
87
+ ],
88
+ },
89
+ ],
90
+ invalid: [
91
+ // Recipe with incorrect ordering (concentric for remaining)
92
+ {
93
+ code: `
94
+ import { recipe } from '@vanilla-extract/recipes';
95
+ const myRecipe = recipe({
96
+ base: {
97
+ backgroundColor: 'white',
98
+ width: '100%',
99
+ display: 'flex',
100
+ alignItems: 'center',
101
+ margin: 0
102
+ },
103
+ variants: {
104
+ color: {
105
+ blue: {
106
+ color: 'white',
107
+ backgroundColor: 'blue',
108
+ position: 'relative'
109
+ },
110
+ red: {
111
+ color: 'black',
112
+ backgroundColor: 'red',
113
+ position: 'relative'
114
+ }
115
+ }
116
+ }
117
+ });
118
+ `,
119
+ options: [
120
+ {
121
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
122
+ sortRemainingProperties: 'concentric',
123
+ },
124
+ ],
125
+ errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
126
+ output: `
127
+ import { recipe } from '@vanilla-extract/recipes';
128
+ const myRecipe = recipe({
129
+ base: {
130
+ width: '100%',
131
+ margin: 0,
132
+ display: 'flex',
133
+ alignItems: 'center',
134
+ backgroundColor: 'white'
135
+ },
136
+ variants: {
137
+ color: {
138
+ blue: {
139
+ position: 'relative',
140
+ backgroundColor: 'blue',
141
+ color: 'white'
142
+ },
143
+ red: {
144
+ position: 'relative',
145
+ backgroundColor: 'red',
146
+ color: 'black'
147
+ }
148
+ }
149
+ }
150
+ });
151
+ `,
152
+ },
153
+ // Recipe with incorrect ordering (alphabetical for remaining)
154
+ {
155
+ code: `
156
+ import { recipe } from '@vanilla-extract/recipes';
157
+ const myRecipe = recipe({
158
+ base: {
159
+ position: 'relative',
160
+ display: 'flex',
161
+ alignItems: 'center',
162
+ backgroundColor: 'white',
163
+ width: '100%',
164
+ margin: 0
165
+ },
166
+ variants: {
167
+ color: {
168
+ blue: {
169
+ position: 'relative',
170
+ backgroundColor: 'blue',
171
+ color: 'white'
172
+ }
173
+ }
174
+ }
175
+ });
176
+ `,
177
+ options: [
178
+ {
179
+ groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
180
+ sortRemainingProperties: 'alphabetical',
181
+ },
182
+ ],
183
+ errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
184
+ output: `
185
+ import { recipe } from '@vanilla-extract/recipes';
186
+ const myRecipe = recipe({
187
+ base: {
188
+ width: '100%',
189
+ margin: 0,
190
+ alignItems: 'center',
191
+ backgroundColor: 'white',
192
+ display: 'flex',
193
+ position: 'relative'
194
+ },
195
+ variants: {
196
+ color: {
197
+ blue: {
198
+ backgroundColor: 'blue',
199
+ color: 'white',
200
+ position: 'relative'
201
+ }
202
+ }
203
+ }
204
+ });
205
+ `,
206
+ },
207
+ ],
208
+ });