@antebudimir/eslint-plugin-vanilla-extract 1.15.1 → 1.17.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 CHANGED
@@ -264,6 +264,7 @@ The recommended configuration enables the following rules with error severity:
264
264
  - `vanilla-extract/alphabetical-order`: Alternative ordering rule (alphabetical sorting)
265
265
  - `vanilla-extract/custom-order`: Alternative ordering rule (custom group-based sorting)
266
266
  - `vanilla-extract/no-px-unit`: Disallows px units with an optional allowlist
267
+ - `vanilla-extract/no-unitless-values`: Disallows unitless numeric values for CSS properties that require units
267
268
  - `vanilla-extract/prefer-logical-properties`: Enforces logical CSS properties over physical directional properties
268
269
  - `vanilla-extract/prefer-theme-tokens`: Enforces theme tokens instead of hard-coded values for colors, spacing, font sizes, border radius, border widths, shadows, z-index, opacity, font weights, and transitions/animations (optionally evaluates helper functions and template literals)
269
270
 
@@ -303,6 +304,36 @@ export default [
303
304
 
304
305
  > **Note:** Remember to enable only one ordering rule at a time. See the "Important" section above for details on switching between ordering rules.
305
306
 
307
+ ### Global Settings (Recommended for shared wrappers)
308
+
309
+ If you use imported wrapper functions across multiple ordering rules, configure them once in ESLint `settings`.
310
+ All ordering rules (`alphabetical-order`, `concentric-order`, `custom-order`) read this value.
311
+
312
+ ```typescript
313
+ import { defineConfig } from 'eslint/config';
314
+ import vanillaExtract from '@antebudimir/eslint-plugin-vanilla-extract';
315
+
316
+ export default defineConfig([
317
+ {
318
+ files: ['**/*.css.ts'],
319
+ plugins: {
320
+ 'vanilla-extract': vanillaExtract,
321
+ },
322
+ settings: {
323
+ 'vanilla-extract': {
324
+ style: ['componentStyle', 'layerStyle'],
325
+ recipe: ['componentRecipe'],
326
+ },
327
+ },
328
+ rules: {
329
+ ...vanillaExtract.configs.recommended.rules,
330
+ },
331
+ },
332
+ ]);
333
+ ```
334
+
335
+ Configure wrapper names only via ESLint `settings` (`style`, `recipe`).
336
+
306
337
  ## Rules
307
338
 
308
339
  ### vanilla-extract/alphabetical-order
@@ -335,6 +366,32 @@ export const myStyle = style({
335
366
  });
336
367
  ```
337
368
 
369
+ #### Global setting: `settings['vanilla-extract'].style`
370
+
371
+ `vanilla-extract/alphabetical-order` reads wrapper names from global ESLint settings.
372
+
373
+ ```typescript
374
+ import { defineConfig } from 'eslint/config';
375
+ import vanillaExtract from '@antebudimir/eslint-plugin-vanilla-extract';
376
+
377
+ export default defineConfig([
378
+ {
379
+ files: ['**/*.css.ts'],
380
+ plugins: {
381
+ 'vanilla-extract': vanillaExtract,
382
+ },
383
+ settings: {
384
+ 'vanilla-extract': {
385
+ style: ['componentStyle'],
386
+ },
387
+ },
388
+ rules: {
389
+ 'vanilla-extract/alphabetical-order': 'error',
390
+ },
391
+ },
392
+ ]);
393
+ ```
394
+
338
395
  ### vanilla-extract/concentric-order
339
396
 
340
397
  This rule enforces that CSS properties in vanilla-extract style objects follow the [concentric CSS](#concentric-css-model) ordering pattern, which organizes properties from outside to inside.
@@ -363,6 +420,33 @@ export const myStyle = style({
363
420
  });
364
421
  ```
365
422
 
423
+ #### Global setting: `settings['vanilla-extract'].style`
424
+
425
+ Use this setting when style wrappers are imported from local modules (for example `componentStyle`, `layerStyle`).
426
+ If a wrapper function name is listed, the rule treats calls to that function like `style(...)` calls.
427
+
428
+ ```typescript
429
+ import { defineConfig } from 'eslint/config';
430
+ import vanillaExtract from '@antebudimir/eslint-plugin-vanilla-extract';
431
+
432
+ export default defineConfig([
433
+ {
434
+ files: ['**/*.css.ts'],
435
+ plugins: {
436
+ 'vanilla-extract': vanillaExtract,
437
+ },
438
+ settings: {
439
+ 'vanilla-extract': {
440
+ style: ['componentStyle', 'layerStyle'],
441
+ },
442
+ },
443
+ rules: {
444
+ 'vanilla-extract/concentric-order': 'error',
445
+ },
446
+ },
447
+ ]);
448
+ ```
449
+
366
450
  ### vanilla-extract/custom-order
367
451
 
368
452
  The `vanilla-extract/custom-order` rule enables you to enforce a custom ordering of CSS properties in your
@@ -387,6 +471,39 @@ To configure the rule, add it to your ESLint configuration file with your desire
387
471
  `groups` array to include any number of available CSS property groups you want to enforce, with a minimum of one group
388
472
  required.
389
473
 
474
+ #### Global setting: `settings['vanilla-extract'].style`
475
+
476
+ `vanilla-extract/custom-order` also reads `style` from global settings together with
477
+ `groupOrder` and `sortRemainingProperties`.
478
+
479
+ ```typescript
480
+ import { defineConfig } from 'eslint/config';
481
+ import vanillaExtract from '@antebudimir/eslint-plugin-vanilla-extract';
482
+
483
+ export default defineConfig([
484
+ {
485
+ files: ['**/*.css.ts'],
486
+ plugins: {
487
+ 'vanilla-extract': vanillaExtract,
488
+ },
489
+ settings: {
490
+ 'vanilla-extract': {
491
+ style: ['componentStyle'],
492
+ },
493
+ },
494
+ rules: {
495
+ 'vanilla-extract/custom-order': [
496
+ 'error',
497
+ {
498
+ groupOrder: ['font', 'dimensions', 'margin', 'padding', 'position', 'border'],
499
+ sortRemainingProperties: 'alphabetical',
500
+ },
501
+ ],
502
+ },
503
+ },
504
+ ]);
505
+ ```
506
+
390
507
  ```typescript
391
508
  // ❌ Incorrect (Unordered)
392
509
  import { style } from '@vanilla-extract/css';
@@ -536,6 +653,77 @@ export const myStyle = style({
536
653
  });
537
654
  ```
538
655
 
656
+ ### vanilla-extract/no-unitless-values
657
+
658
+ This rule disallows unitless numeric values for CSS properties that require units in vanilla-extract style objects. It helps teams that prefer explicit units avoid confusion, as vanilla-extract automatically converts unitless numbers to `px` at runtime.
659
+
660
+ **Note:** This is an optional rule (not enabled in recommended config). Enable it only if your team prefers explicit units over vanilla-extract's automatic `px` conversion.
661
+
662
+ Configuration with allowed properties:
663
+
664
+ ```json
665
+ {
666
+ "rules": {
667
+ "vanilla-extract/no-unitless-values": ["warn", { "allow": ["width", "height"] }]
668
+ }
669
+ }
670
+ ```
671
+
672
+ ```typescript
673
+ // ❌ Incorrect
674
+ import { style } from '@vanilla-extract/css';
675
+
676
+ export const myStyle = style({
677
+ width: 100,
678
+ margin: 20,
679
+ padding: 10.5,
680
+ height: '50',
681
+ top: '-10',
682
+ });
683
+
684
+ // ✅ Correct
685
+ import { style } from '@vanilla-extract/css';
686
+
687
+ export const myStyle = style({
688
+ width: '100px',
689
+ margin: '20px',
690
+ padding: 0,
691
+ height: '50rem',
692
+ opacity: 0.5, // opacity accepts unitless values
693
+ lineHeight: 1.5, // line-height accepts unitless values
694
+ zIndex: 10, // z-index accepts unitless values
695
+ });
696
+ ```
697
+
698
+ **Properties that require units:**
699
+
700
+ - **Box model:** `width`, `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `min-width`, `max-width`, `min-height`, `max-height`
701
+ - **Spacing:** `margin`, `marginTop`, `marginRight`, `marginBottom`, `marginLeft`, `marginBlock`, `marginBlockStart`, `marginBlockEnd`, `marginInline`, `marginInlineStart`, `marginInlineEnd`, `margin-top`, `margin-right`, `margin-bottom`, `margin-left`, `margin-block`, `margin-block-start`, `margin-block-end`, `margin-inline`, `margin-inline-start`, `margin-inline-end`, `padding`, `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft`, `paddingBlock`, `paddingBlockStart`, `paddingBlockEnd`, `paddingInline`, `paddingInlineStart`, `paddingInlineEnd`, `padding-top`, `padding-right`, `padding-bottom`, `padding-left`, `padding-block`, `padding-block-start`, `padding-block-end`, `padding-inline`, `padding-inline-start`, `padding-inline-end`
702
+ - **Positioning:** `top`, `right`, `bottom`, `left`, `inset`, `insetBlock`, `insetBlockStart`, `insetBlockEnd`, `insetInline`, `insetInlineStart`, `insetInlineEnd`, `inset-block`, `inset-block-start`, `inset-block-end`, `inset-inline`, `inset-inline-start`, `inset-inline-end`
703
+ - **Border:** `borderWidth`, `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth`, `borderBlockWidth`, `borderBlockStartWidth`, `borderBlockEndWidth`, `borderInlineWidth`, `borderInlineStartWidth`, `borderInlineEndWidth`, `border-width`, `border-top-width`, `border-right-width`, `border-bottom-width`, `border-left-width`, `border-block-width`, `border-block-start-width`, `border-block-end-width`, `border-inline-width`, `border-inline-start-width`, `border-inline-end-width`, `borderRadius`, `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomLeftRadius`, `borderBottomRightRadius`, `borderStartStartRadius`, `borderStartEndRadius`, `borderEndStartRadius`, `borderEndEndRadius`, `border-radius`, `border-top-left-radius`, `border-top-right-radius`, `border-bottom-left-radius`, `border-bottom-right-radius`, `border-start-start-radius`, `border-start-end-radius`, `border-end-start-radius`, `border-end-end-radius`
704
+ - **Typography:** `fontSize`, `font-size`, `letterSpacing`, `letter-spacing`, `wordSpacing`, `word-spacing`, `textIndent`, `text-indent`
705
+ - **Layout:** `gap`, `rowGap`, `columnGap`, `row-gap`, `column-gap`, `flexBasis`, `flex-basis`
706
+ - **Outline:** `outlineWidth`, `outline-width`, `outlineOffset`, `outline-offset`
707
+ - **Other:** `blockSize`, `inlineSize`, `minBlockSize`, `maxBlockSize`, `minInlineSize`, `maxInlineSize`, `block-size`, `inline-size`, `min-block-size`, `max-block-size`, `min-inline-size`, `max-inline-size`
708
+
709
+ **Properties that accept unitless values:**
710
+
711
+ - **Common:** `opacity`, `zIndex`, `z-index`, `lineHeight`, `line-height`, `flexGrow`, `flex-grow`, `flexShrink`, `flex-shrink`, `order`, `fontWeight`, `font-weight`, `zoom`
712
+ - **Animation:** `animationIterationCount`, `animation-iteration-count`
713
+ - **Layout:** `columnCount`, `column-count`, `orphans`, `widows`
714
+ - **Grid:** `gridColumn`, `grid-column`, `gridColumnEnd`, `grid-column-end`, `gridColumnStart`, `grid-column-start`, `gridRow`, `grid-row`, `gridRowEnd`, `grid-row-end`, `gridRowStart`, `grid-row-start`
715
+ - **SVG:** `fillOpacity`, `fill-opacity`, `strokeOpacity`, `stroke-opacity`, `strokeMiterlimit`, `stroke-miterlimit`
716
+
717
+ **Why use this rule?**
718
+
719
+ While vanilla-extract safely converts unitless numbers to `px`, some teams prefer explicit units because:
720
+
721
+ 1. It makes the intended unit clear (px, rem, em, %, etc.)
722
+ 2. It prevents accidental use of px when rem or other units are preferred
723
+ 3. It aligns with CSS best practices of being explicit about units
724
+
725
+ **Auto-fix:** Not available. Since different teams prefer different units (px, rem, em, %), you must manually add your preferred unit.
726
+
539
727
  ### vanilla-extract/no-unknown-unit
540
728
 
541
729
  This rule enforces the use of valid CSS units in vanilla-extract style objects. It prevents typos and non-standard units
@@ -835,10 +1023,7 @@ The roadmap outlines the project's current status and future plans:
835
1023
  - `no-px-unit` rule to disallow use of `px` units with configurable whitelist.
836
1024
  - `prefer-logical-properties` rule to enforce use of logical properties.
837
1025
  - `prefer-theme-tokens` rule to enforce theme tokens instead of hard-coded values for colors, spacing, font sizes, border radius, border widths, shadows, z-index, opacity, font weights, and transitions/animations (optionally evaluates helper functions and template literals).
838
-
839
- ### Current Work
840
-
841
- - `no-unitless-values` rule that disallows numeric literals for CSS properties that are not unitless in CSS.
1026
+ - `no-unitless-values` rule to disallow unitless numeric values for CSS properties that require units.
842
1027
 
843
1028
  ### Upcoming Features
844
1029
 
@@ -1 +1,2 @@
1
- export { default } from './rule-definition.js';
1
+ import noTrailingZeroRule from './rule-definition.js';
2
+ export default noTrailingZeroRule;
@@ -1 +1,2 @@
1
- export { default } from './rule-definition.js';
1
+ import noTrailingZeroRule from './rule-definition.js';
2
+ export default noTrailingZeroRule;
@@ -0,0 +1,444 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import noUnitlessValuesRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/no-unitless-values',
6
+ rule: noUnitlessValuesRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // Zero values are allowed
16
+ {
17
+ code: `
18
+ import { style } from '@vanilla-extract/css';
19
+ const myStyle = style({
20
+ margin: 0,
21
+ padding: 0,
22
+ width: 0,
23
+ });
24
+ `,
25
+ name: 'should allow zero values without units',
26
+ },
27
+ // String values with units
28
+ {
29
+ code: `
30
+ import { style } from '@vanilla-extract/css';
31
+ const myStyle = style({
32
+ width: '100px',
33
+ margin: '20px',
34
+ padding: '1rem',
35
+ fontSize: '16px',
36
+ });
37
+ `,
38
+ name: 'should allow string values with units',
39
+ },
40
+ // String zero values
41
+ {
42
+ code: `
43
+ import { style } from '@vanilla-extract/css';
44
+ const myStyle = style({
45
+ margin: '0',
46
+ padding: '0',
47
+ });
48
+ `,
49
+ name: 'should allow string zero values without units',
50
+ },
51
+ // Unitless-valid properties
52
+ {
53
+ code: `
54
+ import { style } from '@vanilla-extract/css';
55
+ const myStyle = style({
56
+ opacity: 0.5,
57
+ zIndex: 10,
58
+ lineHeight: 1.5,
59
+ flexGrow: 1,
60
+ flexShrink: 0,
61
+ order: 2,
62
+ fontWeight: 700,
63
+ zoom: 1.2,
64
+ });
65
+ `,
66
+ name: 'should allow unitless values for properties that accept them',
67
+ },
68
+ // Recipe with valid values
69
+ {
70
+ code: `
71
+ import { recipe } from '@vanilla-extract/css';
72
+ const myRecipe = recipe({
73
+ base: {
74
+ margin: '0',
75
+ padding: 0,
76
+ opacity: 0.8,
77
+ },
78
+ variants: {
79
+ size: {
80
+ small: {
81
+ height: '10px',
82
+ width: '10px',
83
+ zIndex: 1,
84
+ },
85
+ },
86
+ },
87
+ });
88
+ `,
89
+ name: 'should allow valid values in recipe',
90
+ },
91
+ // Template literals (not checked)
92
+ {
93
+ code: `
94
+ import { style } from '@vanilla-extract/css';
95
+ const myStyle = style({
96
+ margin: \`\${someValue}px\`,
97
+ padding: someVariable,
98
+ });
99
+ `,
100
+ name: 'should ignore template literals and variables',
101
+ },
102
+ // Nested selectors with valid values
103
+ {
104
+ code: `
105
+ import { style } from '@vanilla-extract/css';
106
+ const myStyle = style({
107
+ width: '100px',
108
+ ':hover': {
109
+ margin: '20px',
110
+ opacity: 0.8,
111
+ },
112
+ });
113
+ `,
114
+ name: 'should allow valid values in nested selectors',
115
+ },
116
+ // Media queries with valid values
117
+ {
118
+ code: `
119
+ import { style } from '@vanilla-extract/css';
120
+ const myStyle = style({
121
+ margin: 0,
122
+ '@media': {
123
+ '(min-width: 768px)': {
124
+ padding: '20px',
125
+ zIndex: 10,
126
+ }
127
+ }
128
+ });
129
+ `,
130
+ name: 'should allow valid values in media queries',
131
+ },
132
+ // globalStyle with valid values
133
+ {
134
+ code: `
135
+ import { globalStyle } from '@vanilla-extract/css';
136
+ globalStyle('html', {
137
+ margin: '0',
138
+ padding: 0,
139
+ lineHeight: 1.5,
140
+ });
141
+ `,
142
+ name: 'should allow valid values in globalStyle',
143
+ },
144
+ // fontFace with valid values
145
+ {
146
+ code: `
147
+ import { fontFace } from '@vanilla-extract/css';
148
+ fontFace({
149
+ src: 'url(...)',
150
+ fontWeight: 400,
151
+ });
152
+ `,
153
+ name: 'should allow valid values in fontFace',
154
+ },
155
+ // keyframes (animation values are strings)
156
+ {
157
+ code: `
158
+ import { keyframes } from '@vanilla-extract/css';
159
+ const spin = keyframes({
160
+ '0%': { transform: 'rotate(0deg)' },
161
+ '100%': { transform: 'rotate(360deg)' }
162
+ });
163
+ `,
164
+ name: 'should allow keyframes with string values',
165
+ },
166
+ // allow option
167
+ {
168
+ code: `
169
+ import { style } from '@vanilla-extract/css';
170
+ const myStyle = style({
171
+ width: 100,
172
+ margin: '20px',
173
+ });
174
+ `,
175
+ options: [{ allow: ['width'] }],
176
+ name: 'should allow properties specified in allow option',
177
+ },
178
+ // Kebab-case unitless-valid properties
179
+ {
180
+ code: `
181
+ import { style } from '@vanilla-extract/css';
182
+ const myStyle = style({
183
+ 'z-index': 10,
184
+ 'line-height': 1.5,
185
+ 'flex-grow': 1,
186
+ });
187
+ `,
188
+ name: 'should allow unitless values for kebab-case unitless-valid properties',
189
+ },
190
+ ],
191
+ invalid: [
192
+ // Basic unitless values
193
+ {
194
+ code: `
195
+ import { style } from '@vanilla-extract/css';
196
+ const myStyle = style({
197
+ width: 100,
198
+ margin: 20,
199
+ });
200
+ `,
201
+ errors: [
202
+ { messageId: 'noUnitlessValue', data: { property: 'width', value: '100' } },
203
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '20' } },
204
+ ],
205
+ name: 'should flag unitless numeric values for length properties',
206
+ },
207
+ // Decimal values
208
+ {
209
+ code: `
210
+ import { style } from '@vanilla-extract/css';
211
+ const myStyle = style({
212
+ padding: 10.5,
213
+ fontSize: 16.5,
214
+ });
215
+ `,
216
+ errors: [
217
+ { messageId: 'noUnitlessValue', data: { property: 'padding', value: '10.5' } },
218
+ { messageId: 'noUnitlessValue', data: { property: 'fontSize', value: '16.5' } },
219
+ ],
220
+ name: 'should flag decimal unitless values',
221
+ },
222
+ // Recipe with unitless values
223
+ {
224
+ code: `
225
+ import { recipe } from '@vanilla-extract/css';
226
+ const myRecipe = recipe({
227
+ base: {
228
+ margin: 10,
229
+ },
230
+ variants: {
231
+ size: {
232
+ small: {
233
+ height: 20,
234
+ },
235
+ },
236
+ },
237
+ });
238
+ `,
239
+ errors: [
240
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '10' } },
241
+ { messageId: 'noUnitlessValue', data: { property: 'height', value: '20' } },
242
+ ],
243
+ name: 'should flag unitless values in recipe',
244
+ },
245
+ // Nested selectors with unitless values
246
+ {
247
+ code: `
248
+ import { style } from '@vanilla-extract/css';
249
+ const myStyle = style({
250
+ width: 100,
251
+ ':hover': {
252
+ margin: 20,
253
+ },
254
+ });
255
+ `,
256
+ errors: [
257
+ { messageId: 'noUnitlessValue', data: { property: 'width', value: '100' } },
258
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '20' } },
259
+ ],
260
+ name: 'should flag unitless values in nested selectors',
261
+ },
262
+ // Media queries with unitless values
263
+ {
264
+ code: `
265
+ import { style } from '@vanilla-extract/css';
266
+ const myStyle = style({
267
+ '@media': {
268
+ '(min-width: 768px)': {
269
+ padding: 20,
270
+ }
271
+ }
272
+ });
273
+ `,
274
+ errors: [{ messageId: 'noUnitlessValue', data: { property: 'padding', value: '20' } }],
275
+ name: 'should flag unitless values in media queries',
276
+ },
277
+ // Multiple levels of nesting
278
+ {
279
+ code: `
280
+ import { style } from '@vanilla-extract/css';
281
+ const myStyle = style({
282
+ margin: 10,
283
+ nested: {
284
+ object: {
285
+ padding: 20,
286
+ deeper: {
287
+ width: 30
288
+ }
289
+ }
290
+ }
291
+ });
292
+ `,
293
+ errors: [
294
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '10' } },
295
+ { messageId: 'noUnitlessValue', data: { property: 'padding', value: '20' } },
296
+ { messageId: 'noUnitlessValue', data: { property: 'width', value: '30' } },
297
+ ],
298
+ name: 'should flag unitless values in deeply nested objects',
299
+ },
300
+ // globalStyle with unitless values
301
+ {
302
+ code: `
303
+ import { globalStyle } from '@vanilla-extract/css';
304
+ globalStyle('html', {
305
+ margin: 10,
306
+ padding: 20,
307
+ });
308
+ `,
309
+ errors: [
310
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '10' } },
311
+ { messageId: 'noUnitlessValue', data: { property: 'padding', value: '20' } },
312
+ ],
313
+ name: 'should flag unitless values in globalStyle',
314
+ },
315
+ // Various length properties
316
+ {
317
+ code: `
318
+ import { style } from '@vanilla-extract/css';
319
+ const myStyle = style({
320
+ width: 100,
321
+ height: 200,
322
+ minWidth: 50,
323
+ maxWidth: 500,
324
+ top: 10,
325
+ left: 20,
326
+ borderWidth: 2,
327
+ borderRadius: 5,
328
+ gap: 15,
329
+ fontSize: 16,
330
+ });
331
+ `,
332
+ errors: 10,
333
+ name: 'should flag all unitless values for various length properties',
334
+ },
335
+ // Kebab-case properties
336
+ {
337
+ code: `
338
+ import { style } from '@vanilla-extract/css';
339
+ const myStyle = style({
340
+ 'margin-top': 10,
341
+ 'padding-left': 20,
342
+ 'font-size': 16,
343
+ });
344
+ `,
345
+ errors: [
346
+ { messageId: 'noUnitlessValue', data: { property: 'margin-top', value: '10' } },
347
+ { messageId: 'noUnitlessValue', data: { property: 'padding-left', value: '20' } },
348
+ { messageId: 'noUnitlessValue', data: { property: 'font-size', value: '16' } },
349
+ ],
350
+ name: 'should flag unitless values for kebab-case properties',
351
+ },
352
+ // Logical properties
353
+ {
354
+ code: `
355
+ import { style } from '@vanilla-extract/css';
356
+ const myStyle = style({
357
+ marginBlock: 10,
358
+ paddingInline: 20,
359
+ insetBlockStart: 5,
360
+ });
361
+ `,
362
+ errors: [
363
+ { messageId: 'noUnitlessValue', data: { property: 'marginBlock', value: '10' } },
364
+ { messageId: 'noUnitlessValue', data: { property: 'paddingInline', value: '20' } },
365
+ { messageId: 'noUnitlessValue', data: { property: 'insetBlockStart', value: '5' } },
366
+ ],
367
+ name: 'should flag unitless values for logical properties',
368
+ },
369
+ // styleVariants
370
+ {
371
+ code: `
372
+ import { styleVariants } from '@vanilla-extract/css';
373
+ const variants = styleVariants({
374
+ small: { width: 10 },
375
+ large: { width: 100 },
376
+ });
377
+ `,
378
+ errors: [
379
+ { messageId: 'noUnitlessValue', data: { property: 'width', value: '10' } },
380
+ { messageId: 'noUnitlessValue', data: { property: 'width', value: '100' } },
381
+ ],
382
+ name: 'should flag unitless values in styleVariants',
383
+ },
384
+ // globalKeyframes
385
+ {
386
+ code: `
387
+ import { globalKeyframes } from '@vanilla-extract/css';
388
+ globalKeyframes('slide', {
389
+ '0%': { left: 0 },
390
+ '100%': { left: 100 }
391
+ });
392
+ `,
393
+ errors: [{ messageId: 'noUnitlessValue', data: { property: 'left', value: '100' } }],
394
+ name: 'should flag unitless values in globalKeyframes',
395
+ },
396
+ // Negative values
397
+ {
398
+ code: `
399
+ import { style } from '@vanilla-extract/css';
400
+ const myStyle = style({
401
+ margin: -10,
402
+ top: -5,
403
+ });
404
+ `,
405
+ errors: [
406
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '-10' } },
407
+ { messageId: 'noUnitlessValue', data: { property: 'top', value: '-5' } },
408
+ ],
409
+ name: 'should flag negative unitless values',
410
+ },
411
+ // String unitless values
412
+ {
413
+ code: `
414
+ import { style } from '@vanilla-extract/css';
415
+ const myStyle = style({
416
+ width: '100',
417
+ margin: '20',
418
+ padding: '10.5',
419
+ });
420
+ `,
421
+ errors: [
422
+ { messageId: 'noUnitlessValue', data: { property: 'width', value: '100' } },
423
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '20' } },
424
+ { messageId: 'noUnitlessValue', data: { property: 'padding', value: '10.5' } },
425
+ ],
426
+ name: 'should flag string unitless values',
427
+ },
428
+ // String negative unitless values
429
+ {
430
+ code: `
431
+ import { style } from '@vanilla-extract/css';
432
+ const myStyle = style({
433
+ margin: '-10',
434
+ top: '-5.5',
435
+ });
436
+ `,
437
+ errors: [
438
+ { messageId: 'noUnitlessValue', data: { property: 'margin', value: '-10' } },
439
+ { messageId: 'noUnitlessValue', data: { property: 'top', value: '-5.5' } },
440
+ ],
441
+ name: 'should flag string negative unitless values',
442
+ },
443
+ ],
444
+ });
@@ -0,0 +1,2 @@
1
+ import noUnitlessValuesRule from './rule-definition.js';
2
+ export default noUnitlessValuesRule;