@antebudimir/eslint-plugin-vanilla-extract 1.0.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +242 -0
  3. package/dist/css/test.css.d.ts +159 -0
  4. package/dist/css/test.css.js +468 -0
  5. package/dist/css/testFileForOtherMethods.css.d.ts +3 -0
  6. package/dist/css/testFileForOtherMethods.css.js +101 -0
  7. package/dist/css-rules/alphabetical-order/index.d.ts +2 -0
  8. package/dist/css-rules/alphabetical-order/index.js +2 -0
  9. package/dist/css-rules/alphabetical-order/property-order-enforcer.d.ts +14 -0
  10. package/dist/css-rules/alphabetical-order/property-order-enforcer.js +57 -0
  11. package/dist/css-rules/alphabetical-order/recipe-order-enforcer.d.ts +14 -0
  12. package/dist/css-rules/alphabetical-order/recipe-order-enforcer.js +22 -0
  13. package/dist/css-rules/alphabetical-order/rule-definition.d.ts +3 -0
  14. package/dist/css-rules/alphabetical-order/rule-definition.js +20 -0
  15. package/dist/css-rules/alphabetical-order/style-object-processor.d.ts +15 -0
  16. package/dist/css-rules/alphabetical-order/style-object-processor.js +28 -0
  17. package/dist/css-rules/concentric-order/concentric-groups.d.ts +7 -0
  18. package/dist/css-rules/concentric-order/concentric-groups.js +307 -0
  19. package/dist/css-rules/concentric-order/index.d.ts +2 -0
  20. package/dist/css-rules/concentric-order/index.js +2 -0
  21. package/dist/css-rules/concentric-order/property-order-enforcer.d.ts +16 -0
  22. package/dist/css-rules/concentric-order/property-order-enforcer.js +60 -0
  23. package/dist/css-rules/concentric-order/recipe-order-enforcer.d.ts +14 -0
  24. package/dist/css-rules/concentric-order/recipe-order-enforcer.js +22 -0
  25. package/dist/css-rules/concentric-order/rule-definition.d.ts +3 -0
  26. package/dist/css-rules/concentric-order/rule-definition.js +20 -0
  27. package/dist/css-rules/concentric-order/style-object-processor.d.ts +21 -0
  28. package/dist/css-rules/concentric-order/style-object-processor.js +59 -0
  29. package/dist/css-rules/concentric-order/types.d.ts +8 -0
  30. package/dist/css-rules/concentric-order/types.js +1 -0
  31. package/dist/css-rules/custom-order/property-order-enforcer.d.ts +17 -0
  32. package/dist/css-rules/custom-order/property-order-enforcer.js +67 -0
  33. package/dist/css-rules/custom-order/recipe-order-enforcer.d.ts +16 -0
  34. package/dist/css-rules/custom-order/recipe-order-enforcer.js +24 -0
  35. package/dist/css-rules/custom-order/rule-definition.d.ts +3 -0
  36. package/dist/css-rules/custom-order/rule-definition.js +40 -0
  37. package/dist/css-rules/custom-order/style-object-processor.d.ts +19 -0
  38. package/dist/css-rules/custom-order/style-object-processor.js +52 -0
  39. package/dist/css-rules/shared-utils/css-order-fixer.d.ts +17 -0
  40. package/dist/css-rules/shared-utils/css-order-fixer.js +39 -0
  41. package/dist/css-rules/shared-utils/css-property-priority-map.d.ts +25 -0
  42. package/dist/css-rules/shared-utils/css-property-priority-map.js +48 -0
  43. package/dist/css-rules/shared-utils/nested-selectors-processor.d.ts +25 -0
  44. package/dist/css-rules/shared-utils/nested-selectors-processor.js +35 -0
  45. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.d.ts +17 -0
  46. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.js +76 -0
  47. package/dist/css-rules/shared-utils/property-separator.d.ts +28 -0
  48. package/dist/css-rules/shared-utils/property-separator.js +49 -0
  49. package/dist/css-rules/shared-utils/recipe-property-processor.d.ts +16 -0
  50. package/dist/css-rules/shared-utils/recipe-property-processor.js +37 -0
  51. package/dist/css-rules/shared-utils/style-node-processor.d.ts +9 -0
  52. package/dist/css-rules/shared-utils/style-node-processor.js +22 -0
  53. package/dist/css-sample/sample.css.d.ts +161 -0
  54. package/dist/css-sample/sample.css.js +551 -0
  55. package/dist/index.d.ts +38 -0
  56. package/dist/index.js +37 -0
  57. package/package.json +75 -0
