@antebudimir/eslint-plugin-vanilla-extract 1.4.0 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +7 -3
  2. package/dist/css-rules/alphabetical-order/__tests__/animation.test.js +108 -0
  3. package/dist/css-rules/alphabetical-order/__tests__/font-face.test.js +138 -0
  4. package/dist/css-rules/alphabetical-order/__tests__/global.test.js +51 -0
  5. package/dist/css-rules/alphabetical-order/__tests__/recipe.test.js +91 -0
  6. package/dist/css-rules/alphabetical-order/__tests__/style.test.d.ts +1 -0
  7. package/dist/css-rules/alphabetical-order/__tests__/style.test.js +108 -0
  8. package/dist/css-rules/alphabetical-order/__tests__/variants.test.d.ts +1 -0
  9. package/dist/css-rules/alphabetical-order/__tests__/variants.test.js +63 -0
  10. package/dist/css-rules/concentric-order/__tests__/animation.test.d.ts +1 -0
  11. package/dist/css-rules/concentric-order/__tests__/animation.test.js +69 -0
  12. package/dist/css-rules/concentric-order/__tests__/font-face.test.d.ts +1 -0
  13. package/dist/css-rules/concentric-order/__tests__/font-face.test.js +94 -0
  14. package/dist/css-rules/concentric-order/__tests__/global.test.d.ts +1 -0
  15. package/dist/css-rules/concentric-order/__tests__/global.test.js +57 -0
  16. package/dist/css-rules/concentric-order/__tests__/recipe.test.d.ts +1 -0
  17. package/dist/css-rules/concentric-order/__tests__/recipe.test.js +100 -0
  18. package/dist/css-rules/concentric-order/__tests__/style.test.d.ts +1 -0
  19. package/dist/css-rules/concentric-order/__tests__/style.test.js +126 -0
  20. package/dist/css-rules/concentric-order/__tests__/variants.test.d.ts +1 -0
  21. package/dist/css-rules/concentric-order/__tests__/variants.test.js +133 -0
  22. package/dist/css-rules/custom-order/__tests__/animation.test.d.ts +1 -0
  23. package/dist/css-rules/custom-order/__tests__/animation.test.js +148 -0
  24. package/dist/css-rules/custom-order/__tests__/font-face.test.d.ts +1 -0
  25. package/dist/css-rules/custom-order/__tests__/font-face.test.js +124 -0
  26. package/dist/css-rules/custom-order/__tests__/global.test.d.ts +1 -0
  27. package/dist/css-rules/custom-order/__tests__/global.test.js +124 -0
  28. package/dist/css-rules/custom-order/__tests__/recipe.test.d.ts +1 -0
  29. package/dist/css-rules/custom-order/__tests__/recipe.test.js +208 -0
  30. package/dist/css-rules/custom-order/__tests__/style.test.d.ts +1 -0
  31. package/dist/css-rules/custom-order/__tests__/style.test.js +249 -0
  32. package/dist/css-rules/custom-order/__tests__/variants.test.d.ts +1 -0
  33. package/dist/css-rules/custom-order/__tests__/variants.test.js +184 -0
  34. package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.d.ts +1 -0
  35. package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.js +37 -0
  36. package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.d.ts +1 -0
  37. package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.js +58 -0
  38. package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.d.ts +1 -0
  39. package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.js +125 -0
  40. package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.d.ts +1 -0
  41. package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.js +53 -0
  42. package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.d.ts +1 -0
  43. package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.js +116 -0
  44. package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.d.ts +1 -0
  45. package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.js +55 -0
  46. package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.d.ts +3 -0
  47. package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.js +30 -0
  48. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.d.ts +4 -3
  49. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.js +5 -4
  50. package/dist/css-rules/shared-utils/style-node-processor.js +2 -5
  51. package/dist/index.js +1 -1
  52. package/package.json +10 -3
  53. package/dist/css-rules/shared-utils/font-face-style-processor.d.ts +0 -10
  54. package/dist/css-rules/shared-utils/font-face-style-processor.js +0 -17
  55. package/dist/css-rules/theme-tokens/ast-helpers.d.ts +0 -12
  56. package/dist/css-rules/theme-tokens/ast-helpers.js +0 -80
  57. package/dist/css-rules/theme-tokens/index.d.ts +0 -2
  58. package/dist/css-rules/theme-tokens/index.js +0 -2
  59. package/dist/css-rules/theme-tokens/rule-definition.d.ts +0 -3
  60. package/dist/css-rules/theme-tokens/rule-definition.js +0 -29
  61. package/dist/css-rules/theme-tokens/theme-loader.d.ts +0 -10
  62. package/dist/css-rules/theme-tokens/theme-loader.js +0 -71
  63. package/dist/css-rules/theme-tokens/theme-token-visitor.d.ts +0 -2
  64. package/dist/css-rules/theme-tokens/theme-token-visitor.js +0 -113
  65. /package/dist/css-rules/{theme-tokens/theme-tokens-enforcer.d.ts → alphabetical-order/__tests__/animation.test.d.ts} +0 -0
  66. /package/dist/css-rules/{theme-tokens/theme-tokens-enforcer.js → alphabetical-order/__tests__/font-face.test.d.ts} +0 -0
  67. /package/dist/css-rules/{theme-tokens/value-comparison.d.ts → alphabetical-order/__tests__/global.test.d.ts} +0 -0
  68. /package/dist/css-rules/{theme-tokens/value-comparison.js → alphabetical-order/__tests__/recipe.test.d.ts} +0 -0
