@antebudimir/eslint-plugin-vanilla-extract 1.17.1 → 1.18.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.
- package/README.md +21 -0
- package/dist/css-rules/no-empty-blocks/fix-utils.d.ts +8 -2
- package/dist/css-rules/no-empty-blocks/fix-utils.js +15 -3
- package/dist/css-rules/no-empty-blocks/rule-definition.js +13 -1
- package/dist/css-rules/sample.css.d.ts +76 -0
- package/dist/css-rules/sample.css.js +548 -0
- package/dist/css-rules/shared-utils/css-order-fixer.d.ts +7 -3
- package/dist/css-rules/shared-utils/css-order-fixer.js +129 -19
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -605,6 +605,27 @@ globalStyle(`${buttonWrapper} > svg`, {
|
|
|
605
605
|
Empty blocks that declare no identifier (e.g. `globalStyle('ul', {})`) and unreferenced, non-exported
|
|
606
606
|
declarations remain fully auto-fixable.
|
|
607
607
|
|
|
608
|
+
If you intentionally use empty declarations as class-name hooks and don't want them reported at all, enable the
|
|
609
|
+
`ignoreReferenced` option:
|
|
610
|
+
|
|
611
|
+
#### Options
|
|
612
|
+
|
|
613
|
+
| Option | Type | Default | Description |
|
|
614
|
+
| ------------------ | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
615
|
+
| `ignoreReferenced` | `boolean` | `false` | Don't report empty style declarations that are exported or still referenced elsewhere (e.g. intentional class-name hooks). |
|
|
616
|
+
|
|
617
|
+
```json
|
|
618
|
+
{
|
|
619
|
+
"rules": {
|
|
620
|
+
"vanilla-extract/no-empty-style-blocks": ["error", { "ignoreReferenced": true }]
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
Genuinely unused empty declarations are still reported and auto-removed with this option. Property-level detections
|
|
626
|
+
(empty selectors, `@media`/`@supports` objects, empty variant values, etc.) remain active too — only the
|
|
627
|
+
whole-declaration report for exported/referenced declarations is suppressed.
|
|
628
|
+
|
|
608
629
|
### vanilla-extract/no-px-unit
|
|
609
630
|
|
|
610
631
|
This rule disallows the use of hard-coded `px` units in vanilla-extract style declarations. Prefer `rem`, `em`, or theme tokens. A configurable allowlist lets you permit specific properties to use `px` where necessary. Allowlist supports both camelCase and kebab-case property names.
|
|
@@ -16,9 +16,15 @@ export declare const findTargetDeclarationNode: (callNode: TSESTree.CallExpressi
|
|
|
16
16
|
/**
|
|
17
17
|
* Reports an issue for an empty style declaration, and provides a fix to remove the declaration.
|
|
18
18
|
*
|
|
19
|
-
* The removal autofix is only provided when the declaration
|
|
20
|
-
* identifier
|
|
19
|
+
* The removal autofix is only provided when the declaration isn't exported and its
|
|
20
|
+
* identifier isn't referenced anywhere else in the file
|
|
21
21
|
* those references (e.g. a `globalStyle()` selector or an import in another file).
|
|
22
|
+
*
|
|
23
|
+
* With the `ignoreReferenced` option enabled, declarations that can't be safely auto-removed
|
|
24
|
+
* are not reported at all (useful when empty declarations are used intentionally as
|
|
25
|
+
* class-name hooks). Property-level reports (empty selectors, variant values, etc.) are
|
|
26
|
+
* unaffected by this option.
|
|
27
|
+
*
|
|
22
28
|
* @param ruleContext The ESLint rule context.
|
|
23
29
|
* @param node The node to report the issue on.
|
|
24
30
|
* @param callNode The CallExpression node of the style() function.
|
|
@@ -81,9 +81,15 @@ const isDeclarationSafeToAutoRemove = (ruleContext, declarationNode) => {
|
|
|
81
81
|
/**
|
|
82
82
|
* Reports an issue for an empty style declaration, and provides a fix to remove the declaration.
|
|
83
83
|
*
|
|
84
|
-
* The removal autofix is only provided when the declaration
|
|
85
|
-
* identifier
|
|
84
|
+
* The removal autofix is only provided when the declaration isn't exported and its
|
|
85
|
+
* identifier isn't referenced anywhere else in the file
|
|
86
86
|
* those references (e.g. a `globalStyle()` selector or an import in another file).
|
|
87
|
+
*
|
|
88
|
+
* With the `ignoreReferenced` option enabled, declarations that can't be safely auto-removed
|
|
89
|
+
* are not reported at all (useful when empty declarations are used intentionally as
|
|
90
|
+
* class-name hooks). Property-level reports (empty selectors, variant values, etc.) are
|
|
91
|
+
* unaffected by this option.
|
|
92
|
+
*
|
|
87
93
|
* @param ruleContext The ESLint rule context.
|
|
88
94
|
* @param node The node to report the issue on.
|
|
89
95
|
* @param callNode The CallExpression node of the style() function.
|
|
@@ -94,7 +100,13 @@ export const reportEmptyDeclaration = (ruleContext, node, callNode) => {
|
|
|
94
100
|
['globalStyle', 'globalFontFace', 'globalKeyframes'].includes(callNode.callee.name);
|
|
95
101
|
// Find the parent declaration node
|
|
96
102
|
const targetDeclarationNode = findTargetDeclarationNode(callNode, isGlobalApi);
|
|
97
|
-
|
|
103
|
+
const isSafeToAutoRemove = targetDeclarationNode !== null && isDeclarationSafeToAutoRemove(ruleContext, targetDeclarationNode);
|
|
104
|
+
// With `ignoreReferenced`, declarations that can't be safely auto-removed (exported or still referenced elsewhere - e.g. intentional class-name hooks) are treated as intentional and not reported at all.
|
|
105
|
+
const options = ruleContext.options[0];
|
|
106
|
+
if (options?.ignoreReferenced === true && !isSafeToAutoRemove) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!isSafeToAutoRemove) {
|
|
98
110
|
// Report the issue without providing a fix
|
|
99
111
|
ruleContext.report({
|
|
100
112
|
node: node,
|
|
@@ -8,7 +8,19 @@ const noEmptyStyleBlocksRule = {
|
|
|
8
8
|
recommended: true,
|
|
9
9
|
},
|
|
10
10
|
fixable: 'code',
|
|
11
|
-
schema: [
|
|
11
|
+
schema: [
|
|
12
|
+
{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
ignoreReferenced: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
default: false,
|
|
18
|
+
description: `Don't report empty style declarations that are exported or still referenced elsewhere (e.g. intentional class-name hooks).`,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
12
24
|
messages: {
|
|
13
25
|
emptyConditionalStyle: 'Empty conditional style object should be removed.',
|
|
14
26
|
emptyMedia: 'Empty @media object should be removed.',
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export declare const theFont: string;
|
|
2
|
+
export declare const spinster: void;
|
|
3
|
+
export declare const buttonWrapper: string;
|
|
4
|
+
export declare const starter: string;
|
|
5
|
+
export declare const accordionContent: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
6
|
+
isOpen: {
|
|
7
|
+
false: {
|
|
8
|
+
boxSizing: "inherit";
|
|
9
|
+
position: "relative";
|
|
10
|
+
right: "inherit";
|
|
11
|
+
display: "flex";
|
|
12
|
+
gap: "revert";
|
|
13
|
+
transform: "none";
|
|
14
|
+
margin: "11rem";
|
|
15
|
+
outline: "none";
|
|
16
|
+
border: "Background";
|
|
17
|
+
borderRight: "ActiveBorder";
|
|
18
|
+
borderLeft: "ActiveBorder";
|
|
19
|
+
borderRadius: "initial";
|
|
20
|
+
borderBottomLeftRadius: "initial";
|
|
21
|
+
borderBottomRightRadius: "initial";
|
|
22
|
+
boxShadow: "none";
|
|
23
|
+
backgroundColor: "initial";
|
|
24
|
+
cursor: "pointer";
|
|
25
|
+
width: "100%";
|
|
26
|
+
color: "red";
|
|
27
|
+
fontSize: "large";
|
|
28
|
+
};
|
|
29
|
+
true: {
|
|
30
|
+
boxSizing: "inherit";
|
|
31
|
+
position: "relative";
|
|
32
|
+
right: "inherit";
|
|
33
|
+
display: "flex";
|
|
34
|
+
gap: "revert";
|
|
35
|
+
transform: "none";
|
|
36
|
+
margin: "11rem";
|
|
37
|
+
outline: "none";
|
|
38
|
+
border: "Background";
|
|
39
|
+
borderRight: "ActiveBorder";
|
|
40
|
+
borderLeft: "ActiveBorder";
|
|
41
|
+
borderRadius: "initial";
|
|
42
|
+
borderBottomLeftRadius: "initial";
|
|
43
|
+
borderBottomRightRadius: "initial";
|
|
44
|
+
boxShadow: "none";
|
|
45
|
+
backgroundColor: "initial";
|
|
46
|
+
cursor: "pointer";
|
|
47
|
+
width: "100%";
|
|
48
|
+
color: "red";
|
|
49
|
+
fontSize: "large";
|
|
50
|
+
':hover': {
|
|
51
|
+
boxSizing: "inherit";
|
|
52
|
+
position: "relative";
|
|
53
|
+
right: "inherit";
|
|
54
|
+
display: "flex";
|
|
55
|
+
gap: "revert";
|
|
56
|
+
transform: "none";
|
|
57
|
+
margin: "11rem";
|
|
58
|
+
outline: "none";
|
|
59
|
+
border: "Background";
|
|
60
|
+
borderRight: "ActiveBorder";
|
|
61
|
+
borderLeft: "ActiveBorder";
|
|
62
|
+
borderRadius: "initial";
|
|
63
|
+
borderBottomLeftRadius: "initial";
|
|
64
|
+
borderBottomRightRadius: "initial";
|
|
65
|
+
boxShadow: "none";
|
|
66
|
+
backgroundColor: "initial";
|
|
67
|
+
cursor: "pointer";
|
|
68
|
+
width: "100%";
|
|
69
|
+
color: "red";
|
|
70
|
+
fontSize: "large";
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
export declare const item: string;
|
|
76
|
+
export declare const selectButtonVariants: Record<"bordered" | "borderless", string>;
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { fontFace, globalFontFace, globalKeyframes, globalStyle, keyframes, style, styleVariants, } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
3
|
+
// fontFaces
|
|
4
|
+
export const theFont = fontFace({
|
|
5
|
+
// Comment to test that the linter doesn't remove it
|
|
6
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")', 'url("/fonts/MyFont.woff") format("woff")'],
|
|
7
|
+
ascentOverride: '90%',
|
|
8
|
+
descentOverride: '10%',
|
|
9
|
+
fontDisplay: 'swap',
|
|
10
|
+
fontFeatureSettings: '"liga" 1',
|
|
11
|
+
fontStretch: 'normal',
|
|
12
|
+
fontStyle: 'normal',
|
|
13
|
+
fontVariationSettings: '"wght" 400',
|
|
14
|
+
fontWeight: '400 700',
|
|
15
|
+
lineGapOverride: '10%',
|
|
16
|
+
sizeAdjust: '90%',
|
|
17
|
+
unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
|
|
18
|
+
});
|
|
19
|
+
globalFontFace('GlobalFont', {
|
|
20
|
+
// Comment to test that the linter doesn't remove it
|
|
21
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")', 'url("/fonts/MyFont.woff") format("woff")'],
|
|
22
|
+
ascentOverride: '90%',
|
|
23
|
+
descentOverride: '10%',
|
|
24
|
+
fontDisplay: 'swap',
|
|
25
|
+
fontFeatureSettings: '"liga" 1',
|
|
26
|
+
fontStretch: 'normal',
|
|
27
|
+
fontStyle: 'normal',
|
|
28
|
+
fontVariationSettings: '"wght" 400',
|
|
29
|
+
fontWeight: '400 700',
|
|
30
|
+
lineGapOverride: '10%',
|
|
31
|
+
sizeAdjust: '90%',
|
|
32
|
+
unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
|
|
33
|
+
});
|
|
34
|
+
// keyframes
|
|
35
|
+
export const spinster = globalKeyframes('spin', {
|
|
36
|
+
// Comment to test that the linter doesn't remove it
|
|
37
|
+
from: {
|
|
38
|
+
boxSizing: 'inherit',
|
|
39
|
+
position: 'relative',
|
|
40
|
+
right: 'inherit',
|
|
41
|
+
display: 'flex',
|
|
42
|
+
gap: 'revert',
|
|
43
|
+
transform: 'none',
|
|
44
|
+
margin: '11rem',
|
|
45
|
+
outline: 'none',
|
|
46
|
+
border: 'Background',
|
|
47
|
+
borderRight: 'ActiveBorder',
|
|
48
|
+
borderLeft: 'ActiveBorder',
|
|
49
|
+
borderRadius: 'initial',
|
|
50
|
+
borderBottomLeftRadius: 'initial',
|
|
51
|
+
borderBottomRightRadius: 'initial',
|
|
52
|
+
boxShadow: 'none',
|
|
53
|
+
backgroundColor: 'initial',
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
width: '100%',
|
|
56
|
+
color: 'red',
|
|
57
|
+
fontSize: 'large',
|
|
58
|
+
},
|
|
59
|
+
// Comment to test that the linter doesn't remove it
|
|
60
|
+
to: {
|
|
61
|
+
// Comment to test that the linter doesn't remove it
|
|
62
|
+
boxSizing: 'inherit',
|
|
63
|
+
position: 'relative',
|
|
64
|
+
right: 'inherit',
|
|
65
|
+
display: 'flex',
|
|
66
|
+
gap: 'revert',
|
|
67
|
+
transform: 'none',
|
|
68
|
+
margin: '11rem',
|
|
69
|
+
outline: 'none',
|
|
70
|
+
border: 'Background',
|
|
71
|
+
borderRight: 'ActiveBorder',
|
|
72
|
+
borderLeft: 'ActiveBorder',
|
|
73
|
+
borderRadius: 'initial',
|
|
74
|
+
borderBottomLeftRadius: 'initial',
|
|
75
|
+
borderBottomRightRadius: 'initial',
|
|
76
|
+
boxShadow: 'none',
|
|
77
|
+
backgroundColor: 'initial',
|
|
78
|
+
cursor: 'pointer',
|
|
79
|
+
width: '100%',
|
|
80
|
+
color: 'red',
|
|
81
|
+
fontSize: 'large',
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
// used only as a class-name hook, not for its own properties
|
|
85
|
+
export const buttonWrapper = style({});
|
|
86
|
+
globalStyle(`${buttonWrapper} > svg`, {
|
|
87
|
+
color: 'red',
|
|
88
|
+
});
|
|
89
|
+
export const starter = keyframes({
|
|
90
|
+
// Comment to test that the linter doesn't remove it
|
|
91
|
+
'0%': {
|
|
92
|
+
boxSizing: 'inherit',
|
|
93
|
+
position: 'relative',
|
|
94
|
+
right: 'inherit',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
gap: 'revert',
|
|
97
|
+
transform: 'none',
|
|
98
|
+
margin: '11rem',
|
|
99
|
+
outline: 'none',
|
|
100
|
+
border: 'Background',
|
|
101
|
+
borderRight: 'ActiveBorder',
|
|
102
|
+
borderLeft: 'ActiveBorder',
|
|
103
|
+
borderRadius: 'initial',
|
|
104
|
+
borderBottomLeftRadius: 'initial',
|
|
105
|
+
borderBottomRightRadius: 'initial',
|
|
106
|
+
boxShadow: 'none',
|
|
107
|
+
backgroundColor: 'initial',
|
|
108
|
+
cursor: 'pointer',
|
|
109
|
+
width: '100%',
|
|
110
|
+
color: 'red',
|
|
111
|
+
fontSize: 'large',
|
|
112
|
+
},
|
|
113
|
+
// Comment to test that the linter doesn't remove it
|
|
114
|
+
'100%': {
|
|
115
|
+
// Comment to test that the linter doesn't remove it
|
|
116
|
+
boxSizing: 'inherit',
|
|
117
|
+
position: 'relative',
|
|
118
|
+
right: 'inherit',
|
|
119
|
+
display: 'flex',
|
|
120
|
+
gap: 'revert',
|
|
121
|
+
transform: 'none',
|
|
122
|
+
margin: '11rem',
|
|
123
|
+
outline: 'none',
|
|
124
|
+
border: 'Background',
|
|
125
|
+
borderRight: 'ActiveBorder',
|
|
126
|
+
borderLeft: 'ActiveBorder',
|
|
127
|
+
borderRadius: 'initial',
|
|
128
|
+
borderBottomLeftRadius: 'initial',
|
|
129
|
+
borderBottomRightRadius: 'initial',
|
|
130
|
+
boxShadow: 'none',
|
|
131
|
+
backgroundColor: 'initial',
|
|
132
|
+
cursor: 'pointer',
|
|
133
|
+
width: '100%',
|
|
134
|
+
color: 'red',
|
|
135
|
+
fontSize: 'large',
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
globalStyle('*, ::before, ::after', {
|
|
139
|
+
// Comment to test that the linter doesn't remove it
|
|
140
|
+
boxSizing: 'inherit',
|
|
141
|
+
position: 'relative',
|
|
142
|
+
right: 'inherit',
|
|
143
|
+
display: 'flex',
|
|
144
|
+
gap: 'revert',
|
|
145
|
+
transform: 'none',
|
|
146
|
+
margin: '11rem',
|
|
147
|
+
outline: 'none',
|
|
148
|
+
border: 'Background',
|
|
149
|
+
borderRight: 'ActiveBorder',
|
|
150
|
+
borderLeft: 'ActiveBorder',
|
|
151
|
+
borderRadius: 'initial',
|
|
152
|
+
borderBottomLeftRadius: 'initial',
|
|
153
|
+
borderBottomRightRadius: 'initial',
|
|
154
|
+
backgroundColor: 'initial',
|
|
155
|
+
cursor: 'pointer',
|
|
156
|
+
width: '100%',
|
|
157
|
+
color: 'red',
|
|
158
|
+
fontSize: 'large',
|
|
159
|
+
});
|
|
160
|
+
// style with an array
|
|
161
|
+
const accordionContentBase = style([
|
|
162
|
+
// Comment to test that the linter doesn't remove it
|
|
163
|
+
{
|
|
164
|
+
// Comment to test that the linter doesn't remove it
|
|
165
|
+
boxSizing: 'inherit',
|
|
166
|
+
position: 'relative',
|
|
167
|
+
right: 'inherit',
|
|
168
|
+
display: 'flex',
|
|
169
|
+
gap: 'revert',
|
|
170
|
+
transform: 'none',
|
|
171
|
+
margin: '11rem',
|
|
172
|
+
outline: 'none',
|
|
173
|
+
border: 'Background',
|
|
174
|
+
borderRight: 'ActiveBorder',
|
|
175
|
+
borderLeft: 'ActiveBorder',
|
|
176
|
+
borderRadius: 'initial',
|
|
177
|
+
borderBottomLeftRadius: 'initial',
|
|
178
|
+
borderBottomRightRadius: 'initial',
|
|
179
|
+
boxShadow: 'none',
|
|
180
|
+
backgroundColor: 'initial',
|
|
181
|
+
cursor: 'pointer',
|
|
182
|
+
width: '100%',
|
|
183
|
+
color: 'red',
|
|
184
|
+
fontSize: 'large',
|
|
185
|
+
// special selector to test that the linter doesn't remove it
|
|
186
|
+
'@supports': {
|
|
187
|
+
'(hanging-punctuation: first) and (font: -apple-system-body) and (-webkit-appearance: none)': {
|
|
188
|
+
// Comment to test that the linter doesn't remove it
|
|
189
|
+
boxSizing: 'inherit',
|
|
190
|
+
position: 'relative',
|
|
191
|
+
right: 'inherit',
|
|
192
|
+
display: 'flex',
|
|
193
|
+
gap: 'revert',
|
|
194
|
+
transform: 'none',
|
|
195
|
+
margin: '11rem',
|
|
196
|
+
outline: 'none',
|
|
197
|
+
border: 'Background',
|
|
198
|
+
borderRight: 'ActiveBorder',
|
|
199
|
+
borderLeft: 'ActiveBorder',
|
|
200
|
+
borderRadius: 'initial',
|
|
201
|
+
borderBottomLeftRadius: 'initial',
|
|
202
|
+
borderBottomRightRadius: 'initial',
|
|
203
|
+
boxShadow: 'none',
|
|
204
|
+
backgroundColor: 'initial',
|
|
205
|
+
cursor: 'pointer',
|
|
206
|
+
width: '100%',
|
|
207
|
+
color: 'red',
|
|
208
|
+
fontSize: 'large',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
]);
|
|
213
|
+
export const accordionContent = recipe({
|
|
214
|
+
// Comment to test that the linter doesn't remove it
|
|
215
|
+
base: accordionContentBase,
|
|
216
|
+
// Comment to test that the linter doesn't remove it
|
|
217
|
+
variants: {
|
|
218
|
+
// Comment to test that the linter doesn't remove it
|
|
219
|
+
isOpen: {
|
|
220
|
+
// Comment to test that the linter doesn't remove it
|
|
221
|
+
false: {
|
|
222
|
+
// Comment to test that the linter doesn't remove it
|
|
223
|
+
boxSizing: 'inherit',
|
|
224
|
+
position: 'relative',
|
|
225
|
+
right: 'inherit',
|
|
226
|
+
display: 'flex',
|
|
227
|
+
gap: 'revert',
|
|
228
|
+
transform: 'none',
|
|
229
|
+
margin: '11rem',
|
|
230
|
+
outline: 'none',
|
|
231
|
+
border: 'Background',
|
|
232
|
+
borderRight: 'ActiveBorder',
|
|
233
|
+
borderLeft: 'ActiveBorder',
|
|
234
|
+
borderRadius: 'initial',
|
|
235
|
+
borderBottomLeftRadius: 'initial',
|
|
236
|
+
borderBottomRightRadius: 'initial',
|
|
237
|
+
boxShadow: 'none',
|
|
238
|
+
backgroundColor: 'initial',
|
|
239
|
+
cursor: 'pointer',
|
|
240
|
+
width: '100%',
|
|
241
|
+
color: 'red',
|
|
242
|
+
fontSize: 'large',
|
|
243
|
+
},
|
|
244
|
+
true: {
|
|
245
|
+
boxSizing: 'inherit',
|
|
246
|
+
position: 'relative',
|
|
247
|
+
right: 'inherit',
|
|
248
|
+
display: 'flex',
|
|
249
|
+
gap: 'revert',
|
|
250
|
+
transform: 'none',
|
|
251
|
+
margin: '11rem',
|
|
252
|
+
outline: 'none',
|
|
253
|
+
border: 'Background',
|
|
254
|
+
borderRight: 'ActiveBorder',
|
|
255
|
+
borderLeft: 'ActiveBorder',
|
|
256
|
+
borderRadius: 'initial',
|
|
257
|
+
borderBottomLeftRadius: 'initial',
|
|
258
|
+
borderBottomRightRadius: 'initial',
|
|
259
|
+
boxShadow: 'none',
|
|
260
|
+
backgroundColor: 'initial',
|
|
261
|
+
cursor: 'pointer',
|
|
262
|
+
width: '100%',
|
|
263
|
+
color: 'red',
|
|
264
|
+
fontSize: 'large',
|
|
265
|
+
// pseudo selector inside a variant
|
|
266
|
+
':hover': {
|
|
267
|
+
// Comment to test that the linter doesn't remove it
|
|
268
|
+
boxSizing: 'inherit',
|
|
269
|
+
position: 'relative',
|
|
270
|
+
right: 'inherit',
|
|
271
|
+
display: 'flex',
|
|
272
|
+
gap: 'revert',
|
|
273
|
+
transform: 'none',
|
|
274
|
+
margin: '11rem',
|
|
275
|
+
outline: 'none',
|
|
276
|
+
border: 'Background',
|
|
277
|
+
borderRight: 'ActiveBorder',
|
|
278
|
+
borderLeft: 'ActiveBorder',
|
|
279
|
+
borderRadius: 'initial',
|
|
280
|
+
borderBottomLeftRadius: 'initial',
|
|
281
|
+
borderBottomRightRadius: 'initial',
|
|
282
|
+
boxShadow: 'none',
|
|
283
|
+
backgroundColor: 'initial',
|
|
284
|
+
cursor: 'pointer',
|
|
285
|
+
width: '100%',
|
|
286
|
+
color: 'red',
|
|
287
|
+
fontSize: 'large',
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
export const item = style({
|
|
294
|
+
boxSizing: 'inherit',
|
|
295
|
+
position: 'relative',
|
|
296
|
+
right: 'inherit',
|
|
297
|
+
display: 'flex',
|
|
298
|
+
gap: 'revert',
|
|
299
|
+
transform: 'none',
|
|
300
|
+
margin: '11rem',
|
|
301
|
+
outline: 'none',
|
|
302
|
+
border: 'Background',
|
|
303
|
+
borderRight: 'ActiveBorder',
|
|
304
|
+
borderLeft: 'ActiveBorder',
|
|
305
|
+
borderRadius: 'initial',
|
|
306
|
+
borderBottomLeftRadius: 'initial',
|
|
307
|
+
borderBottomRightRadius: 'initial',
|
|
308
|
+
backgroundColor: 'initial',
|
|
309
|
+
cursor: 'pointer',
|
|
310
|
+
width: '100%',
|
|
311
|
+
color: 'red',
|
|
312
|
+
fontSize: 'large',
|
|
313
|
+
// pseudo selector inside a style
|
|
314
|
+
':focus-visible': {
|
|
315
|
+
// Comment to test that the linter doesn't remove it
|
|
316
|
+
boxSizing: 'inherit',
|
|
317
|
+
position: 'relative',
|
|
318
|
+
right: 'inherit',
|
|
319
|
+
display: 'flex',
|
|
320
|
+
gap: 'revert',
|
|
321
|
+
transform: 'none',
|
|
322
|
+
margin: '11rem',
|
|
323
|
+
outline: 'none',
|
|
324
|
+
border: 'Background',
|
|
325
|
+
borderRight: 'ActiveBorder',
|
|
326
|
+
borderLeft: 'ActiveBorder',
|
|
327
|
+
borderRadius: 'initial',
|
|
328
|
+
borderBottomLeftRadius: 'initial',
|
|
329
|
+
borderBottomRightRadius: 'initial',
|
|
330
|
+
boxShadow: 'none',
|
|
331
|
+
backgroundColor: 'initial',
|
|
332
|
+
cursor: 'pointer',
|
|
333
|
+
width: '100%',
|
|
334
|
+
color: 'red',
|
|
335
|
+
fontSize: 'large',
|
|
336
|
+
},
|
|
337
|
+
selectors: {
|
|
338
|
+
// Comment to test that the linter doesn't remove it
|
|
339
|
+
'&[data-pressed]': {
|
|
340
|
+
// Comment to test that the linter doesn't remove it
|
|
341
|
+
boxSizing: 'inherit',
|
|
342
|
+
position: 'relative',
|
|
343
|
+
right: 'inherit',
|
|
344
|
+
display: 'flex',
|
|
345
|
+
gap: 'revert',
|
|
346
|
+
transform: 'none',
|
|
347
|
+
margin: '11rem',
|
|
348
|
+
outline: 'none',
|
|
349
|
+
border: 'Background',
|
|
350
|
+
borderRight: 'ActiveBorder',
|
|
351
|
+
borderLeft: 'ActiveBorder',
|
|
352
|
+
borderRadius: 'initial',
|
|
353
|
+
borderBottomLeftRadius: 'initial',
|
|
354
|
+
borderBottomRightRadius: 'initial',
|
|
355
|
+
boxShadow: 'none',
|
|
356
|
+
backgroundColor: 'initial',
|
|
357
|
+
cursor: 'pointer',
|
|
358
|
+
width: '100%',
|
|
359
|
+
color: 'red',
|
|
360
|
+
fontSize: 'large',
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
export const selectButtonVariants = styleVariants({
|
|
365
|
+
// Comment to test that the linter doesn't remove it
|
|
366
|
+
bordered: {
|
|
367
|
+
// Comment to test that the linter doesn't remove it
|
|
368
|
+
boxSizing: 'inherit',
|
|
369
|
+
position: 'relative',
|
|
370
|
+
right: 'inherit',
|
|
371
|
+
display: 'flex',
|
|
372
|
+
gap: 'revert',
|
|
373
|
+
transform: 'none',
|
|
374
|
+
margin: '11rem',
|
|
375
|
+
outline: 'none',
|
|
376
|
+
border: 'Background',
|
|
377
|
+
borderRight: 'ActiveBorder',
|
|
378
|
+
borderLeft: 'ActiveBorder',
|
|
379
|
+
borderRadius: 'initial',
|
|
380
|
+
borderBottomLeftRadius: 'initial',
|
|
381
|
+
borderBottomRightRadius: 'initial',
|
|
382
|
+
backgroundColor: 'initial',
|
|
383
|
+
cursor: 'pointer',
|
|
384
|
+
width: '100%',
|
|
385
|
+
color: 'red',
|
|
386
|
+
fontSize: 'large',
|
|
387
|
+
},
|
|
388
|
+
borderless: {
|
|
389
|
+
boxSizing: 'inherit',
|
|
390
|
+
position: 'relative',
|
|
391
|
+
right: 'inherit',
|
|
392
|
+
display: 'flex',
|
|
393
|
+
gap: 'revert',
|
|
394
|
+
transform: 'none',
|
|
395
|
+
margin: '11rem',
|
|
396
|
+
outline: 'none',
|
|
397
|
+
border: 'Background',
|
|
398
|
+
borderRight: 'ActiveBorder',
|
|
399
|
+
borderLeft: 'ActiveBorder',
|
|
400
|
+
borderRadius: 'initial',
|
|
401
|
+
borderBottomLeftRadius: 'initial',
|
|
402
|
+
borderBottomRightRadius: 'initial',
|
|
403
|
+
boxShadow: 'none',
|
|
404
|
+
backgroundColor: 'initial',
|
|
405
|
+
cursor: 'pointer',
|
|
406
|
+
width: '100%',
|
|
407
|
+
color: 'red',
|
|
408
|
+
fontSize: 'large',
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
// Test cases for noEmptyStyleBlocksRule
|
|
412
|
+
// export const myRecipe = recipe({
|
|
413
|
+
// base: {
|
|
414
|
+
// color: 'blue',
|
|
415
|
+
// selectors: {},
|
|
416
|
+
// '@media': {},
|
|
417
|
+
// '@supports': {},
|
|
418
|
+
// },
|
|
419
|
+
// variants: {
|
|
420
|
+
// size: {
|
|
421
|
+
// small: {
|
|
422
|
+
// selectors: {
|
|
423
|
+
// '&:hover': {},
|
|
424
|
+
// },
|
|
425
|
+
// '@media': {
|
|
426
|
+
// '(min-width: 768px)': {},
|
|
427
|
+
// },
|
|
428
|
+
// '@supports': {
|
|
429
|
+
// '(display: grid)': {},
|
|
430
|
+
// },
|
|
431
|
+
// },
|
|
432
|
+
// },
|
|
433
|
+
// },
|
|
434
|
+
// });
|
|
435
|
+
// const base = style({ padding: 12 });
|
|
436
|
+
// export const variant = styleVariants({
|
|
437
|
+
// primary: [],
|
|
438
|
+
// secondary: [],
|
|
439
|
+
// bordered: {},
|
|
440
|
+
// borderless: {},
|
|
441
|
+
// });
|
|
442
|
+
// const baseStyles = {
|
|
443
|
+
// color: 'blue',
|
|
444
|
+
// margin: '10px',
|
|
445
|
+
// };
|
|
446
|
+
// const isDarkMode = false;
|
|
447
|
+
// export const spreadStyle = style({
|
|
448
|
+
// ...baseStyles,
|
|
449
|
+
// ...{},
|
|
450
|
+
// });
|
|
451
|
+
// export const recipeWithNonObjectValue = recipe({
|
|
452
|
+
// base: { color: 'black' },
|
|
453
|
+
// variants: {
|
|
454
|
+
// color: {
|
|
455
|
+
// red: { color: 'red' },
|
|
456
|
+
// // string instead of object
|
|
457
|
+
// string: 'string',
|
|
458
|
+
// // variable instead of object
|
|
459
|
+
// variable: baseStyles,
|
|
460
|
+
// },
|
|
461
|
+
// },
|
|
462
|
+
// });
|
|
463
|
+
// export const conditionalStyle = style(isDarkMode ? {} : {});
|
|
464
|
+
// export const recipeWithEmptyVariantValues = recipe({
|
|
465
|
+
// base: { color: 'black' },
|
|
466
|
+
// variants: {
|
|
467
|
+
// color: {
|
|
468
|
+
// blue: {},
|
|
469
|
+
// red: {},
|
|
470
|
+
// },
|
|
471
|
+
// },
|
|
472
|
+
// });
|
|
473
|
+
// export const nestedEmptyStyle = style({
|
|
474
|
+
// selectors: {
|
|
475
|
+
// '&:hover': {},
|
|
476
|
+
// '&:focus': {},
|
|
477
|
+
// },
|
|
478
|
+
// });
|
|
479
|
+
// const myEmptyStyle = style({});
|
|
480
|
+
// export { myEmptyStyle };
|
|
481
|
+
// export const emptyStyle1 = style({});
|
|
482
|
+
// export const emptyStyle2 = style({});
|
|
483
|
+
// export const emptyVariants = styleVariants({});
|
|
484
|
+
// export const emptyRecipe = recipe({});
|
|
485
|
+
// export const styleWithComments = style({
|
|
486
|
+
// /_This is an empty style_/
|
|
487
|
+
// });
|
|
488
|
+
// export const styleWithEmptyMedia = style({
|
|
489
|
+
// color: 'blue',
|
|
490
|
+
// });
|
|
491
|
+
// export const styleWithEmptySelector = style({
|
|
492
|
+
// color: 'blue',
|
|
493
|
+
// selectors: {
|
|
494
|
+
// '&:hover': {},
|
|
495
|
+
// },
|
|
496
|
+
// });
|
|
497
|
+
// export const recipeWithBothEmpty = recipe({
|
|
498
|
+
// base: {},
|
|
499
|
+
// variants: {},
|
|
500
|
+
// });
|
|
501
|
+
// export const recipeWithEmptyVariants = recipe({
|
|
502
|
+
// base: { color: 'black' },
|
|
503
|
+
// variants: {},
|
|
504
|
+
// });
|
|
505
|
+
// export const recipeWithEmptyBase = recipe({
|
|
506
|
+
// base: {},
|
|
507
|
+
// variants: {
|
|
508
|
+
// color: {
|
|
509
|
+
// blue: { color: 'blue' },
|
|
510
|
+
// },
|
|
511
|
+
// },
|
|
512
|
+
// });
|
|
513
|
+
// export const recipe = recipe({
|
|
514
|
+
// base: {},
|
|
515
|
+
// variants: {
|
|
516
|
+
// color: {
|
|
517
|
+
// red: {},
|
|
518
|
+
// blue: {},
|
|
519
|
+
// },
|
|
520
|
+
// },
|
|
521
|
+
// });
|
|
522
|
+
// export const recipeWithNonObjectVariants = recipe({
|
|
523
|
+
// base: { color: 'blue' },
|
|
524
|
+
// variants: {
|
|
525
|
+
// color: {
|
|
526
|
+
// size: 'string instead of object', // This is a string, not an object
|
|
527
|
+
// red: {},
|
|
528
|
+
// },
|
|
529
|
+
// },
|
|
530
|
+
// });
|
|
531
|
+
// export const recipeWithEmptyVariantValue = recipe({
|
|
532
|
+
// base: { color: 'black' },
|
|
533
|
+
// variants: {
|
|
534
|
+
// color: {
|
|
535
|
+
// blue: {}, // Empty object is allowed - represents a reset/default variant
|
|
536
|
+
// red: { color: 'red' },
|
|
537
|
+
// },
|
|
538
|
+
// },
|
|
539
|
+
// });
|
|
540
|
+
// Using the same empty object reference in both branches
|
|
541
|
+
// export const myStyle = style(true ? {} : {});
|
|
542
|
+
// export const emptyFontFace = fontFace({});
|
|
543
|
+
// globalFontFace('GlobalFont', {});
|
|
544
|
+
// globalKeyframes('a', {});
|
|
545
|
+
// export const emptyKeyframes = keyframes({});
|
|
546
|
+
// globalStyle('ul', {});
|
|
547
|
+
// export const emptyStyleVariants = styleVariants({});
|
|
548
|
+
// export const emptyStyle = style({});
|
|
@@ -10,8 +10,12 @@ import type { Rule } from 'eslint';
|
|
|
10
10
|
*
|
|
11
11
|
* This function performs the following steps:
|
|
12
12
|
* 1. Sorts the input properties using the provided comparison function.
|
|
13
|
-
* 2.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* 2. Splits every property into its attachable "chunk" (leading comments,
|
|
14
|
+
* property text, same-line trailing comment).
|
|
15
|
+
* 3. For every file slot whose property changed position, replaces the slot's
|
|
16
|
+
* whole chunk (from its first leading comment to its trailing comma /
|
|
17
|
+
* same-line comment) with the incoming property's chunk, re-adding the
|
|
18
|
+
* trailing comma when required so the result stays syntactically valid.
|
|
19
|
+
* 4. Comments always move together with the property they describe.
|
|
16
20
|
*/
|
|
17
21
|
export declare const generateFixesForCSSOrder: <T>(eslintFixer: Rule.RuleFixer, ruleContext: Rule.RuleContext, cssProperties: T[], compareProperties: (firstProperty: T, secondProperty: T) => number, extractNode: (property: T) => Rule.Node) => Rule.Fix[];
|
|
@@ -1,3 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the pieces of source text that belong to a property and should move
|
|
3
|
+
* with it when properties are reordered:
|
|
4
|
+
* 1. The leading comments directly above the property (contiguous block of
|
|
5
|
+
* comments with no blank line separating them from the property).
|
|
6
|
+
* 2. The property node itself.
|
|
7
|
+
* 3. A trailing comment on the same line as the property, if present.
|
|
8
|
+
*
|
|
9
|
+
* Delimiters that belong to the *slot* in the file rather than to the property
|
|
10
|
+
* (the trailing comma, the newlines, the indentation of the first line) are
|
|
11
|
+
* deliberately excluded so that swapping chunk texts between slots always
|
|
12
|
+
* produces valid syntax.
|
|
13
|
+
*/
|
|
14
|
+
const createPropertyChunkExtractor = (sourceCode) => {
|
|
15
|
+
// Comments already claimed as trailing comments of an earlier property must
|
|
16
|
+
// not also be claimed as leading comments of the next property.
|
|
17
|
+
const claimedTrailingComments = new Set();
|
|
18
|
+
const extractLeadingComments = (node) => {
|
|
19
|
+
const allCommentsBefore = sourceCode.getCommentsBefore(node);
|
|
20
|
+
if (allCommentsBefore.length === 0) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
// Walk upwards from the property, collecting the contiguous run of
|
|
24
|
+
// comments directly above it (no blank line in between).
|
|
25
|
+
const attachedComments = [];
|
|
26
|
+
let currentEndLine = node.loc.start.line;
|
|
27
|
+
for (let index = allCommentsBefore.length - 1; index >= 0; index--) {
|
|
28
|
+
const comment = allCommentsBefore[index];
|
|
29
|
+
if (!comment || claimedTrailingComments.has(comment)) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
// A blank line between the comment and what follows means the comment
|
|
33
|
+
// documents the block, not this specific property.
|
|
34
|
+
if (currentEndLine - comment.loc.end.line > 1) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
attachedComments.unshift(comment);
|
|
38
|
+
currentEndLine = comment.loc.start.line;
|
|
39
|
+
}
|
|
40
|
+
if (attachedComments.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
// Slice from the first attached comment up to the property start. This
|
|
44
|
+
// includes the newlines and indentation between the comments and before
|
|
45
|
+
// the property, but not the indentation of the first comment's line (the
|
|
46
|
+
// destination slot already provides that indentation).
|
|
47
|
+
const firstComment = attachedComments[0];
|
|
48
|
+
const firstCommentStart = firstComment.range[0];
|
|
49
|
+
const commentsText = sourceCode.text.slice(firstCommentStart, node.range[0]);
|
|
50
|
+
return { start: firstCommentStart, text: commentsText };
|
|
51
|
+
};
|
|
52
|
+
// ESLint attaches a same-line trailing comment to the *following* node's
|
|
53
|
+
// leading comments rather than to this node, so trailing comments are found
|
|
54
|
+
// by scanning all comments for one starting on the property's last line.
|
|
55
|
+
const findTrailingComment = (node) => sourceCode.getAllComments().find((comment) => comment.loc.start.line === node.loc.end.line);
|
|
56
|
+
const extractTrailingCommentText = (node) => {
|
|
57
|
+
const trailingComment = findTrailingComment(node);
|
|
58
|
+
if (!trailingComment) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
claimedTrailingComments.add(trailingComment);
|
|
62
|
+
return sourceCode.text.slice(trailingComment.range[0], trailingComment.range[1]);
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
extractPropertyChunk: (node) => {
|
|
66
|
+
const leadingComments = extractLeadingComments(node);
|
|
67
|
+
return {
|
|
68
|
+
leadingCommentsStart: leadingComments?.start ?? null,
|
|
69
|
+
leadingCommentsText: leadingComments?.text ?? '',
|
|
70
|
+
nodeText: sourceCode.getText(node),
|
|
71
|
+
trailingCommentText: extractTrailingCommentText(node),
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
findTrailingComment,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
1
77
|
/**
|
|
2
78
|
* Generates ESLint fixes for CSS property ordering violations.
|
|
3
79
|
* @param eslintFixer The ESLint fixer instance used to create fix objects.
|
|
@@ -9,31 +85,65 @@
|
|
|
9
85
|
*
|
|
10
86
|
* This function performs the following steps:
|
|
11
87
|
* 1. Sorts the input properties using the provided comparison function.
|
|
12
|
-
* 2.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
88
|
+
* 2. Splits every property into its attachable "chunk" (leading comments,
|
|
89
|
+
* property text, same-line trailing comment).
|
|
90
|
+
* 3. For every file slot whose property changed position, replaces the slot's
|
|
91
|
+
* whole chunk (from its first leading comment to its trailing comma /
|
|
92
|
+
* same-line comment) with the incoming property's chunk, re-adding the
|
|
93
|
+
* trailing comma when required so the result stays syntactically valid.
|
|
94
|
+
* 4. Comments always move together with the property they describe.
|
|
15
95
|
*/
|
|
16
96
|
export const generateFixesForCSSOrder = (eslintFixer, ruleContext, cssProperties, compareProperties, extractNode) => {
|
|
17
97
|
const sourceCode = ruleContext.sourceCode;
|
|
18
98
|
// Sort properties using the provided comparison function
|
|
19
99
|
const sortedProperties = [...cssProperties].sort(compareProperties);
|
|
20
|
-
|
|
21
|
-
const
|
|
100
|
+
const { extractPropertyChunk, findTrailingComment } = createPropertyChunkExtractor(sourceCode);
|
|
101
|
+
const chunksByProperty = new Map(cssProperties.map((property) => [
|
|
22
102
|
property,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
103
|
+
extractPropertyChunk(extractNode(property)),
|
|
104
|
+
]));
|
|
105
|
+
// Generate fixes for slots whose property has changed
|
|
106
|
+
return cssProperties
|
|
107
|
+
.map((slotProperty, slotIndex) => {
|
|
108
|
+
const sortedProperty = sortedProperties[slotIndex];
|
|
109
|
+
if (!sortedProperty || sortedProperty === slotProperty) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const slotChunk = chunksByProperty.get(slotProperty);
|
|
113
|
+
const sortedChunk = chunksByProperty.get(sortedProperty);
|
|
114
|
+
if (!slotChunk || !sortedChunk) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const slotNode = extractNode(slotProperty);
|
|
118
|
+
// The replacement range spans the slot's whole attachable chunk: from
|
|
119
|
+
// its first leading comment (if any) to the end of its trailing comma
|
|
120
|
+
// and/or same-line trailing comment. This consumes the original
|
|
121
|
+
// comments and punctuation so they are neither left behind nor doubled.
|
|
122
|
+
const rangeStart = slotChunk.leadingCommentsStart ?? slotNode.range[0];
|
|
123
|
+
let rangeEnd = slotNode.range[1];
|
|
124
|
+
const tokenAfter = sourceCode.getTokenAfter(slotNode);
|
|
125
|
+
if (tokenAfter && tokenAfter.value === ',' && tokenAfter.range[1] > rangeEnd) {
|
|
126
|
+
rangeEnd = tokenAfter.range[1];
|
|
127
|
+
}
|
|
128
|
+
if (slotChunk.trailingCommentText !== null) {
|
|
129
|
+
const trailingComment = findTrailingComment(slotNode);
|
|
130
|
+
if (trailingComment && trailingComment.range[1] > rangeEnd) {
|
|
131
|
+
rangeEnd = trailingComment.range[1];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Rebuild the incoming property's text, preserving the slot's comma
|
|
135
|
+
// convention: if the original property in this slot had a trailing
|
|
136
|
+
// comma, keep one; if not (typically the object's last property), don't.
|
|
137
|
+
const slotHadTrailingComma = tokenAfter?.value === ',';
|
|
138
|
+
const replacementText = [
|
|
139
|
+
sortedChunk.leadingCommentsText,
|
|
140
|
+
sortedChunk.nodeText,
|
|
141
|
+
slotHadTrailingComma ? ',' : '',
|
|
142
|
+
sortedChunk.trailingCommentText !== null
|
|
143
|
+
? `${slotHadTrailingComma ? ' ' : ''}${sortedChunk.trailingCommentText}`
|
|
144
|
+
: '',
|
|
145
|
+
].join('');
|
|
146
|
+
return eslintFixer.replaceTextRange([rangeStart, rangeEnd], replacementText);
|
|
37
147
|
})
|
|
38
148
|
.filter((fix) => fix !== null);
|
|
39
149
|
};
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import preferThemeTokensRule from './css-rules/prefer-theme-tokens/index.js';
|
|
|
12
12
|
const vanillaExtract = {
|
|
13
13
|
meta: {
|
|
14
14
|
name: '@antebudimir/eslint-plugin-vanilla-extract',
|
|
15
|
-
version: '1.
|
|
15
|
+
version: '1.18.1',
|
|
16
16
|
},
|
|
17
17
|
rules: {
|
|
18
18
|
'alphabetical-order': alphabeticalOrderRule,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antebudimir/eslint-plugin-vanilla-extract",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "Comprehensive ESLint plugin for vanilla-extract with CSS property ordering, style validation, and best practices enforcement. Supports alphabetical, concentric and custom CSS ordering, auto-fixing, and zero-runtime safety.",
|
|
5
5
|
"author": "Ante Budimir",
|
|
6
6
|
"license": "MIT",
|