@antebudimir/eslint-plugin-vanilla-extract 1.12.0 → 1.14.0
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 +90 -14
- package/dist/css-rules/no-px-unit/_tests_/no-px-unit.test.d.ts +1 -0
- package/dist/css-rules/no-px-unit/_tests_/no-px-unit.test.js +163 -0
- package/dist/css-rules/no-px-unit/index.d.ts +2 -0
- package/dist/css-rules/no-px-unit/index.js +2 -0
- package/dist/css-rules/no-px-unit/no-px-unit-visitor-creator.d.ts +2 -0
- package/dist/css-rules/no-px-unit/no-px-unit-visitor-creator.js +55 -0
- package/dist/css-rules/no-px-unit/processor.d.ts +3 -0
- package/dist/css-rules/no-px-unit/processor.js +93 -0
- package/dist/css-rules/no-px-unit/px-unit-processor.d.ts +14 -0
- package/dist/css-rules/no-px-unit/px-unit-processor.js +104 -0
- package/dist/css-rules/no-px-unit/px-unit-visitor-creator.d.ts +11 -0
- package/dist/css-rules/no-px-unit/px-unit-visitor-creator.js +64 -0
- package/dist/css-rules/no-px-unit/rule-definition.d.ts +3 -0
- package/dist/css-rules/no-px-unit/rule-definition.js +37 -0
- package/dist/css-rules/no-px-unit/visitor-creator.d.ts +2 -0
- package/dist/css-rules/no-px-unit/visitor-creator.js +55 -0
- package/dist/css-rules/prefer-logical-properties/_tests_/prefer-logical-properties.test.d.ts +1 -0
- package/dist/css-rules/prefer-logical-properties/_tests_/prefer-logical-properties.test.js +572 -0
- package/dist/css-rules/prefer-logical-properties/index.d.ts +2 -0
- package/dist/css-rules/prefer-logical-properties/index.js +2 -0
- package/dist/css-rules/prefer-logical-properties/logical-properties-processor.d.ts +19 -0
- package/dist/css-rules/prefer-logical-properties/logical-properties-processor.js +202 -0
- package/dist/css-rules/prefer-logical-properties/logical-properties-visitor-creator.d.ts +14 -0
- package/dist/css-rules/prefer-logical-properties/logical-properties-visitor-creator.js +67 -0
- package/dist/css-rules/prefer-logical-properties/property-mappings.d.ts +44 -0
- package/dist/css-rules/prefer-logical-properties/property-mappings.js +179 -0
- package/dist/css-rules/prefer-logical-properties/rule-definition.d.ts +3 -0
- package/dist/css-rules/prefer-logical-properties/rule-definition.js +35 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/sample.css.d.ts +75 -0
- package/dist/sample.css.js +540 -0
- package/package.json +2 -2
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import { run } from 'eslint-vitest-rule-tester';
|
|
3
|
+
import preferLogicalPropertiesRule from '../rule-definition.js';
|
|
4
|
+
run({
|
|
5
|
+
name: 'vanilla-extract/prefer-logical-properties',
|
|
6
|
+
rule: preferLogicalPropertiesRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
{
|
|
16
|
+
code: `
|
|
17
|
+
import { style } from '@vanilla-extract/css';
|
|
18
|
+
const myStyle = style({
|
|
19
|
+
marginInlineStart: '1rem',
|
|
20
|
+
marginInlineEnd: '1rem',
|
|
21
|
+
marginBlockStart: '2rem',
|
|
22
|
+
marginBlockEnd: '2rem',
|
|
23
|
+
});
|
|
24
|
+
`,
|
|
25
|
+
name: 'allows logical properties in camelCase',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
code: `
|
|
29
|
+
import { style } from '@vanilla-extract/css';
|
|
30
|
+
const myStyle = style({
|
|
31
|
+
'margin-inline-start': '1rem',
|
|
32
|
+
'margin-inline-end': '1rem',
|
|
33
|
+
'margin-block-start': '2rem',
|
|
34
|
+
'margin-block-end': '2rem',
|
|
35
|
+
});
|
|
36
|
+
`,
|
|
37
|
+
name: 'allows logical properties in kebab-case',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
code: `
|
|
41
|
+
import { style } from '@vanilla-extract/css';
|
|
42
|
+
const myStyle = style({
|
|
43
|
+
insetInlineStart: 0,
|
|
44
|
+
insetInlineEnd: 0,
|
|
45
|
+
insetBlockStart: 0,
|
|
46
|
+
insetBlockEnd: 0,
|
|
47
|
+
});
|
|
48
|
+
`,
|
|
49
|
+
name: 'allows logical inset properties',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
code: `
|
|
53
|
+
import { style } from '@vanilla-extract/css';
|
|
54
|
+
const myStyle = style({
|
|
55
|
+
borderInlineStartWidth: '1px',
|
|
56
|
+
borderInlineEndColor: 'red',
|
|
57
|
+
borderBlockStartStyle: 'solid',
|
|
58
|
+
});
|
|
59
|
+
`,
|
|
60
|
+
name: 'allows logical border properties',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
code: `
|
|
64
|
+
import { style } from '@vanilla-extract/css';
|
|
65
|
+
const myStyle = style({
|
|
66
|
+
inlineSize: '100%',
|
|
67
|
+
blockSize: '50vh',
|
|
68
|
+
minInlineSize: '200px',
|
|
69
|
+
maxBlockSize: '800px',
|
|
70
|
+
});
|
|
71
|
+
`,
|
|
72
|
+
name: 'allows logical size properties',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
code: `
|
|
76
|
+
import { style } from '@vanilla-extract/css';
|
|
77
|
+
const myStyle = style({
|
|
78
|
+
textAlign: 'start',
|
|
79
|
+
float: 'inline-start',
|
|
80
|
+
clear: 'inline-end',
|
|
81
|
+
});
|
|
82
|
+
`,
|
|
83
|
+
name: 'allows logical values for directional properties',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
code: `
|
|
87
|
+
import { style } from '@vanilla-extract/css';
|
|
88
|
+
const myStyle = style({
|
|
89
|
+
marginLeft: '1rem',
|
|
90
|
+
paddingTop: '2rem',
|
|
91
|
+
top: 0,
|
|
92
|
+
left: 0,
|
|
93
|
+
});
|
|
94
|
+
`,
|
|
95
|
+
options: [{ allow: ['marginLeft', 'paddingTop', 'top', 'left'] }],
|
|
96
|
+
name: 'respects allowlist for camelCase properties',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
code: `
|
|
100
|
+
import { style } from '@vanilla-extract/css';
|
|
101
|
+
const myStyle = style({
|
|
102
|
+
'margin-left': '1rem',
|
|
103
|
+
'padding-top': '2rem',
|
|
104
|
+
});
|
|
105
|
+
`,
|
|
106
|
+
options: [{ allow: ['margin-left', 'padding-top'] }],
|
|
107
|
+
name: 'respects allowlist for kebab-case properties',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
code: `
|
|
111
|
+
import { style } from '@vanilla-extract/css';
|
|
112
|
+
const myStyle = style({
|
|
113
|
+
marginLeft: '1rem',
|
|
114
|
+
});
|
|
115
|
+
`,
|
|
116
|
+
options: [{ allow: ['margin-left'] }],
|
|
117
|
+
name: 'allowlist works with mixed case (kebab in config, camel in code)',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
code: `
|
|
121
|
+
import { recipe } from '@vanilla-extract/css';
|
|
122
|
+
const myRecipe = recipe({
|
|
123
|
+
base: {
|
|
124
|
+
marginInlineStart: '1rem',
|
|
125
|
+
paddingBlockEnd: '2rem',
|
|
126
|
+
},
|
|
127
|
+
variants: {
|
|
128
|
+
size: {
|
|
129
|
+
sm: { insetInlineStart: 0 },
|
|
130
|
+
lg: { borderInlineEndWidth: '2px' },
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
`,
|
|
135
|
+
name: 'allows logical properties in recipe base and variants',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
code: `
|
|
139
|
+
import { style } from '@vanilla-extract/css';
|
|
140
|
+
const myStyle = style({
|
|
141
|
+
'@media': {
|
|
142
|
+
'(min-width: 768px)': {
|
|
143
|
+
marginInlineStart: '2rem',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
selectors: {
|
|
147
|
+
'&:hover': {
|
|
148
|
+
paddingBlockStart: '1rem',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
`,
|
|
153
|
+
name: 'allows logical properties in nested @media and selectors',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
code: `
|
|
157
|
+
import { style } from '@vanilla-extract/css';
|
|
158
|
+
const myStyle = style({
|
|
159
|
+
color: 'red',
|
|
160
|
+
display: 'flex',
|
|
161
|
+
fontSize: '16px',
|
|
162
|
+
});
|
|
163
|
+
`,
|
|
164
|
+
name: 'ignores non-directional properties',
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
invalid: [
|
|
168
|
+
{
|
|
169
|
+
code: `
|
|
170
|
+
import { style } from '@vanilla-extract/css';
|
|
171
|
+
const myStyle = style({
|
|
172
|
+
marginTop: '1rem',
|
|
173
|
+
marginBottom: '2rem',
|
|
174
|
+
});
|
|
175
|
+
`,
|
|
176
|
+
output: `
|
|
177
|
+
import { style } from '@vanilla-extract/css';
|
|
178
|
+
const myStyle = style({
|
|
179
|
+
marginBlockStart: '1rem',
|
|
180
|
+
marginBlockEnd: '2rem',
|
|
181
|
+
});
|
|
182
|
+
`,
|
|
183
|
+
errors: [
|
|
184
|
+
{
|
|
185
|
+
messageId: 'preferLogicalProperty',
|
|
186
|
+
data: { physical: 'marginTop', logical: 'marginBlockStart' },
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
messageId: 'preferLogicalProperty',
|
|
190
|
+
data: { physical: 'marginBottom', logical: 'marginBlockEnd' },
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
name: 'reports and fixes margin properties',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
code: `
|
|
197
|
+
import { style } from '@vanilla-extract/css';
|
|
198
|
+
const myStyle = style({
|
|
199
|
+
'padding-left': '1rem',
|
|
200
|
+
'padding-right': '2rem',
|
|
201
|
+
});
|
|
202
|
+
`,
|
|
203
|
+
output: `
|
|
204
|
+
import { style } from '@vanilla-extract/css';
|
|
205
|
+
const myStyle = style({
|
|
206
|
+
'padding-inline-start': '1rem',
|
|
207
|
+
'padding-inline-end': '2rem',
|
|
208
|
+
});
|
|
209
|
+
`,
|
|
210
|
+
errors: [
|
|
211
|
+
{
|
|
212
|
+
messageId: 'preferLogicalProperty',
|
|
213
|
+
data: { physical: 'padding-left', logical: 'padding-inline-start' },
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
messageId: 'preferLogicalProperty',
|
|
217
|
+
data: { physical: 'padding-right', logical: 'padding-inline-end' },
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
name: 'reports and fixes kebab-case padding properties',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
code: `
|
|
224
|
+
import { style } from '@vanilla-extract/css';
|
|
225
|
+
const myStyle = style({
|
|
226
|
+
top: 0,
|
|
227
|
+
left: 0,
|
|
228
|
+
right: 0,
|
|
229
|
+
bottom: 0,
|
|
230
|
+
});
|
|
231
|
+
`,
|
|
232
|
+
output: `
|
|
233
|
+
import { style } from '@vanilla-extract/css';
|
|
234
|
+
const myStyle = style({
|
|
235
|
+
insetBlockStart: 0,
|
|
236
|
+
insetInlineStart: 0,
|
|
237
|
+
insetInlineEnd: 0,
|
|
238
|
+
insetBlockEnd: 0,
|
|
239
|
+
});
|
|
240
|
+
`,
|
|
241
|
+
errors: [
|
|
242
|
+
{ messageId: 'preferLogicalProperty' },
|
|
243
|
+
{ messageId: 'preferLogicalProperty' },
|
|
244
|
+
{ messageId: 'preferLogicalProperty' },
|
|
245
|
+
{ messageId: 'preferLogicalProperty' },
|
|
246
|
+
],
|
|
247
|
+
name: 'reports and fixes positioning properties',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
code: `
|
|
251
|
+
import { style } from '@vanilla-extract/css';
|
|
252
|
+
const myStyle = style({
|
|
253
|
+
borderLeftWidth: '1px',
|
|
254
|
+
borderRightColor: 'red',
|
|
255
|
+
borderTopStyle: 'solid',
|
|
256
|
+
});
|
|
257
|
+
`,
|
|
258
|
+
output: `
|
|
259
|
+
import { style } from '@vanilla-extract/css';
|
|
260
|
+
const myStyle = style({
|
|
261
|
+
borderInlineStartWidth: '1px',
|
|
262
|
+
borderInlineEndColor: 'red',
|
|
263
|
+
borderBlockStartStyle: 'solid',
|
|
264
|
+
});
|
|
265
|
+
`,
|
|
266
|
+
errors: [
|
|
267
|
+
{ messageId: 'preferLogicalProperty' },
|
|
268
|
+
{ messageId: 'preferLogicalProperty' },
|
|
269
|
+
{ messageId: 'preferLogicalProperty' },
|
|
270
|
+
],
|
|
271
|
+
name: 'reports and fixes border sub-properties',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
code: `
|
|
275
|
+
import { style } from '@vanilla-extract/css';
|
|
276
|
+
const myStyle = style({
|
|
277
|
+
borderLeft: '1px solid red',
|
|
278
|
+
borderRight: '2px dashed blue',
|
|
279
|
+
});
|
|
280
|
+
`,
|
|
281
|
+
output: `
|
|
282
|
+
import { style } from '@vanilla-extract/css';
|
|
283
|
+
const myStyle = style({
|
|
284
|
+
borderInlineStart: '1px solid red',
|
|
285
|
+
borderInlineEnd: '2px dashed blue',
|
|
286
|
+
});
|
|
287
|
+
`,
|
|
288
|
+
errors: [
|
|
289
|
+
{ messageId: 'preferLogicalProperty' },
|
|
290
|
+
{ messageId: 'preferLogicalProperty' },
|
|
291
|
+
],
|
|
292
|
+
name: 'reports and fixes border shorthand properties',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
code: `
|
|
296
|
+
import { style } from '@vanilla-extract/css';
|
|
297
|
+
const myStyle = style({
|
|
298
|
+
borderTopLeftRadius: '4px',
|
|
299
|
+
borderBottomRightRadius: '8px',
|
|
300
|
+
});
|
|
301
|
+
`,
|
|
302
|
+
output: `
|
|
303
|
+
import { style } from '@vanilla-extract/css';
|
|
304
|
+
const myStyle = style({
|
|
305
|
+
borderStartStartRadius: '4px',
|
|
306
|
+
borderEndEndRadius: '8px',
|
|
307
|
+
});
|
|
308
|
+
`,
|
|
309
|
+
errors: [
|
|
310
|
+
{ messageId: 'preferLogicalProperty' },
|
|
311
|
+
{ messageId: 'preferLogicalProperty' },
|
|
312
|
+
],
|
|
313
|
+
name: 'reports and fixes border radius properties',
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
code: `
|
|
317
|
+
import { style } from '@vanilla-extract/css';
|
|
318
|
+
const myStyle = style({
|
|
319
|
+
width: '100px',
|
|
320
|
+
height: '200px',
|
|
321
|
+
minWidth: '50px',
|
|
322
|
+
maxHeight: '400px',
|
|
323
|
+
});
|
|
324
|
+
`,
|
|
325
|
+
output: `
|
|
326
|
+
import { style } from '@vanilla-extract/css';
|
|
327
|
+
const myStyle = style({
|
|
328
|
+
inlineSize: '100px',
|
|
329
|
+
blockSize: '200px',
|
|
330
|
+
minInlineSize: '50px',
|
|
331
|
+
maxBlockSize: '400px',
|
|
332
|
+
});
|
|
333
|
+
`,
|
|
334
|
+
errors: [
|
|
335
|
+
{ messageId: 'preferLogicalProperty' },
|
|
336
|
+
{ messageId: 'preferLogicalProperty' },
|
|
337
|
+
{ messageId: 'preferLogicalProperty' },
|
|
338
|
+
{ messageId: 'preferLogicalProperty' },
|
|
339
|
+
],
|
|
340
|
+
name: 'reports and fixes size properties',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
code: `
|
|
344
|
+
import { style } from '@vanilla-extract/css';
|
|
345
|
+
const myStyle = style({
|
|
346
|
+
overflowX: 'auto',
|
|
347
|
+
overflowY: 'hidden',
|
|
348
|
+
});
|
|
349
|
+
`,
|
|
350
|
+
output: `
|
|
351
|
+
import { style } from '@vanilla-extract/css';
|
|
352
|
+
const myStyle = style({
|
|
353
|
+
overflowInline: 'auto',
|
|
354
|
+
overflowBlock: 'hidden',
|
|
355
|
+
});
|
|
356
|
+
`,
|
|
357
|
+
errors: [
|
|
358
|
+
{ messageId: 'preferLogicalProperty' },
|
|
359
|
+
{ messageId: 'preferLogicalProperty' },
|
|
360
|
+
],
|
|
361
|
+
name: 'reports and fixes overflow properties',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
code: `
|
|
365
|
+
import { style } from '@vanilla-extract/css';
|
|
366
|
+
const myStyle = style({
|
|
367
|
+
textAlign: 'left',
|
|
368
|
+
float: 'right',
|
|
369
|
+
clear: 'left',
|
|
370
|
+
resize: 'horizontal',
|
|
371
|
+
});
|
|
372
|
+
`,
|
|
373
|
+
output: `
|
|
374
|
+
import { style } from '@vanilla-extract/css';
|
|
375
|
+
const myStyle = style({
|
|
376
|
+
textAlign: 'start',
|
|
377
|
+
float: 'inline-end',
|
|
378
|
+
clear: 'inline-start',
|
|
379
|
+
resize: 'inline',
|
|
380
|
+
});
|
|
381
|
+
`,
|
|
382
|
+
errors: [
|
|
383
|
+
{
|
|
384
|
+
messageId: 'preferLogicalValue',
|
|
385
|
+
data: { property: 'textAlign', physical: 'left', logical: 'start' },
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
messageId: 'preferLogicalValue',
|
|
389
|
+
data: { property: 'float', physical: 'right', logical: 'inline-end' },
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
messageId: 'preferLogicalValue',
|
|
393
|
+
data: { property: 'clear', physical: 'left', logical: 'inline-start' },
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
messageId: 'preferLogicalValue',
|
|
397
|
+
data: { property: 'resize', physical: 'horizontal', logical: 'inline' },
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
name: 'reports and fixes directional values',
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
code: `
|
|
404
|
+
import { recipe } from '@vanilla-extract/css';
|
|
405
|
+
const myRecipe = recipe({
|
|
406
|
+
base: {
|
|
407
|
+
marginLeft: '1rem',
|
|
408
|
+
paddingTop: '2rem',
|
|
409
|
+
},
|
|
410
|
+
variants: {
|
|
411
|
+
size: {
|
|
412
|
+
sm: { left: 0 },
|
|
413
|
+
lg: { borderRightWidth: '2px' },
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
`,
|
|
418
|
+
output: `
|
|
419
|
+
import { recipe } from '@vanilla-extract/css';
|
|
420
|
+
const myRecipe = recipe({
|
|
421
|
+
base: {
|
|
422
|
+
marginInlineStart: '1rem',
|
|
423
|
+
paddingBlockStart: '2rem',
|
|
424
|
+
},
|
|
425
|
+
variants: {
|
|
426
|
+
size: {
|
|
427
|
+
sm: { insetInlineStart: 0 },
|
|
428
|
+
lg: { borderInlineEndWidth: '2px' },
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
`,
|
|
433
|
+
errors: [
|
|
434
|
+
{ messageId: 'preferLogicalProperty' },
|
|
435
|
+
{ messageId: 'preferLogicalProperty' },
|
|
436
|
+
{ messageId: 'preferLogicalProperty' },
|
|
437
|
+
{ messageId: 'preferLogicalProperty' },
|
|
438
|
+
],
|
|
439
|
+
name: 'reports and fixes physical properties in recipe base and variants',
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
code: `
|
|
443
|
+
import { style } from '@vanilla-extract/css';
|
|
444
|
+
const myStyle = style({
|
|
445
|
+
'@media': {
|
|
446
|
+
'(min-width: 768px)': {
|
|
447
|
+
marginLeft: '2rem',
|
|
448
|
+
paddingTop: '1rem',
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
selectors: {
|
|
452
|
+
'&:hover': {
|
|
453
|
+
right: 0,
|
|
454
|
+
bottom: 0,
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
`,
|
|
459
|
+
output: `
|
|
460
|
+
import { style } from '@vanilla-extract/css';
|
|
461
|
+
const myStyle = style({
|
|
462
|
+
'@media': {
|
|
463
|
+
'(min-width: 768px)': {
|
|
464
|
+
marginInlineStart: '2rem',
|
|
465
|
+
paddingBlockStart: '1rem',
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
selectors: {
|
|
469
|
+
'&:hover': {
|
|
470
|
+
insetInlineEnd: 0,
|
|
471
|
+
insetBlockEnd: 0,
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
`,
|
|
476
|
+
errors: [
|
|
477
|
+
{ messageId: 'preferLogicalProperty' },
|
|
478
|
+
{ messageId: 'preferLogicalProperty' },
|
|
479
|
+
{ messageId: 'preferLogicalProperty' },
|
|
480
|
+
{ messageId: 'preferLogicalProperty' },
|
|
481
|
+
],
|
|
482
|
+
name: 'reports and fixes physical properties in nested @media and selectors',
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
code: `
|
|
486
|
+
import { style } from '@vanilla-extract/css';
|
|
487
|
+
const myStyle = style({
|
|
488
|
+
scrollMarginLeft: '10px',
|
|
489
|
+
scrollPaddingTop: '20px',
|
|
490
|
+
});
|
|
491
|
+
`,
|
|
492
|
+
output: `
|
|
493
|
+
import { style } from '@vanilla-extract/css';
|
|
494
|
+
const myStyle = style({
|
|
495
|
+
scrollMarginInlineStart: '10px',
|
|
496
|
+
scrollPaddingBlockStart: '20px',
|
|
497
|
+
});
|
|
498
|
+
`,
|
|
499
|
+
errors: [
|
|
500
|
+
{ messageId: 'preferLogicalProperty' },
|
|
501
|
+
{ messageId: 'preferLogicalProperty' },
|
|
502
|
+
],
|
|
503
|
+
name: 'reports and fixes scroll margin and padding properties',
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
code: `
|
|
507
|
+
import { style } from '@vanilla-extract/css';
|
|
508
|
+
const myStyle = style({
|
|
509
|
+
overscrollBehaviorX: 'contain',
|
|
510
|
+
overscrollBehaviorY: 'auto',
|
|
511
|
+
});
|
|
512
|
+
`,
|
|
513
|
+
output: `
|
|
514
|
+
import { style } from '@vanilla-extract/css';
|
|
515
|
+
const myStyle = style({
|
|
516
|
+
overscrollBehaviorInline: 'contain',
|
|
517
|
+
overscrollBehaviorBlock: 'auto',
|
|
518
|
+
});
|
|
519
|
+
`,
|
|
520
|
+
errors: [
|
|
521
|
+
{ messageId: 'preferLogicalProperty' },
|
|
522
|
+
{ messageId: 'preferLogicalProperty' },
|
|
523
|
+
],
|
|
524
|
+
name: 'reports and fixes overscroll behavior properties',
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
code: `
|
|
528
|
+
import { style } from '@vanilla-extract/css';
|
|
529
|
+
const myStyle = style({
|
|
530
|
+
marginLeft: \`1rem\`,
|
|
531
|
+
textAlign: \`left\`,
|
|
532
|
+
});
|
|
533
|
+
`,
|
|
534
|
+
output: `
|
|
535
|
+
import { style } from '@vanilla-extract/css';
|
|
536
|
+
const myStyle = style({
|
|
537
|
+
marginInlineStart: \`1rem\`,
|
|
538
|
+
textAlign: \`start\`,
|
|
539
|
+
});
|
|
540
|
+
`,
|
|
541
|
+
errors: [
|
|
542
|
+
{ messageId: 'preferLogicalProperty' },
|
|
543
|
+
{ messageId: 'preferLogicalValue' },
|
|
544
|
+
],
|
|
545
|
+
name: 'handles template literals',
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
code: `
|
|
549
|
+
import { style } from '@vanilla-extract/css';
|
|
550
|
+
const myStyle = style({
|
|
551
|
+
marginLeft: '1rem',
|
|
552
|
+
paddingTop: '2rem',
|
|
553
|
+
});
|
|
554
|
+
`,
|
|
555
|
+
options: [{ allow: ['paddingTop'] }],
|
|
556
|
+
output: `
|
|
557
|
+
import { style } from '@vanilla-extract/css';
|
|
558
|
+
const myStyle = style({
|
|
559
|
+
marginInlineStart: '1rem',
|
|
560
|
+
paddingTop: '2rem',
|
|
561
|
+
});
|
|
562
|
+
`,
|
|
563
|
+
errors: [
|
|
564
|
+
{
|
|
565
|
+
messageId: 'preferLogicalProperty',
|
|
566
|
+
data: { physical: 'marginLeft', logical: 'marginInlineStart' },
|
|
567
|
+
},
|
|
568
|
+
],
|
|
569
|
+
name: 'only reports non-allowlisted properties',
|
|
570
|
+
},
|
|
571
|
+
],
|
|
572
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
3
|
+
export interface LogicalPropertiesOptions {
|
|
4
|
+
allow?: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Recursively processes a vanilla-extract style object and reports physical CSS properties.
|
|
8
|
+
*
|
|
9
|
+
* - Detects physical property names and suggests logical equivalents
|
|
10
|
+
* - Detects physical directional values (e.g., text-align: left)
|
|
11
|
+
* - Skips properties in the allow list
|
|
12
|
+
* - Provides auto-fixes where unambiguous
|
|
13
|
+
* - Traverses nested objects, @media, and selectors
|
|
14
|
+
*
|
|
15
|
+
* @param context ESLint rule context
|
|
16
|
+
* @param node The ObjectExpression node representing the style object
|
|
17
|
+
* @param allowSet Set of property names to skip
|
|
18
|
+
*/
|
|
19
|
+
export declare const processLogicalPropertiesInStyleObject: (context: Rule.RuleContext, node: TSESTree.ObjectExpression, allowSet: Set<string>) => void;
|