package/README.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # @antebudimir/eslint-plugin-vanilla-extract
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@antebudimir/eslint-plugin-vanilla-extract.svg)](https://www.npmjs.com/package/@antebudimir/eslint-plugin-vanilla-extract)
3
+ [![npm version](https://img.shields.io/npm/v/@antebudimir/eslint-plugin-vanilla-extract.svg)](https://www.npmjs.com/package/@antebudimir/eslint-plugin-vanilla-extract) [![CI](https://github.com/antebudimir/eslint-plugin-vanilla-extract/actions/workflows/ci.yml/badge.svg)](https://github.com/antebudimir/eslint-plugin-vanilla-extract/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/antebudimir/eslint-plugin-vanilla-extract/badge.svg?branch=main)](https://coveralls.io/github/antebudimir/eslint-plugin-vanilla-extract?branch=main)
4
4
 
5
5
  An ESLint plugin for enforcing best practices in [vanilla-extract](https://github.com/vanilla-extract-css/vanilla-extract) CSS styles, including CSS property ordering and additional linting rules. Available presets are for alphabetical and [concentric](https://rhodesmill.org/brandon/2011/concentric-css/) CSS ordering. The plugin also supports a custom group ordering option based on groups available in [concentric CSS](src/css-rules/concentric-order/concentric-groups.ts).
6
6
 
7
+ ## Demo
8
+
9
+ ![Plugin Demo](https://github.com/user-attachments/assets/93ba118d-84df-4da0-ac68-fdb429e581d6)
10
+
7
11
  ## Features
8
12
 
9
13
  - Enforces CSS property ordering in vanilla-extract style objects with two available presets:
@@ -253,14 +257,14 @@ The roadmap outlines the project's current status and future plans:
253
257
  - Initial release with support for alphabetical, concentric, and custom group CSS ordering.
254
258
  - Auto-fix capability integrated into ESLint.
255
259
  - Support for multiple vanilla-extract APIs (e.g., `style`, `styleVariants`, `recipe`, `globalStyle`, `fontFace`, etc.).
260
+ - Rules tested.
256
261
 
257
262
  ### Current Work
258
263
 
259
- - Test coverage.
264
+ - `no-empty-blocks` rule to disallow empty blocks.
260
265
 
261
266
  ### Upcoming Features
262
267
 
263
- - `no-empty-blocks` rule to disallow empty blocks.
264
268
  - `no-unknown-units` rule to disallow unknown units.
265
269
  - `no-number-trailing-zeros` rule to disallow trailing zeros in numbers.
266
270
  - `no-zero-unit` rule to disallow units when the value is zero.
@@ -0,0 +1,108 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import alphabeticalOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/alphabetical-order/animation',
6
+ rule: alphabeticalOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // keyframes with alphabetical ordering
16
+ `
17
+ import { keyframes } from '@vanilla-extract/css';
18
+
19
+ const fadeIn = keyframes({
20
+ '0%': {
21
+ opacity: 0,
22
+ transform: 'translateY(10px)'
23
+ },
24
+ '100%': {
25
+ opacity: 1,
26
+ transform: 'translateY(0)'
27
+ }
28
+ });
29
+ `,
30
+ // globalKeyframes with alphabetical ordering
31
+ `
32
+ import { globalKeyframes } from '@vanilla-extract/css';
33
+
34
+ globalKeyframes('fadeIn', {
35
+ '0%': {
36
+ opacity: 0,
37
+ transform: 'translateY(10px)'
38
+ },
39
+ '100%': {
40
+ opacity: 1,
41
+ transform: 'translateY(0)'
42
+ }
43
+ });
44
+ `,
45
+ ],
46
+ invalid: [
47
+ // keyframes with incorrect ordering
48
+ {
49
+ code: `
50
+ import { keyframes } from '@vanilla-extract/css';
51
+ const fadeIn = keyframes({
52
+ '0%': {
53
+ transform: 'translateY(10px)',
54
+ opacity: 0
55
+ },
56
+ '100%': {
57
+ transform: 'translateY(0)',
58
+ opacity: 1
59
+ }
60
+ });
61
+ `,
62
+ errors: [{ messageId: 'alphabeticalOrder' }, { messageId: 'alphabeticalOrder' }],
63
+ output: `
64
+ import { keyframes } from '@vanilla-extract/css';
65
+ const fadeIn = keyframes({
66
+ '0%': {
67
+ opacity: 0,
68
+ transform: 'translateY(10px)'
69
+ },
70
+ '100%': {
71
+ opacity: 1,
72
+ transform: 'translateY(0)'
73
+ }
74
+ });
75
+ `,
76
+ },
77
+ // globalKeyframes with incorrect ordering
78
+ {
79
+ code: `
80
+ import { globalKeyframes } from '@vanilla-extract/css';
81
+ globalKeyframes('fadeIn', {
82
+ '0%': {
83
+ transform: 'translateY(10px)',
84
+ opacity: 0
85
+ },
86
+ '100%': {
87
+ transform: 'translateY(0)',
88
+ opacity: 1
89
+ }
90
+ });
91
+ `,
92
+ errors: [{ messageId: 'alphabeticalOrder' }, { messageId: 'alphabeticalOrder' }],
93
+ output: `
94
+ import { globalKeyframes } from '@vanilla-extract/css';
95
+ globalKeyframes('fadeIn', {
96
+ '0%': {
97
+ opacity: 0,
98
+ transform: 'translateY(10px)'
99
+ },
100
+ '100%': {
101
+ opacity: 1,
102
+ transform: 'translateY(0)'
103
+ }
104
+ });
105
+ `,
106
+ },
107
+ ],
108
+ });
@@ -0,0 +1,138 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import alphabeticalOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/alphabetical-order/font-face',
6
+ rule: alphabeticalOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // fontFace with src first and other properties alphabetically ordered
16
+ `
17
+ import { fontFace } from '@vanilla-extract/css';
18
+
19
+ const myFont = fontFace({
20
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
21
+ ascentOverride: '90%',
22
+ descentOverride: '10%',
23
+ fontDisplay: 'swap',
24
+ fontFeatureSettings: '"liga" 1',
25
+ fontStretch: 'normal',
26
+ fontStyle: 'normal',
27
+ fontVariant: 'normal',
28
+ fontWeight: '400'
29
+ });
30
+ `,
31
+ // globalFontFace with src first and other properties alphabetically ordered
32
+ `
33
+ import { globalFontFace } from '@vanilla-extract/css';
34
+
35
+ globalFontFace('GlobalFont', {
36
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
37
+ ascentOverride: '90%',
38
+ descentOverride: '10%',
39
+ fontDisplay: 'swap',
40
+ fontFeatureSettings: '"liga" 1',
41
+ fontStretch: 'normal',
42
+ fontStyle: 'normal',
43
+ fontVariant: 'normal',
44
+ fontWeight: '400'
45
+ });
46
+ `,
47
+ ],
48
+ invalid: [
49
+ // fontFace with src not first
50
+ {
51
+ code: `
52
+ import { fontFace } from '@vanilla-extract/css';
53
+ const myFont = fontFace({
54
+ fontWeight: '400',
55
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
56
+ ascentOverride: '90%',
57
+ fontStyle: 'normal'
58
+ });
59
+ `,
60
+ errors: [{ messageId: 'fontFaceOrder' }],
61
+ output: `
62
+ import { fontFace } from '@vanilla-extract/css';
63
+ const myFont = fontFace({
64
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
65
+ ascentOverride: '90%',
66
+ fontStyle: 'normal',
67
+ fontWeight: '400'
68
+ });
69
+ `,
70
+ },
71
+ // fontFace with src first but other properties not in alphabetical order
72
+ {
73
+ code: `
74
+ import { fontFace } from '@vanilla-extract/css';
75
+ const myFont = fontFace({
76
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
77
+ fontWeight: '400',
78
+ ascentOverride: '90%',
79
+ fontStyle: 'normal'
80
+ });
81
+ `,
82
+ errors: [{ messageId: 'fontFaceOrder' }],
83
+ output: `
84
+ import { fontFace } from '@vanilla-extract/css';
85
+ const myFont = fontFace({
86
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
87
+ ascentOverride: '90%',
88
+ fontStyle: 'normal',
89
+ fontWeight: '400'
90
+ });
91
+ `,
92
+ },
93
+ // globalFontFace with src not first
94
+ {
95
+ code: `
96
+ import { globalFontFace } from '@vanilla-extract/css';
97
+ globalFontFace('GlobalFont', {
98
+ fontWeight: '400',
99
+ fontStyle: 'normal',
100
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
101
+ ascentOverride: '90%'
102
+ });
103
+ `,
104
+ errors: [{ messageId: 'fontFaceOrder' }],
105
+ output: `
106
+ import { globalFontFace } from '@vanilla-extract/css';
107
+ globalFontFace('GlobalFont', {
108
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
109
+ ascentOverride: '90%',
110
+ fontStyle: 'normal',
111
+ fontWeight: '400'
112
+ });
113
+ `,
114
+ },
115
+ // globalFontFace with src first but other properties not in alphabetical order
116
+ {
117
+ code: `
118
+ import { globalFontFace } from '@vanilla-extract/css';
119
+ globalFontFace('GlobalFont', {
120
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
121
+ fontWeight: '400',
122
+ fontStyle: 'normal',
123
+ ascentOverride: '90%'
124
+ });
125
+ `,
126
+ errors: [{ messageId: 'fontFaceOrder' }],
127
+ output: `
128
+ import { globalFontFace } from '@vanilla-extract/css';
129
+ globalFontFace('GlobalFont', {
130
+ src: ['url("/fonts/MyFont.woff2") format("woff2")'],
131
+ ascentOverride: '90%',
132
+ fontStyle: 'normal',
133
+ fontWeight: '400'
134
+ });
135
+ `,
136
+ },
137
+ ],
138
+ });
@@ -0,0 +1,51 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import alphabeticalOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/alphabetical-order/global',
6
+ rule: alphabeticalOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // globalStyle with alphabetical ordering
16
+ `
17
+ import { globalStyle } from '@vanilla-extract/css';
18
+
19
+ globalStyle('body', {
20
+ backgroundColor: 'white',
21
+ color: 'black',
22
+ margin: 0,
23
+ padding: 0
24
+ });
25
+ `,
26
+ ],
27
+ invalid: [
28
+ // globalStyle with incorrect ordering
29
+ {
30
+ code: `
31
+ import { globalStyle } from '@vanilla-extract/css';
32
+ globalStyle('body', {
33
+ color: 'black',
34
+ backgroundColor: 'white',
35
+ padding: 0,
36
+ margin: 0
37
+ });
38
+ `,
39
+ errors: [{ messageId: 'alphabeticalOrder' }],
40
+ output: `
41
+ import { globalStyle } from '@vanilla-extract/css';
42
+ globalStyle('body', {
43
+ backgroundColor: 'white',
44
+ color: 'black',
45
+ margin: 0,
46
+ padding: 0
47
+ });
48
+ `,
49
+ },
50
+ ],
51
+ });
@@ -0,0 +1,91 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import alphabeticalOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/alphabetical-order/recipe',
6
+ rule: alphabeticalOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // Recipe with alphabetical ordering
16
+ `
17
+ import { recipe } from '@vanilla-extract/recipes';
18
+
19
+ const myRecipe = recipe({
20
+ base: {
21
+ alignItems: 'center',
22
+ display: 'flex'
23
+ },
24
+ variants: {
25
+ color: {
26
+ blue: {
27
+ backgroundColor: 'blue',
28
+ color: 'white'
29
+ },
30
+ red: {
31
+ backgroundColor: 'red',
32
+ color: 'black'
33
+ }
34
+ }
35
+ }
36
+ });
37
+ `,
38
+ ],
39
+ invalid: [
40
+ // Recipe with incorrect ordering
41
+ {
42
+ code: `
43
+ import { recipe } from '@vanilla-extract/recipes';
44
+ const myRecipe = recipe({
45
+ base: {
46
+ display: 'flex',
47
+ alignItems: 'center'
48
+ },
49
+ variants: {
50
+ color: {
51
+ blue: {
52
+ color: 'white',
53
+ backgroundColor: 'blue'
54
+ },
55
+ red: {
56
+ color: 'black',
57
+ backgroundColor: 'red'
58
+ }
59
+ }
60
+ }
61
+ });
62
+ `,
63
+ errors: [
64
+ { messageId: 'alphabeticalOrder' },
65
+ { messageId: 'alphabeticalOrder' },
66
+ { messageId: 'alphabeticalOrder' },
67
+ ],
68
+ output: `
69
+ import { recipe } from '@vanilla-extract/recipes';
70
+ const myRecipe = recipe({
71
+ base: {
72
+ alignItems: 'center',
73
+ display: 'flex'
74
+ },
75
+ variants: {
76
+ color: {
77
+ blue: {
78
+ backgroundColor: 'blue',
79
+ color: 'white'
80
+ },
81
+ red: {
82
+ backgroundColor: 'red',
83
+ color: 'black'
84
+ }
85
+ }
86
+ }
87
+ });
88
+ `,
89
+ },
90
+ ],
91
+ });
@@ -0,0 +1,108 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import alphabeticalOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/alphabetical-order/style',
6
+ rule: alphabeticalOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // Basic style object with alphabetical ordering
16
+ `
17
+ import { style } from '@vanilla-extract/css';
18
+
19
+ const myStyle = style({
20
+ alignItems: 'center',
21
+ backgroundColor: 'red',
22
+ color: 'blue',
23
+ display: 'flex',
24
+ margin: '10px',
25
+ padding: '20px',
26
+ zIndex: 1
27
+ });
28
+ `,
29
+ // Style with nested selectors
30
+ `
31
+ import { style } from '@vanilla-extract/css';
32
+
33
+ const myStyle = style({
34
+ alignItems: 'center',
35
+ backgroundColor: 'red',
36
+ color: 'blue',
37
+ selectors: {
38
+ '&:hover': {
39
+ backgroundColor: 'blue',
40
+ color: 'white'
41
+ }
42
+ }
43
+ });
44
+ `,
45
+ ],
46
+ invalid: [
47
+ // Basic style object with incorrect ordering
48
+ {
49
+ code: `
50
+ import { style } from '@vanilla-extract/css';
51
+ const myStyle = style({
52
+ backgroundColor: 'red',
53
+ alignItems: 'center',
54
+ padding: '20px',
55
+ color: 'blue',
56
+ margin: '10px',
57
+ display: 'flex',
58
+ zIndex: 1
59
+ });
60
+ `,
61
+ errors: [{ messageId: 'alphabeticalOrder' }],
62
+ output: `
63
+ import { style } from '@vanilla-extract/css';
64
+ const myStyle = style({
65
+ alignItems: 'center',
66
+ backgroundColor: 'red',
67
+ color: 'blue',
68
+ display: 'flex',
69
+ margin: '10px',
70
+ padding: '20px',
71
+ zIndex: 1
72
+ });
73
+ `,
74
+ },
75
+ // Style with nested selectors having incorrect ordering
76
+ {
77
+ code: `
78
+ import { style } from '@vanilla-extract/css';
79
+ const myStyle = style({
80
+ backgroundColor: 'red',
81
+ alignItems: 'center',
82
+ color: 'blue',
83
+ selectors: {
84
+ '&:hover': {
85
+ color: 'white',
86
+ backgroundColor: 'blue'
87
+ }
88
+ }
89
+ });
90
+ `,
91
+ errors: [{ messageId: 'alphabeticalOrder' }, { messageId: 'alphabeticalOrder' }],
92
+ output: `
93
+ import { style } from '@vanilla-extract/css';
94
+ const myStyle = style({
95
+ alignItems: 'center',
96
+ backgroundColor: 'red',
97
+ color: 'blue',
98
+ selectors: {
99
+ '&:hover': {
100
+ backgroundColor: 'blue',
101
+ color: 'white'
102
+ }
103
+ }
104
+ });
105
+ `,
106
+ },
107
+ ],
108
+ });
@@ -0,0 +1,63 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import alphabeticalOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/alphabetical-order/variants',
6
+ rule: alphabeticalOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // styleVariants with alphabetical ordering
16
+ `
17
+ import { styleVariants } from '@vanilla-extract/css';
18
+
19
+ const variants = styleVariants({
20
+ primary: {
21
+ backgroundColor: 'blue',
22
+ color: 'white'
23
+ },
24
+ secondary: {
25
+ backgroundColor: 'gray',
26
+ color: 'black'
27
+ }
28
+ });
29
+ `,
30
+ ],
31
+ invalid: [
32
+ // styleVariants with incorrect ordering
33
+ {
34
+ code: `
35
+ import { styleVariants } from '@vanilla-extract/css';
36
+ const variants = styleVariants({
37
+ primary: {
38
+ color: 'white',
39
+ backgroundColor: 'blue'
40
+ },
41
+ secondary: {
42
+ color: 'black',
43
+ backgroundColor: 'gray'
44
+ }
45
+ });
46
+ `,
47
+ errors: [{ messageId: 'alphabeticalOrder' }, { messageId: 'alphabeticalOrder' }],
48
+ output: `
49
+ import { styleVariants } from '@vanilla-extract/css';
50
+ const variants = styleVariants({
51
+ primary: {
52
+ backgroundColor: 'blue',
53
+ color: 'white'
54
+ },
55
+ secondary: {
56
+ backgroundColor: 'gray',
57
+ color: 'black'
58
+ }
59
+ });
60
+ `,
61
+ },
62
+ ],
63
+ });
@@ -0,0 +1,69 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import { run } from 'eslint-vitest-rule-tester';
3
+ import concentricOrderRule from '../rule-definition.js';
4
+ run({
5
+ name: 'vanilla-extract/concentric-order/animation',
6
+ rule: concentricOrderRule,
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ ecmaVersion: 2022,
11
+ sourceType: 'module',
12
+ },
13
+ },
14
+ valid: [
15
+ // keyframes with concentric ordering
16
+ `
17
+ import { keyframes } from '@vanilla-extract/css';
18
+
19
+ const fadeIn = keyframes({
20
+ '0%': {
21
+ position: 'relative',
22
+ transform: 'translateY(1rem)',
23
+ opacity: 0
24
+ },
25
+ '100%': {
26
+ position: 'relative',
27
+ transform: 'translateY(0)',
28
+ opacity: 1
29
+ }
30
+ });
31
+ `,
32
+ ],
33
+ invalid: [
34
+ // keyframes with incorrect ordering
35
+ {
36
+ code: `
37
+ import { keyframes } from '@vanilla-extract/css';
38
+ const fadeIn = keyframes({
39
+ '0%': {
40
+ opacity: 0,
41
+ transform: 'translateY(1rem)',
42
+ position: 'relative'
43
+ },
44
+ '100%': {
45
+ opacity: 1,
46
+ transform: 'translateY(0)',
47
+ position: 'relative'
48
+ }
49
+ });
50
+ `,
51
+ errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
52
+ output: `
53
+ import { keyframes } from '@vanilla-extract/css';
54
+ const fadeIn = keyframes({
55
+ '0%': {
56
+ position: 'relative',
57
+ transform: 'translateY(1rem)',
58
+ opacity: 0
59
+ },
60
+ '100%': {
61
+ position: 'relative',
62
+ transform: 'translateY(0)',
63
+ opacity: 1
64
+ }
65
+ });
66
+ `,
67
+ },
68
+ ],
69
+ });