@@ -0,0 +1,22 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';
2
+ import { processRecipeProperties } from '../shared-utils/recipe-property-processor.js';
3
+ import { processStyleNode } from '../shared-utils/style-node-processor.js';
4
+ import { enforceAlphabeticalCSSOrderInStyleObject } from './style-object-processor.js';
5
+ /**
6
+ * Enforces alphabetical ordering of CSS properties within a recipe function call.
7
+ *
8
+ * @param node The CallExpression node representing the recipe function call.
9
+ * @param context The ESLint rule context.
10
+ *
11
+ * This function does the following:
12
+ * 1. Checks if the first argument of the recipe function is an ObjectExpression.
13
+ * 2. If valid, processes the recipe object's properties.
14
+ * 3. For each relevant property (e.g., 'base', 'variants'), it applies alphabetical ordering to the CSS properties.
15
+ */
16
+ export const enforceAlphabeticalCSSOrderInRecipe = (node, context) => {
17
+ if (!node.arguments[0] || node.arguments[0].type !== 'ObjectExpression') {
18
+ return;
19
+ }
20
+ const recipeObject = node.arguments[0];
21
+ processRecipeProperties(context, recipeObject, (context, object) => processStyleNode(context, object, enforceAlphabeticalCSSOrderInStyleObject));
22
+ };
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const alphabeticalOrderRule: Rule.RuleModule;
3
+ export default alphabeticalOrderRule;
@@ -0,0 +1,20 @@
1
+ import { createNodeVisitors } from '../shared-utils/order-strategy-visitor-creator.js';
2
+ const alphabeticalOrderRule = {
3
+ meta: {
4
+ type: 'suggestion',
5
+ docs: {
6
+ description: 'enforce alphabetical CSS property ordering in vanilla-extract styles',
7
+ category: 'Stylistic Issues',
8
+ recommended: true,
9
+ },
10
+ fixable: 'code',
11
+ schema: [],
12
+ messages: {
13
+ alphabeticalOrder: "Property '{{next}}' should come before '{{current}}' in alphabetical order.",
14
+ },
15
+ },
16
+ create(context) {
17
+ return createNodeVisitors(context, 'alphabetical');
18
+ },
19
+ };
20
+ export default alphabeticalOrderRule;
@@ -0,0 +1,15 @@
1
+ import type { Rule } from 'eslint';
2
+ import { TSESTree } from '@typescript-eslint/utils';
3
+ /**
4
+ * Processes a style object to enforce alphabetical ordering of CSS properties.
5
+ *
6
+ * This function handles different types of style objects:
7
+ * 1. If the object is invalid or not an ObjectExpression, it returns immediately.
8
+ * 2. For 'selectors' objects, it processes nested selectors recursively.
9
+ * 3. For regular style objects, it separates and enforces alphabetical order on properties.
10
+ * 4. It always processes nested objects recursively, regardless of type.
11
+ *
12
+ * @param ruleContext - The ESLint rule context for reporting and fixing issues.
13
+ * @param styleObject - The object expression representing the style object to be processed.
14
+ */
15
+ export declare const enforceAlphabeticalCSSOrderInStyleObject: (ruleContext: Rule.RuleContext, styleObject: TSESTree.ObjectExpression) => void;
@@ -0,0 +1,28 @@
1
+ import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
2
+ import { isSelectorsObject, processNestedSelectors } from '../shared-utils/nested-selectors-processor.js';
3
+ import { separateProperties } from '../shared-utils/property-separator.js';
4
+ import { enforceAlphabeticalCSSOrder } from './property-order-enforcer.js';
5
+ /**
6
+ * Processes a style object to enforce alphabetical ordering of CSS properties.
7
+ *
8
+ * This function handles different types of style objects:
9
+ * 1. If the object is invalid or not an ObjectExpression, it returns immediately.
10
+ * 2. For 'selectors' objects, it processes nested selectors recursively.
11
+ * 3. For regular style objects, it separates and enforces alphabetical order on properties.
12
+ * 4. It always processes nested objects recursively, regardless of type.
13
+ *
14
+ * @param ruleContext - The ESLint rule context for reporting and fixing issues.
15
+ * @param styleObject - The object expression representing the style object to be processed.
16
+ */
17
+ export const enforceAlphabeticalCSSOrderInStyleObject = (ruleContext, styleObject) => {
18
+ if (!styleObject || styleObject.type !== AST_NODE_TYPES.ObjectExpression) {
19
+ return;
20
+ }
21
+ if (isSelectorsObject(styleObject)) {
22
+ processNestedSelectors(ruleContext, styleObject, enforceAlphabeticalCSSOrderInStyleObject);
23
+ return;
24
+ }
25
+ const { regularProperties } = separateProperties(styleObject.properties);
26
+ enforceAlphabeticalCSSOrder(ruleContext, regularProperties);
27
+ processNestedSelectors(ruleContext, styleObject, enforceAlphabeticalCSSOrderInStyleObject);
28
+ };
@@ -0,0 +1,7 @@
1
+ export declare const concentricGroups: {
2
+ [key: string]: string[];
3
+ };
4
+ /**
5
+ * Export all available groups for use in custom groups rule
6
+ */
7
+ export declare const availableGroups: string[];
@@ -0,0 +1,307 @@
1
+ // CSS property groups in order of importance (outside -> inside)
2
+ export const concentricGroups = {
3
+ boxSizing: ['all', 'box-sizing', 'aspect-ratio', 'contain'],
4
+ position: [
5
+ 'position',
6
+ 'z-index',
7
+ 'top',
8
+ 'right',
9
+ 'bottom',
10
+ 'left',
11
+ 'offset',
12
+ 'offset-path',
13
+ 'offset-distance',
14
+ 'offset-rotate',
15
+ 'inset',
16
+ 'inset-block',
17
+ 'inset-block-start',
18
+ 'inset-block-end',
19
+ 'inset-inline',
20
+ 'inset-inline-start',
21
+ 'inset-inline-end',
22
+ ],
23
+ display: ['display', 'float', 'clear', 'isolation', 'appearance'],
24
+ flex: ['flex', 'flex-basis', 'flex-direction', 'flex-flow', 'flex-grow', 'flex-shrink', 'flex-wrap'],
25
+ grid: [
26
+ 'grid',
27
+ 'grid-area',
28
+ 'grid-template',
29
+ 'grid-template-areas',
30
+ 'grid-template-rows',
31
+ 'grid-template-columns',
32
+ 'grid-row',
33
+ 'grid-row-start',
34
+ 'grid-row-end',
35
+ 'grid-column',
36
+ 'grid-column-start',
37
+ 'grid-column-end',
38
+ 'grid-auto-rows',
39
+ 'grid-auto-columns',
40
+ 'grid-auto-flow',
41
+ 'grid-gap',
42
+ 'grid-row-gap',
43
+ 'grid-column-gap',
44
+ ],
45
+ alignment: [
46
+ 'align-content',
47
+ 'align-items',
48
+ 'align-self',
49
+ 'justify-content',
50
+ 'justify-items',
51
+ 'justify-self',
52
+ 'place-content',
53
+ 'place-items',
54
+ 'place-self',
55
+ 'order',
56
+ 'gap',
57
+ 'row-gap',
58
+ 'column-gap',
59
+ ],
60
+ columns: [
61
+ 'columns',
62
+ 'column-fill',
63
+ 'column-rule',
64
+ 'column-rule-width',
65
+ 'column-rule-style',
66
+ 'column-rule-color',
67
+ 'column-span',
68
+ 'column-count',
69
+ 'column-width',
70
+ ],
71
+ transform: [
72
+ 'backface-visibility',
73
+ 'perspective',
74
+ 'perspective-origin',
75
+ 'transform',
76
+ 'transform-origin',
77
+ 'transform-style',
78
+ 'transform-box',
79
+ ],
80
+ transitions: [
81
+ 'transition',
82
+ 'transition-delay',
83
+ 'transition-duration',
84
+ 'transition-property',
85
+ 'transition-timing-function',
86
+ 'transition-behavior',
87
+ ],
88
+ visibility: [
89
+ 'visibility',
90
+ 'opacity',
91
+ 'backdrop-filter',
92
+ 'content-visibility',
93
+ 'filter',
94
+ 'mix-blend-mode',
95
+ 'will-change',
96
+ ],
97
+ shape: ['clip-path', 'shape-outside', 'shape-image-threshold', 'shape-margin'],
98
+ margin: [
99
+ 'margin',
100
+ 'margin-top',
101
+ 'margin-right',
102
+ 'margin-bottom',
103
+ 'margin-left',
104
+ 'margin-block',
105
+ 'margin-block-start',
106
+ 'margin-block-end',
107
+ 'margin-inline',
108
+ 'margin-inline-start',
109
+ 'margin-inline-end',
110
+ 'margin-trim',
111
+ ],
112
+ outline: ['outline', 'outline-offset', 'outline-width', 'outline-style', 'outline-color'],
113
+ border: [
114
+ 'border',
115
+ 'border-top',
116
+ 'border-right',
117
+ 'border-bottom',
118
+ 'border-left',
119
+ 'border-width',
120
+ 'border-top-width',
121
+ 'border-right-width',
122
+ 'border-bottom-width',
123
+ 'border-left-width',
124
+ 'border-style',
125
+ 'border-top-style',
126
+ 'border-right-style',
127
+ 'border-bottom-style',
128
+ 'border-left-style',
129
+ 'border-radius',
130
+ 'border-top-left-radius',
131
+ 'border-top-right-radius',
132
+ 'border-bottom-left-radius',
133
+ 'border-bottom-right-radius',
134
+ 'border-start-start-radius',
135
+ 'border-start-end-radius',
136
+ 'border-end-start-radius',
137
+ 'border-end-end-radius',
138
+ 'border-color',
139
+ 'border-top-color',
140
+ 'border-right-color',
141
+ 'border-bottom-color',
142
+ 'border-left-color',
143
+ 'border-image',
144
+ 'border-image-source',
145
+ 'border-image-width',
146
+ 'border-image-outset',
147
+ 'border-image-repeat',
148
+ 'border-image-slice',
149
+ 'border-block',
150
+ 'border-block-start',
151
+ 'border-block-end',
152
+ 'border-block-width',
153
+ 'border-block-style',
154
+ 'border-block-color',
155
+ 'border-inline',
156
+ 'border-inline-start',
157
+ 'border-inline-end',
158
+ 'border-inline-width',
159
+ 'border-inline-style',
160
+ 'border-inline-color',
161
+ ],
162
+ boxShadow: ['box-shadow'],
163
+ background: [
164
+ 'background',
165
+ 'background-attachment',
166
+ 'background-clip',
167
+ 'background-color',
168
+ 'background-image',
169
+ 'background-origin',
170
+ 'background-position',
171
+ 'background-repeat',
172
+ 'background-size',
173
+ 'background-blend-mode',
174
+ 'object-fit',
175
+ 'object-position',
176
+ 'image-orientation',
177
+ 'image-rendering',
178
+ ],
179
+ cursor: ['cursor', 'pointer-events', 'touch-action'],
180
+ padding: [
181
+ 'padding',
182
+ 'padding-top',
183
+ 'padding-right',
184
+ 'padding-bottom',
185
+ 'padding-left',
186
+ 'padding-block',
187
+ 'padding-block-start',
188
+ 'padding-block-end',
189
+ 'padding-inline',
190
+ 'padding-inline-start',
191
+ 'padding-inline-end',
192
+ ],
193
+ dimensions: [
194
+ 'width',
195
+ 'min-width',
196
+ 'max-width',
197
+ 'height',
198
+ 'min-height',
199
+ 'max-height',
200
+ 'block-size',
201
+ 'min-block-size',
202
+ 'max-block-size',
203
+ 'inline-size',
204
+ 'min-inline-size',
205
+ 'max-inline-size',
206
+ ],
207
+ overflow: [
208
+ 'overflow',
209
+ 'overflow-x',
210
+ 'overflow-y',
211
+ 'overflow-block',
212
+ 'overflow-inline',
213
+ 'overflow-clip-margin',
214
+ 'overflow-anchor',
215
+ 'overflow-wrap',
216
+ 'overscroll-behavior',
217
+ 'overscroll-behavior-x',
218
+ 'overscroll-behavior-y',
219
+ 'resize',
220
+ 'scrollbar-width',
221
+ 'scrollbar-color',
222
+ 'scrollbar-gutter',
223
+ 'scroll-behavior',
224
+ 'scroll-margin',
225
+ 'scroll-padding',
226
+ 'scroll-snap-align',
227
+ 'scroll-snap-stop',
228
+ 'scroll-snap-type',
229
+ ],
230
+ listStyle: ['list-style', 'list-style-type', 'list-style-position', 'list-style-image', 'caption-side'],
231
+ tables: ['table-layout', 'border-collapse', 'border-spacing', 'empty-cells'],
232
+ animation: [
233
+ 'animation',
234
+ 'animation-name',
235
+ 'animation-duration',
236
+ 'animation-timing-function',
237
+ 'animation-delay',
238
+ 'animation-iteration-count',
239
+ 'animation-direction',
240
+ 'animation-fill-mode',
241
+ 'animation-play-state',
242
+ ],
243
+ text: [
244
+ 'vertical-align',
245
+ 'direction',
246
+ 'writing-mode',
247
+ 'text-orientation',
248
+ 'unicode-bidi',
249
+ 'tab-size',
250
+ 'text-align',
251
+ 'text-align-last',
252
+ 'text-justify',
253
+ 'text-indent',
254
+ 'text-transform',
255
+ 'text-decoration',
256
+ 'text-decoration-color',
257
+ 'text-decoration-line',
258
+ 'text-decoration-style',
259
+ 'text-decoration-thickness',
260
+ 'text-decoration-skip-ink',
261
+ 'text-underline-position',
262
+ 'text-rendering',
263
+ 'text-shadow',
264
+ 'text-overflow',
265
+ 'text-wrap',
266
+ 'text-size-adjust',
267
+ 'text-combine-upright',
268
+ 'hyphens',
269
+ 'line-break',
270
+ 'ruby-position',
271
+ 'caret-color',
272
+ 'user-select',
273
+ ],
274
+ textSpacing: [
275
+ 'line-height',
276
+ 'word-spacing',
277
+ 'letter-spacing',
278
+ 'white-space',
279
+ 'word-break',
280
+ 'word-wrap',
281
+ 'orphans',
282
+ 'widows',
283
+ 'color',
284
+ ],
285
+ font: [
286
+ 'font',
287
+ 'font-family',
288
+ 'font-size',
289
+ 'font-size-adjust',
290
+ 'font-stretch',
291
+ 'font-weight',
292
+ 'font-smoothing',
293
+ 'osx-font-smoothing',
294
+ 'font-variant',
295
+ 'font-style',
296
+ 'font-feature-settings',
297
+ 'font-kerning',
298
+ 'font-optical-sizing',
299
+ ],
300
+ content: ['content', 'quotes'],
301
+ counters: ['counter-reset', 'counter-increment', 'counter-set'],
302
+ breaks: ['page-break-before', 'page-break-after', 'page-break-inside', 'break-before', 'break-after', 'break-inside'],
303
+ };
304
+ /**
305
+ * Export all available groups for use in custom groups rule
306
+ */
307
+ export const availableGroups = Object.keys(concentricGroups);
@@ -0,0 +1,2 @@
1
+ import concentricOrderRule from './rule-definition.js';
2
+ export default concentricOrderRule;
@@ -0,0 +1,2 @@
1
+ import concentricOrderRule from './rule-definition.js';
2
+ export default concentricOrderRule;
@@ -0,0 +1,16 @@
1
+ import type { Rule } from 'eslint';
2
+ import type { CSSPropertyInfo } from './types.js';
3
+ /**
4
+ * Enforces concentric ordering of CSS properties.
5
+ *
6
+ * This function checks the order of CSS properties to ensure they follow a concentric order
7
+ * based on their priority and position within their group. It performs the following steps:
8
+ * 1. Validates if there are enough properties to compare.
9
+ * 2. Creates pairs of consecutive properties for comparison.
10
+ * 3. Identifies the first pair that violates the concentric order.
11
+ * 4. If a violation is detected, reports the issue and suggests fixes using ESLint.
12
+ *
13
+ * @param ruleContext - The ESLint rule context used for reporting and fixing.
14
+ * @param cssPropertyInfoList - An array of CSS property information objects to be checked.
15
+ */
16
+ export declare const enforceConcentricCSSOrder: (ruleContext: Rule.RuleContext, cssPropertyInfoList: CSSPropertyInfo[]) => void;
@@ -0,0 +1,60 @@
1
+ import { generateFixesForCSSOrder } from '../shared-utils/css-order-fixer.js';
2
+ /**
3
+ * Reports a violation of the concentric CSS ordering rule and generates fixes.
4
+ *
5
+ * @param ruleContext The ESLint rule context used for reporting and fixing.
6
+ * @param currentProperty The current property in the order.
7
+ * @param nextProperty The next property that is out of order.
8
+ * @param cssPropertyInfoList The full list of CSS properties to be reordered.
9
+ */
10
+ const reportOrderingIssue = (ruleContext, currentProperty, nextProperty, cssPropertyInfoList) => {
11
+ ruleContext.report({
12
+ node: nextProperty.node,
13
+ messageId: 'incorrectOrder',
14
+ data: {
15
+ next: nextProperty.name,
16
+ current: currentProperty.name,
17
+ },
18
+ fix: (fixer) => generateFixesForCSSOrder(fixer, ruleContext, cssPropertyInfoList, compareProperties, (propertyInfo) => propertyInfo.node),
19
+ });
20
+ };
21
+ /**
22
+ * Compares two CSS properties based on their priority and position within their group.
23
+ *
24
+ * @param firstProperty The first property to compare.
25
+ * @param secondProperty The second property to compare.
26
+ * @returns A number indicating the relative order of the properties (-1, 0, or 1).
27
+ */
28
+ const compareProperties = (firstProperty, secondProperty) => {
29
+ if (firstProperty.priority !== secondProperty.priority) {
30
+ return firstProperty.priority - secondProperty.priority;
31
+ }
32
+ return firstProperty.positionInGroup - secondProperty.positionInGroup;
33
+ };
34
+ /**
35
+ * Enforces concentric ordering of CSS properties.
36
+ *
37
+ * This function checks the order of CSS properties to ensure they follow a concentric order
38
+ * based on their priority and position within their group. It performs the following steps:
39
+ * 1. Validates if there are enough properties to compare.
40
+ * 2. Creates pairs of consecutive properties for comparison.
41
+ * 3. Identifies the first pair that violates the concentric order.
42
+ * 4. If a violation is detected, reports the issue and suggests fixes using ESLint.
43
+ *
44
+ * @param ruleContext - The ESLint rule context used for reporting and fixing.
45
+ * @param cssPropertyInfoList - An array of CSS property information objects to be checked.
46
+ */
47
+ export const enforceConcentricCSSOrder = (ruleContext, cssPropertyInfoList) => {
48
+ if (cssPropertyInfoList.length <= 1) {
49
+ return;
50
+ }
51
+ // Create pairs of consecutive properties
52
+ const propertyPairs = cssPropertyInfoList.slice(0, -1).map((currentProperty, index) => ({
53
+ currentProperty,
54
+ nextProperty: cssPropertyInfoList[index + 1],
55
+ }));
56
+ const violatingPair = propertyPairs.find(({ currentProperty, nextProperty }) => compareProperties(currentProperty, nextProperty) > 0);
57
+ if (violatingPair) {
58
+ reportOrderingIssue(ruleContext, violatingPair.currentProperty, violatingPair.nextProperty, cssPropertyInfoList);
59
+ }
60
+ };
@@ -0,0 +1,14 @@
1
+ import type { Rule } from 'eslint';
2
+ import { TSESTree } from '@typescript-eslint/utils';
3
+ /**
4
+ * Enforces concentric ordering of CSS properties within a recipe function call.
5
+ *
6
+ * @param ruleContext The ESLint rule context for reporting and fixing issues.
7
+ * @param callExpression The CallExpression node representing the recipe function call.
8
+ *
9
+ * This function does the following:
10
+ * 1. Checks if the first argument of the recipe function is an ObjectExpression.
11
+ * 2. If valid, processes the recipe object's properties.
12
+ * 3. For each relevant property (e.g., 'base', 'variants'), it applies concentric ordering to the CSS properties.
13
+ */
14
+ export declare const enforceConcentricCSSOrderInRecipe: (ruleContext: Rule.RuleContext, callExpression: TSESTree.CallExpression) => void;
@@ -0,0 +1,22 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';
2
+ import { processRecipeProperties } from '../shared-utils/recipe-property-processor.js';
3
+ import { processStyleNode } from '../shared-utils/style-node-processor.js';
4
+ import { enforceConcentricCSSOrderInStyleObject } from './style-object-processor.js';
5
+ /**
6
+ * Enforces concentric ordering of CSS properties within a recipe function call.
7
+ *
8
+ * @param ruleContext The ESLint rule context for reporting and fixing issues.
9
+ * @param callExpression The CallExpression node representing the recipe function call.
10
+ *
11
+ * This function does the following:
12
+ * 1. Checks if the first argument of the recipe function is an ObjectExpression.
13
+ * 2. If valid, processes the recipe object's properties.
14
+ * 3. For each relevant property (e.g., 'base', 'variants'), it applies concentric ordering to the CSS properties.
15
+ */
16
+ export const enforceConcentricCSSOrderInRecipe = (ruleContext, callExpression) => {
17
+ if (!callExpression.arguments[0] || callExpression.arguments[0].type !== 'ObjectExpression') {
18
+ return;
19
+ }
20
+ const recipeObjectExpression = callExpression.arguments[0];
21
+ processRecipeProperties(ruleContext, recipeObjectExpression, (currentContext, styleObject) => processStyleNode(currentContext, styleObject, enforceConcentricCSSOrderInStyleObject));
22
+ };
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const concentricOrderRule: Rule.RuleModule;
3
+ export default concentricOrderRule;
@@ -0,0 +1,20 @@
1
+ import { createNodeVisitors } from '../shared-utils/order-strategy-visitor-creator.js';
2
+ const concentricOrderRule = {
3
+ meta: {
4
+ type: 'suggestion',
5
+ docs: {
6
+ description: 'enforce concentric CSS property ordering in vanilla-extract styles',
7
+ category: 'Stylistic Issues',
8
+ recommended: true,
9
+ },
10
+ fixable: 'code',
11
+ schema: [],
12
+ messages: {
13
+ incorrectOrder: "Property '{{next}}' should come before '{{current}}' according to concentric CSS ordering.",
14
+ },
15
+ },
16
+ create(context) {
17
+ return createNodeVisitors(context, 'concentric');
18
+ },
19
+ };
20
+ export default concentricOrderRule;
@@ -0,0 +1,21 @@
1
+ import type { Rule } from 'eslint';
2
+ import { TSESTree } from '@typescript-eslint/utils';
3
+ /**
4
+ * Enforces concentric ordering of CSS properties within a style object.
5
+ *
6
+ * This function processes the given style object to ensure that CSS properties
7
+ * follow a concentric order based on predefined priority groups. It handles
8
+ * different types of style objects by:
9
+ * 1. Validating that the input is an ObjectExpression.
10
+ * 2. Processing 'selectors' objects separately and recursively applying the
11
+ * concentric order enforcement.
12
+ * 3. Separating regular properties and building a list of CSSPropertyInfo
13
+ * objects with priority details.
14
+ * 4. Enforcing concentric order on the properties using their priority
15
+ * information.
16
+ * 5. Recursively processing nested selectors and style objects.
17
+ *
18
+ * @param ruleContext - The ESLint rule context for reporting and fixing issues.
19
+ * @param styleObject - The object expression representing the style object to be processed.
20
+ */
21
+ export declare const enforceConcentricCSSOrderInStyleObject: (ruleContext: Rule.RuleContext, styleObject: TSESTree.ObjectExpression) => void;
@@ -0,0 +1,59 @@
1
+ import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
2
+ import { createCSSPropertyPriorityMap } from '../shared-utils/css-property-priority-map.js';
3
+ import { isSelectorsObject, processNestedSelectors } from '../shared-utils/nested-selectors-processor.js';
4
+ import { getPropertyName, separateProperties } from '../shared-utils/property-separator.js';
5
+ import { enforceConcentricCSSOrder } from './property-order-enforcer.js';
6
+ const cssPropertyPriorityMap = createCSSPropertyPriorityMap();
7
+ /**
8
+ * Builds a list of CSS properties with their priority information in the concentric order of their groups.
9
+ *
10
+ * @param regularStyleProperties An array of regular style properties.
11
+ * @returns An array of CSSPropertyInfo objects containing name, node, priority, and position information.
12
+ */
13
+ const buildCSSPropertyInfoList = (regularStyleProperties) => {
14
+ return regularStyleProperties.map((styleProperty) => {
15
+ const propertyName = getPropertyName(styleProperty);
16
+ const propertyInfo = cssPropertyPriorityMap.get(propertyName);
17
+ return {
18
+ name: propertyName,
19
+ node: styleProperty,
20
+ priority: propertyInfo?.groupIndex ?? Number.MAX_SAFE_INTEGER,
21
+ positionInGroup: propertyInfo?.positionInGroup ?? Number.MAX_SAFE_INTEGER,
22
+ };
23
+ });
24
+ };
25
+ /**
26
+ * Enforces concentric ordering of CSS properties within a style object.
27
+ *
28
+ * This function processes the given style object to ensure that CSS properties
29
+ * follow a concentric order based on predefined priority groups. It handles
30
+ * different types of style objects by:
31
+ * 1. Validating that the input is an ObjectExpression.
32
+ * 2. Processing 'selectors' objects separately and recursively applying the
33
+ * concentric order enforcement.
34
+ * 3. Separating regular properties and building a list of CSSPropertyInfo
35
+ * objects with priority details.
36
+ * 4. Enforcing concentric order on the properties using their priority
37
+ * information.
38
+ * 5. Recursively processing nested selectors and style objects.
39
+ *
40
+ * @param ruleContext - The ESLint rule context for reporting and fixing issues.
41
+ * @param styleObject - The object expression representing the style object to be processed.
42
+ */
43
+ export const enforceConcentricCSSOrderInStyleObject = (ruleContext, styleObject) => {
44
+ if (!styleObject || styleObject.type !== AST_NODE_TYPES.ObjectExpression) {
45
+ return;
46
+ }
47
+ if (isSelectorsObject(styleObject)) {
48
+ styleObject.properties.forEach((property) => {
49
+ if (property.type === AST_NODE_TYPES.Property && property.value.type === AST_NODE_TYPES.ObjectExpression) {
50
+ enforceConcentricCSSOrderInStyleObject(ruleContext, property.value);
51
+ }
52
+ });
53
+ return;
54
+ }
55
+ const { regularProperties } = separateProperties(styleObject.properties);
56
+ const cssPropertyInfoList = buildCSSPropertyInfoList(regularProperties);
57
+ enforceConcentricCSSOrder(ruleContext, cssPropertyInfoList);
58
+ processNestedSelectors(ruleContext, styleObject, enforceConcentricCSSOrderInStyleObject);
59
+ };
@@ -0,0 +1,8 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';
2
+ export interface CSSPropertyInfo {
3
+ name: string;
4
+ node: TSESTree.Property;
5
+ priority: number;
6
+ positionInGroup: number;
7
+ group?: string;
8
+ }
@@ -0,0 +1 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';