@antebudimir/eslint-plugin-vanilla-extract 1.2.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.
- package/README.md +46 -8
- package/dist/css-rules/alphabetical-order/__tests__/animation.test.d.ts +1 -0
- package/dist/css-rules/alphabetical-order/__tests__/animation.test.js +108 -0
- package/dist/css-rules/alphabetical-order/__tests__/font-face.test.d.ts +1 -0
- package/dist/css-rules/alphabetical-order/__tests__/font-face.test.js +138 -0
- package/dist/css-rules/alphabetical-order/__tests__/global.test.d.ts +1 -0
- package/dist/css-rules/alphabetical-order/__tests__/global.test.js +51 -0
- package/dist/css-rules/alphabetical-order/__tests__/recipe.test.d.ts +1 -0
- package/dist/css-rules/alphabetical-order/__tests__/recipe.test.js +91 -0
- package/dist/css-rules/alphabetical-order/__tests__/style.test.d.ts +1 -0
- package/dist/css-rules/alphabetical-order/__tests__/style.test.js +108 -0
- package/dist/css-rules/alphabetical-order/__tests__/variants.test.d.ts +1 -0
- package/dist/css-rules/alphabetical-order/__tests__/variants.test.js +63 -0
- package/dist/css-rules/alphabetical-order/property-order-enforcer.js +1 -11
- package/dist/css-rules/alphabetical-order/rule-definition.js +2 -1
- package/dist/css-rules/concentric-order/__tests__/animation.test.d.ts +1 -0
- package/dist/css-rules/concentric-order/__tests__/animation.test.js +69 -0
- package/dist/css-rules/concentric-order/__tests__/font-face.test.d.ts +1 -0
- package/dist/css-rules/concentric-order/__tests__/font-face.test.js +94 -0
- package/dist/css-rules/concentric-order/__tests__/global.test.d.ts +1 -0
- package/dist/css-rules/concentric-order/__tests__/global.test.js +57 -0
- package/dist/css-rules/concentric-order/__tests__/recipe.test.d.ts +1 -0
- package/dist/css-rules/concentric-order/__tests__/recipe.test.js +100 -0
- package/dist/css-rules/concentric-order/__tests__/style.test.d.ts +1 -0
- package/dist/css-rules/concentric-order/__tests__/style.test.js +126 -0
- package/dist/css-rules/concentric-order/__tests__/variants.test.d.ts +1 -0
- package/dist/css-rules/concentric-order/__tests__/variants.test.js +133 -0
- package/dist/css-rules/concentric-order/property-order-enforcer.js +2 -2
- package/dist/css-rules/concentric-order/rule-definition.js +3 -1
- package/dist/css-rules/custom-order/__tests__/animation.test.d.ts +1 -0
- package/dist/css-rules/custom-order/__tests__/animation.test.js +148 -0
- package/dist/css-rules/custom-order/__tests__/font-face.test.d.ts +1 -0
- package/dist/css-rules/custom-order/__tests__/font-face.test.js +124 -0
- package/dist/css-rules/custom-order/__tests__/global.test.d.ts +1 -0
- package/dist/css-rules/custom-order/__tests__/global.test.js +124 -0
- package/dist/css-rules/custom-order/__tests__/recipe.test.d.ts +1 -0
- package/dist/css-rules/custom-order/__tests__/recipe.test.js +208 -0
- package/dist/css-rules/custom-order/__tests__/style.test.d.ts +1 -0
- package/dist/css-rules/custom-order/__tests__/style.test.js +249 -0
- package/dist/css-rules/custom-order/__tests__/variants.test.d.ts +1 -0
- package/dist/css-rules/custom-order/__tests__/variants.test.js +184 -0
- package/dist/css-rules/custom-order/rule-definition.js +1 -0
- package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.d.ts +1 -0
- package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.js +37 -0
- package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.d.ts +1 -0
- package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.js +58 -0
- package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.d.ts +1 -0
- package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.js +125 -0
- package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.d.ts +1 -0
- package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.js +53 -0
- package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.d.ts +1 -0
- package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.js +116 -0
- package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.d.ts +1 -0
- package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.js +55 -0
- package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.d.ts +3 -0
- package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.js +30 -0
- package/dist/css-rules/shared-utils/alphabetical-property-comparator.d.ts +8 -0
- package/dist/css-rules/shared-utils/alphabetical-property-comparator.js +19 -0
- package/dist/css-rules/shared-utils/font-face-property-order-enforcer.d.ts +10 -0
- package/dist/css-rules/shared-utils/font-face-property-order-enforcer.js +39 -0
- package/dist/css-rules/shared-utils/order-strategy-visitor-creator.d.ts +4 -3
- package/dist/css-rules/shared-utils/order-strategy-visitor-creator.js +23 -8
- package/dist/css-rules/shared-utils/style-node-processor.js +2 -5
- package/dist/index.js +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import { run } from 'eslint-vitest-rule-tester';
|
|
3
|
+
import customGroupOrderRule from '../rule-definition.js';
|
|
4
|
+
run({
|
|
5
|
+
name: 'vanilla-extract/custom-order/animation',
|
|
6
|
+
rule: customGroupOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// keyframes with custom group ordering (concentric for remaining)
|
|
16
|
+
{
|
|
17
|
+
code: `
|
|
18
|
+
import { keyframes } from '@vanilla-extract/css';
|
|
19
|
+
|
|
20
|
+
const fadeIn = keyframes({
|
|
21
|
+
'0%': {
|
|
22
|
+
position: 'relative',
|
|
23
|
+
transform: 'translateY(1rem)',
|
|
24
|
+
opacity: 0
|
|
25
|
+
},
|
|
26
|
+
'100%': {
|
|
27
|
+
position: 'relative',
|
|
28
|
+
transform: 'translateY(0)',
|
|
29
|
+
opacity: 1
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
`,
|
|
33
|
+
options: [
|
|
34
|
+
{
|
|
35
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
36
|
+
sortRemainingProperties: 'concentric',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
// keyframes with custom group ordering (alphabetical for remaining)
|
|
41
|
+
{
|
|
42
|
+
code: `
|
|
43
|
+
import { keyframes } from '@vanilla-extract/css';
|
|
44
|
+
|
|
45
|
+
const fadeIn = keyframes({
|
|
46
|
+
'0%': {
|
|
47
|
+
opacity: 0,
|
|
48
|
+
position: 'relative',
|
|
49
|
+
transform: 'translateY(1rem)'
|
|
50
|
+
},
|
|
51
|
+
'100%': {
|
|
52
|
+
opacity: 1,
|
|
53
|
+
position: 'relative',
|
|
54
|
+
transform: 'translateY(0)'
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
`,
|
|
58
|
+
options: [
|
|
59
|
+
{
|
|
60
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
61
|
+
sortRemainingProperties: 'alphabetical',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
invalid: [
|
|
67
|
+
// keyframes with incorrect ordering (concentric for remaining)
|
|
68
|
+
{
|
|
69
|
+
code: `
|
|
70
|
+
import { keyframes } from '@vanilla-extract/css';
|
|
71
|
+
const fadeIn = keyframes({
|
|
72
|
+
'0%': {
|
|
73
|
+
opacity: 0,
|
|
74
|
+
transform: 'translateY(1rem)',
|
|
75
|
+
position: 'relative'
|
|
76
|
+
},
|
|
77
|
+
'100%': {
|
|
78
|
+
opacity: 1,
|
|
79
|
+
transform: 'translateY(0)',
|
|
80
|
+
position: 'relative'
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
`,
|
|
84
|
+
options: [
|
|
85
|
+
{
|
|
86
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
87
|
+
sortRemainingProperties: 'concentric',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
91
|
+
output: `
|
|
92
|
+
import { keyframes } from '@vanilla-extract/css';
|
|
93
|
+
const fadeIn = keyframes({
|
|
94
|
+
'0%': {
|
|
95
|
+
position: 'relative',
|
|
96
|
+
transform: 'translateY(1rem)',
|
|
97
|
+
opacity: 0
|
|
98
|
+
},
|
|
99
|
+
'100%': {
|
|
100
|
+
position: 'relative',
|
|
101
|
+
transform: 'translateY(0)',
|
|
102
|
+
opacity: 1
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
`,
|
|
106
|
+
},
|
|
107
|
+
// keyframes with incorrect ordering (alphabetical for remaining)
|
|
108
|
+
{
|
|
109
|
+
code: `
|
|
110
|
+
import { keyframes } from '@vanilla-extract/css';
|
|
111
|
+
const fadeIn = keyframes({
|
|
112
|
+
'0%': {
|
|
113
|
+
transform: 'translateY(1rem)',
|
|
114
|
+
position: 'relative',
|
|
115
|
+
opacity: 0
|
|
116
|
+
},
|
|
117
|
+
'100%': {
|
|
118
|
+
transform: 'translateY(0)',
|
|
119
|
+
position: 'relative',
|
|
120
|
+
opacity: 1
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
`,
|
|
124
|
+
options: [
|
|
125
|
+
{
|
|
126
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
127
|
+
sortRemainingProperties: 'alphabetical',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
131
|
+
output: `
|
|
132
|
+
import { keyframes } from '@vanilla-extract/css';
|
|
133
|
+
const fadeIn = keyframes({
|
|
134
|
+
'0%': {
|
|
135
|
+
opacity: 0,
|
|
136
|
+
position: 'relative',
|
|
137
|
+
transform: 'translateY(1rem)'
|
|
138
|
+
},
|
|
139
|
+
'100%': {
|
|
140
|
+
opacity: 1,
|
|
141
|
+
position: 'relative',
|
|
142
|
+
transform: 'translateY(0)'
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
`,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import { run } from 'eslint-vitest-rule-tester';
|
|
3
|
+
import customGroupOrderRule from '../rule-definition.js';
|
|
4
|
+
run({
|
|
5
|
+
name: 'vanilla-extract/custom-order/font-face',
|
|
6
|
+
rule: customGroupOrderRule,
|
|
7
|
+
configs: {
|
|
8
|
+
languageOptions: {
|
|
9
|
+
parser: tsParser,
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaVersion: 2022,
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
valid: [
|
|
17
|
+
// fontFace
|
|
18
|
+
{
|
|
19
|
+
code: `
|
|
20
|
+
import { fontFace } from '@vanilla-extract/css';
|
|
21
|
+
|
|
22
|
+
const myFont = fontFace({
|
|
23
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
24
|
+
ascentOverride: '90%',
|
|
25
|
+
descentOverride: '10%',
|
|
26
|
+
fontDisplay: 'swap',
|
|
27
|
+
fontFeatureSettings: '"liga" 1',
|
|
28
|
+
fontStretch: 'normal',
|
|
29
|
+
fontStyle: 'normal',
|
|
30
|
+
fontVariant: 'normal',
|
|
31
|
+
fontWeight: '400'
|
|
32
|
+
});
|
|
33
|
+
`,
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
groupOrder: ['dimensions', 'margin', 'font'],
|
|
37
|
+
sortRemainingProperties: 'concentric',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
// globalFontFace
|
|
42
|
+
{
|
|
43
|
+
code: `
|
|
44
|
+
import { globalFontFace } from '@vanilla-extract/css';
|
|
45
|
+
|
|
46
|
+
globalFontFace('GlobalFont', {
|
|
47
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
48
|
+
ascentOverride: '90%',
|
|
49
|
+
descentOverride: '10%',
|
|
50
|
+
fontDisplay: 'swap',
|
|
51
|
+
fontFeatureSettings: '"liga" 1',
|
|
52
|
+
fontStretch: 'normal',
|
|
53
|
+
fontStyle: 'normal',
|
|
54
|
+
fontVariant: 'normal',
|
|
55
|
+
fontWeight: '400'
|
|
56
|
+
});
|
|
57
|
+
`,
|
|
58
|
+
options: [
|
|
59
|
+
{
|
|
60
|
+
groupOrder: ['dimensions', 'margin', 'font'],
|
|
61
|
+
sortRemainingProperties: 'concentric',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
invalid: [
|
|
67
|
+
// fontFace with src not first
|
|
68
|
+
{
|
|
69
|
+
code: `
|
|
70
|
+
import { fontFace } from '@vanilla-extract/css';
|
|
71
|
+
const myFont = fontFace({
|
|
72
|
+
fontWeight: '400',
|
|
73
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
74
|
+
ascentOverride: '90%',
|
|
75
|
+
fontStyle: 'normal'
|
|
76
|
+
});
|
|
77
|
+
`,
|
|
78
|
+
options: [
|
|
79
|
+
{
|
|
80
|
+
groupOrder: ['dimensions', 'margin', 'font'],
|
|
81
|
+
sortRemainingProperties: 'concentric',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
errors: [{ messageId: 'fontFaceOrder' }],
|
|
85
|
+
output: `
|
|
86
|
+
import { fontFace } from '@vanilla-extract/css';
|
|
87
|
+
const myFont = fontFace({
|
|
88
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
89
|
+
ascentOverride: '90%',
|
|
90
|
+
fontStyle: 'normal',
|
|
91
|
+
fontWeight: '400'
|
|
92
|
+
});
|
|
93
|
+
`,
|
|
94
|
+
},
|
|
95
|
+
// globalFontFace with src not first
|
|
96
|
+
{
|
|
97
|
+
code: `
|
|
98
|
+
import { globalFontFace } from '@vanilla-extract/css';
|
|
99
|
+
globalFontFace('GlobalFont', {
|
|
100
|
+
fontWeight: '400',
|
|
101
|
+
fontStyle: 'normal',
|
|
102
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
103
|
+
ascentOverride: '90%'
|
|
104
|
+
});
|
|
105
|
+
`,
|
|
106
|
+
options: [
|
|
107
|
+
{
|
|
108
|
+
groupOrder: ['dimensions', 'margin', 'font'],
|
|
109
|
+
sortRemainingProperties: 'concentric',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
errors: [{ messageId: 'fontFaceOrder' }],
|
|
113
|
+
output: `
|
|
114
|
+
import { globalFontFace } from '@vanilla-extract/css';
|
|
115
|
+
globalFontFace('GlobalFont', {
|
|
116
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
117
|
+
ascentOverride: '90%',
|
|
118
|
+
fontStyle: 'normal',
|
|
119
|
+
fontWeight: '400'
|
|
120
|
+
});
|
|
121
|
+
`,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import { run } from 'eslint-vitest-rule-tester';
|
|
3
|
+
import customGroupOrderRule from '../rule-definition.js';
|
|
4
|
+
run({
|
|
5
|
+
name: 'vanilla-extract/custom-order/global',
|
|
6
|
+
rule: customGroupOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// globalStyle with custom group ordering (concentric for remaining)
|
|
16
|
+
{
|
|
17
|
+
code: `
|
|
18
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
19
|
+
|
|
20
|
+
globalStyle('body', {
|
|
21
|
+
margin: 0,
|
|
22
|
+
position: 'relative',
|
|
23
|
+
display: 'block',
|
|
24
|
+
backgroundColor: 'white',
|
|
25
|
+
padding: 0,
|
|
26
|
+
color: 'black'
|
|
27
|
+
});
|
|
28
|
+
`,
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
32
|
+
sortRemainingProperties: 'concentric',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
// globalStyle with custom group ordering (alphabetical for remaining)
|
|
37
|
+
{
|
|
38
|
+
code: `
|
|
39
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
40
|
+
|
|
41
|
+
globalStyle('body', {
|
|
42
|
+
margin: 0,
|
|
43
|
+
backgroundColor: 'white',
|
|
44
|
+
color: 'black',
|
|
45
|
+
display: 'block',
|
|
46
|
+
padding: 0,
|
|
47
|
+
position: 'relative'
|
|
48
|
+
});
|
|
49
|
+
`,
|
|
50
|
+
options: [
|
|
51
|
+
{
|
|
52
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
53
|
+
sortRemainingProperties: 'alphabetical',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
invalid: [
|
|
59
|
+
// globalStyle with incorrect ordering (concentric for remaining)
|
|
60
|
+
{
|
|
61
|
+
code: `
|
|
62
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
63
|
+
globalStyle('body', {
|
|
64
|
+
color: 'black',
|
|
65
|
+
margin: 0,
|
|
66
|
+
backgroundColor: 'white',
|
|
67
|
+
padding: 0,
|
|
68
|
+
display: 'block',
|
|
69
|
+
position: 'relative'
|
|
70
|
+
});
|
|
71
|
+
`,
|
|
72
|
+
options: [
|
|
73
|
+
{
|
|
74
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
75
|
+
sortRemainingProperties: 'concentric',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
errors: [{ messageId: 'incorrectOrder' }],
|
|
79
|
+
output: `
|
|
80
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
81
|
+
globalStyle('body', {
|
|
82
|
+
margin: 0,
|
|
83
|
+
position: 'relative',
|
|
84
|
+
display: 'block',
|
|
85
|
+
backgroundColor: 'white',
|
|
86
|
+
padding: 0,
|
|
87
|
+
color: 'black'
|
|
88
|
+
});
|
|
89
|
+
`,
|
|
90
|
+
},
|
|
91
|
+
// globalStyle with incorrect ordering (alphabetical for remaining)
|
|
92
|
+
{
|
|
93
|
+
code: `
|
|
94
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
95
|
+
globalStyle('body', {
|
|
96
|
+
position: 'relative',
|
|
97
|
+
display: 'block',
|
|
98
|
+
margin: 0,
|
|
99
|
+
backgroundColor: 'white',
|
|
100
|
+
padding: 0,
|
|
101
|
+
color: 'black'
|
|
102
|
+
});
|
|
103
|
+
`,
|
|
104
|
+
options: [
|
|
105
|
+
{
|
|
106
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
107
|
+
sortRemainingProperties: 'alphabetical',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
errors: [{ messageId: 'incorrectOrder' }],
|
|
111
|
+
output: `
|
|
112
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
113
|
+
globalStyle('body', {
|
|
114
|
+
margin: 0,
|
|
115
|
+
backgroundColor: 'white',
|
|
116
|
+
color: 'black',
|
|
117
|
+
display: 'block',
|
|
118
|
+
padding: 0,
|
|
119
|
+
position: 'relative'
|
|
120
|
+
});
|
|
121
|
+
`,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import { run } from 'eslint-vitest-rule-tester';
|
|
3
|
+
import customGroupOrderRule from '../rule-definition.js';
|
|
4
|
+
run({
|
|
5
|
+
name: 'vanilla-extract/custom-order/recipe',
|
|
6
|
+
rule: customGroupOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// Recipe with custom group ordering (concentric for remaining)
|
|
16
|
+
{
|
|
17
|
+
code: `
|
|
18
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
19
|
+
|
|
20
|
+
const myRecipe = recipe({
|
|
21
|
+
base: {
|
|
22
|
+
width: '100%',
|
|
23
|
+
margin: 0,
|
|
24
|
+
position: 'relative',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
backgroundColor: 'white'
|
|
28
|
+
},
|
|
29
|
+
variants: {
|
|
30
|
+
color: {
|
|
31
|
+
blue: {
|
|
32
|
+
position: 'relative',
|
|
33
|
+
backgroundColor: 'blue',
|
|
34
|
+
color: 'white'
|
|
35
|
+
},
|
|
36
|
+
red: {
|
|
37
|
+
position: 'relative',
|
|
38
|
+
backgroundColor: 'red',
|
|
39
|
+
color: 'black'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
`,
|
|
45
|
+
options: [
|
|
46
|
+
{
|
|
47
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
48
|
+
sortRemainingProperties: 'concentric',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
// Recipe with custom group ordering (alphabetical for remaining)
|
|
53
|
+
{
|
|
54
|
+
code: `
|
|
55
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
56
|
+
|
|
57
|
+
const myRecipe = recipe({
|
|
58
|
+
base: {
|
|
59
|
+
width: '100%',
|
|
60
|
+
margin: 0,
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
backgroundColor: 'white',
|
|
63
|
+
display: 'flex',
|
|
64
|
+
position: 'relative'
|
|
65
|
+
},
|
|
66
|
+
variants: {
|
|
67
|
+
color: {
|
|
68
|
+
blue: {
|
|
69
|
+
backgroundColor: 'blue',
|
|
70
|
+
color: 'white',
|
|
71
|
+
position: 'relative'
|
|
72
|
+
},
|
|
73
|
+
red: {
|
|
74
|
+
backgroundColor: 'red',
|
|
75
|
+
color: 'black',
|
|
76
|
+
position: 'relative'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
`,
|
|
82
|
+
options: [
|
|
83
|
+
{
|
|
84
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
85
|
+
sortRemainingProperties: 'alphabetical',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
invalid: [
|
|
91
|
+
// Recipe with incorrect ordering (concentric for remaining)
|
|
92
|
+
{
|
|
93
|
+
code: `
|
|
94
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
95
|
+
const myRecipe = recipe({
|
|
96
|
+
base: {
|
|
97
|
+
backgroundColor: 'white',
|
|
98
|
+
width: '100%',
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
margin: 0
|
|
102
|
+
},
|
|
103
|
+
variants: {
|
|
104
|
+
color: {
|
|
105
|
+
blue: {
|
|
106
|
+
color: 'white',
|
|
107
|
+
backgroundColor: 'blue',
|
|
108
|
+
position: 'relative'
|
|
109
|
+
},
|
|
110
|
+
red: {
|
|
111
|
+
color: 'black',
|
|
112
|
+
backgroundColor: 'red',
|
|
113
|
+
position: 'relative'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
`,
|
|
119
|
+
options: [
|
|
120
|
+
{
|
|
121
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
122
|
+
sortRemainingProperties: 'concentric',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
126
|
+
output: `
|
|
127
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
128
|
+
const myRecipe = recipe({
|
|
129
|
+
base: {
|
|
130
|
+
width: '100%',
|
|
131
|
+
margin: 0,
|
|
132
|
+
display: 'flex',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
backgroundColor: 'white'
|
|
135
|
+
},
|
|
136
|
+
variants: {
|
|
137
|
+
color: {
|
|
138
|
+
blue: {
|
|
139
|
+
position: 'relative',
|
|
140
|
+
backgroundColor: 'blue',
|
|
141
|
+
color: 'white'
|
|
142
|
+
},
|
|
143
|
+
red: {
|
|
144
|
+
position: 'relative',
|
|
145
|
+
backgroundColor: 'red',
|
|
146
|
+
color: 'black'
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
`,
|
|
152
|
+
},
|
|
153
|
+
// Recipe with incorrect ordering (alphabetical for remaining)
|
|
154
|
+
{
|
|
155
|
+
code: `
|
|
156
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
157
|
+
const myRecipe = recipe({
|
|
158
|
+
base: {
|
|
159
|
+
position: 'relative',
|
|
160
|
+
display: 'flex',
|
|
161
|
+
alignItems: 'center',
|
|
162
|
+
backgroundColor: 'white',
|
|
163
|
+
width: '100%',
|
|
164
|
+
margin: 0
|
|
165
|
+
},
|
|
166
|
+
variants: {
|
|
167
|
+
color: {
|
|
168
|
+
blue: {
|
|
169
|
+
position: 'relative',
|
|
170
|
+
backgroundColor: 'blue',
|
|
171
|
+
color: 'white'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
`,
|
|
177
|
+
options: [
|
|
178
|
+
{
|
|
179
|
+
groupOrder: ['dimensions', 'margin', 'font', 'border', 'boxShadow'],
|
|
180
|
+
sortRemainingProperties: 'alphabetical',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
184
|
+
output: `
|
|
185
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
186
|
+
const myRecipe = recipe({
|
|
187
|
+
base: {
|
|
188
|
+
width: '100%',
|
|
189
|
+
margin: 0,
|
|
190
|
+
alignItems: 'center',
|
|
191
|
+
backgroundColor: 'white',
|
|
192
|
+
display: 'flex',
|
|
193
|
+
position: 'relative'
|
|
194
|
+
},
|
|
195
|
+
variants: {
|
|
196
|
+
color: {
|
|
197
|
+
blue: {
|
|
198
|
+
backgroundColor: 'blue',
|
|
199
|
+
color: 'white',
|
|
200
|
+
position: 'relative'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
`,
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|