@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
|
@@ -10,7 +10,8 @@ const alphabeticalOrderRule = {
|
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
schema: [],
|
|
12
12
|
messages: {
|
|
13
|
-
alphabeticalOrder: "Property '{{
|
|
13
|
+
alphabeticalOrder: "Property '{{nextProperty}}' should come before '{{currentProperty}}' in alphabetical order.",
|
|
14
|
+
fontFaceOrder: "Properties in fontFace should be ordered with 'src' first, followed by other properties in alphabetical order. Property '{{nextProperty}}' should come before '{{currentProperty}}'.",
|
|
14
15
|
},
|
|
15
16
|
},
|
|
16
17
|
create(context) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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/font-face',
|
|
6
|
+
rule: concentricOrderRule,
|
|
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
|
+
// globalFontFace with src not first
|
|
72
|
+
{
|
|
73
|
+
code: `
|
|
74
|
+
import { globalFontFace } from '@vanilla-extract/css';
|
|
75
|
+
globalFontFace('GlobalFont', {
|
|
76
|
+
fontWeight: '400',
|
|
77
|
+
fontStyle: 'normal',
|
|
78
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
79
|
+
ascentOverride: '90%'
|
|
80
|
+
});
|
|
81
|
+
`,
|
|
82
|
+
errors: [{ messageId: 'fontFaceOrder' }],
|
|
83
|
+
output: `
|
|
84
|
+
import { globalFontFace } from '@vanilla-extract/css';
|
|
85
|
+
globalFontFace('GlobalFont', {
|
|
86
|
+
src: ['url("/fonts/MyFont.woff2") format("woff2")'],
|
|
87
|
+
ascentOverride: '90%',
|
|
88
|
+
fontStyle: 'normal',
|
|
89
|
+
fontWeight: '400'
|
|
90
|
+
});
|
|
91
|
+
`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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/global',
|
|
6
|
+
rule: concentricOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// globalStyle with concentric ordering
|
|
16
|
+
`
|
|
17
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
18
|
+
|
|
19
|
+
globalStyle('body', {
|
|
20
|
+
position: 'relative',
|
|
21
|
+
display: 'block',
|
|
22
|
+
margin: 0,
|
|
23
|
+
backgroundColor: 'white',
|
|
24
|
+
padding: 0,
|
|
25
|
+
color: 'black'
|
|
26
|
+
});
|
|
27
|
+
`,
|
|
28
|
+
],
|
|
29
|
+
invalid: [
|
|
30
|
+
// globalStyle with incorrect ordering
|
|
31
|
+
{
|
|
32
|
+
code: `
|
|
33
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
34
|
+
globalStyle('body', {
|
|
35
|
+
color: 'black',
|
|
36
|
+
margin: 0,
|
|
37
|
+
backgroundColor: 'white',
|
|
38
|
+
padding: 0,
|
|
39
|
+
display: 'block',
|
|
40
|
+
position: 'relative'
|
|
41
|
+
});
|
|
42
|
+
`,
|
|
43
|
+
errors: [{ messageId: 'incorrectOrder' }],
|
|
44
|
+
output: `
|
|
45
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
46
|
+
globalStyle('body', {
|
|
47
|
+
position: 'relative',
|
|
48
|
+
display: 'block',
|
|
49
|
+
margin: 0,
|
|
50
|
+
backgroundColor: 'white',
|
|
51
|
+
padding: 0,
|
|
52
|
+
color: 'black'
|
|
53
|
+
});
|
|
54
|
+
`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
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/recipe',
|
|
6
|
+
rule: concentricOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// Recipe with concentric ordering
|
|
16
|
+
`
|
|
17
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
18
|
+
|
|
19
|
+
const myRecipe = recipe({
|
|
20
|
+
base: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
backgroundColor: 'white',
|
|
25
|
+
width: '100%'
|
|
26
|
+
},
|
|
27
|
+
variants: {
|
|
28
|
+
color: {
|
|
29
|
+
blue: {
|
|
30
|
+
position: 'relative',
|
|
31
|
+
backgroundColor: 'blue',
|
|
32
|
+
color: 'white'
|
|
33
|
+
},
|
|
34
|
+
red: {
|
|
35
|
+
position: 'relative',
|
|
36
|
+
backgroundColor: 'red',
|
|
37
|
+
color: 'black'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
`,
|
|
43
|
+
],
|
|
44
|
+
invalid: [
|
|
45
|
+
// Recipe with incorrect ordering
|
|
46
|
+
{
|
|
47
|
+
code: `
|
|
48
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
49
|
+
const myRecipe = recipe({
|
|
50
|
+
base: {
|
|
51
|
+
backgroundColor: 'white',
|
|
52
|
+
width: '100%',
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'center'
|
|
55
|
+
},
|
|
56
|
+
variants: {
|
|
57
|
+
color: {
|
|
58
|
+
blue: {
|
|
59
|
+
color: 'white',
|
|
60
|
+
backgroundColor: 'blue',
|
|
61
|
+
position: 'relative'
|
|
62
|
+
},
|
|
63
|
+
red: {
|
|
64
|
+
color: 'black',
|
|
65
|
+
backgroundColor: 'red',
|
|
66
|
+
position: 'relative'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
`,
|
|
72
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
73
|
+
output: `
|
|
74
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
75
|
+
const myRecipe = recipe({
|
|
76
|
+
base: {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
backgroundColor: 'white',
|
|
80
|
+
width: '100%'
|
|
81
|
+
},
|
|
82
|
+
variants: {
|
|
83
|
+
color: {
|
|
84
|
+
blue: {
|
|
85
|
+
position: 'relative',
|
|
86
|
+
backgroundColor: 'blue',
|
|
87
|
+
color: 'white'
|
|
88
|
+
},
|
|
89
|
+
red: {
|
|
90
|
+
position: 'relative',
|
|
91
|
+
backgroundColor: 'red',
|
|
92
|
+
color: 'black'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
`,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
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/style',
|
|
6
|
+
rule: concentricOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// Basic style object with concentric ordering
|
|
16
|
+
`
|
|
17
|
+
import { style } from '@vanilla-extract/css';
|
|
18
|
+
|
|
19
|
+
const myStyle = style({
|
|
20
|
+
boxSizing: 'border-box',
|
|
21
|
+
position: 'relative',
|
|
22
|
+
zIndex: 1,
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
transform: 'none',
|
|
26
|
+
opacity: 1,
|
|
27
|
+
margin: '1rem',
|
|
28
|
+
border: '1px solid black',
|
|
29
|
+
boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
|
|
30
|
+
backgroundColor: 'red',
|
|
31
|
+
padding: '2rem',
|
|
32
|
+
width: '10rem',
|
|
33
|
+
height: '10rem',
|
|
34
|
+
color: 'blue',
|
|
35
|
+
fontSize: '16rem'
|
|
36
|
+
});
|
|
37
|
+
`,
|
|
38
|
+
// Style with nested selectors
|
|
39
|
+
`
|
|
40
|
+
import { style } from '@vanilla-extract/css';
|
|
41
|
+
|
|
42
|
+
const myStyle = style({
|
|
43
|
+
position: 'relative',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
backgroundColor: 'red',
|
|
47
|
+
color: 'blue',
|
|
48
|
+
|
|
49
|
+
selectors: {
|
|
50
|
+
'&:hover': {
|
|
51
|
+
position: 'relative',
|
|
52
|
+
opacity: 0.8,
|
|
53
|
+
backgroundColor: 'blue',
|
|
54
|
+
color: 'white'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
`,
|
|
59
|
+
],
|
|
60
|
+
invalid: [
|
|
61
|
+
// Basic style object with incorrect ordering
|
|
62
|
+
{
|
|
63
|
+
code: `
|
|
64
|
+
import { style } from '@vanilla-extract/css';
|
|
65
|
+
const myStyle = style({
|
|
66
|
+
color: 'blue',
|
|
67
|
+
width: '10rem',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
backgroundColor: 'red',
|
|
70
|
+
margin: '1rem',
|
|
71
|
+
position: 'relative'
|
|
72
|
+
});
|
|
73
|
+
`,
|
|
74
|
+
errors: [{ messageId: 'incorrectOrder' }],
|
|
75
|
+
output: `
|
|
76
|
+
import { style } from '@vanilla-extract/css';
|
|
77
|
+
const myStyle = style({
|
|
78
|
+
position: 'relative',
|
|
79
|
+
display: 'flex',
|
|
80
|
+
margin: '1rem',
|
|
81
|
+
backgroundColor: 'red',
|
|
82
|
+
width: '10rem',
|
|
83
|
+
color: 'blue'
|
|
84
|
+
});
|
|
85
|
+
`,
|
|
86
|
+
},
|
|
87
|
+
// Style with nested selectors having incorrect ordering
|
|
88
|
+
{
|
|
89
|
+
code: `
|
|
90
|
+
import { style } from '@vanilla-extract/css';
|
|
91
|
+
const myStyle = style({
|
|
92
|
+
color: 'blue',
|
|
93
|
+
display: 'flex',
|
|
94
|
+
backgroundColor: 'red',
|
|
95
|
+
position: 'relative',
|
|
96
|
+
|
|
97
|
+
selectors: {
|
|
98
|
+
'&:hover': {
|
|
99
|
+
color: 'white',
|
|
100
|
+
position: 'relative',
|
|
101
|
+
backgroundColor: 'blue'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
`,
|
|
106
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
107
|
+
output: `
|
|
108
|
+
import { style } from '@vanilla-extract/css';
|
|
109
|
+
const myStyle = style({
|
|
110
|
+
position: 'relative',
|
|
111
|
+
display: 'flex',
|
|
112
|
+
backgroundColor: 'red',
|
|
113
|
+
color: 'blue',
|
|
114
|
+
|
|
115
|
+
selectors: {
|
|
116
|
+
'&:hover': {
|
|
117
|
+
position: 'relative',
|
|
118
|
+
backgroundColor: 'blue',
|
|
119
|
+
color: 'white'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
`,
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
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/variants',
|
|
6
|
+
rule: concentricOrderRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
// styleVariants with concentric ordering
|
|
16
|
+
`
|
|
17
|
+
import { styleVariants } from '@vanilla-extract/css';
|
|
18
|
+
|
|
19
|
+
const variants = styleVariants({
|
|
20
|
+
primary: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
margin: '1rem',
|
|
24
|
+
backgroundColor: 'blue',
|
|
25
|
+
padding: '0.5rem',
|
|
26
|
+
color: 'white'
|
|
27
|
+
},
|
|
28
|
+
secondary: {
|
|
29
|
+
position: 'relative',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
margin: '0.8rem',
|
|
32
|
+
backgroundColor: 'gray',
|
|
33
|
+
padding: '0.4rem',
|
|
34
|
+
color: 'black'
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
`,
|
|
38
|
+
],
|
|
39
|
+
invalid: [
|
|
40
|
+
// styleVariants with incorrect ordering
|
|
41
|
+
{
|
|
42
|
+
code: `
|
|
43
|
+
import { styleVariants } from '@vanilla-extract/css';
|
|
44
|
+
const variants = styleVariants({
|
|
45
|
+
primary: {
|
|
46
|
+
color: 'white',
|
|
47
|
+
backgroundColor: 'blue',
|
|
48
|
+
padding: '0.5rem',
|
|
49
|
+
margin: '1rem',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
position: 'relative'
|
|
52
|
+
},
|
|
53
|
+
secondary: {
|
|
54
|
+
color: 'black',
|
|
55
|
+
backgroundColor: 'gray',
|
|
56
|
+
padding: '0.4rem',
|
|
57
|
+
margin: '0.8rem',
|
|
58
|
+
display: 'flex',
|
|
59
|
+
position: 'relative'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
`,
|
|
63
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
64
|
+
output: `
|
|
65
|
+
import { styleVariants } from '@vanilla-extract/css';
|
|
66
|
+
const variants = styleVariants({
|
|
67
|
+
primary: {
|
|
68
|
+
position: 'relative',
|
|
69
|
+
display: 'flex',
|
|
70
|
+
margin: '1rem',
|
|
71
|
+
backgroundColor: 'blue',
|
|
72
|
+
padding: '0.5rem',
|
|
73
|
+
color: 'white'
|
|
74
|
+
},
|
|
75
|
+
secondary: {
|
|
76
|
+
position: 'relative',
|
|
77
|
+
display: 'flex',
|
|
78
|
+
margin: '0.8rem',
|
|
79
|
+
backgroundColor: 'gray',
|
|
80
|
+
padding: '0.4rem',
|
|
81
|
+
color: 'black'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
`,
|
|
85
|
+
},
|
|
86
|
+
// styleVariants with some variants having incorrect ordering
|
|
87
|
+
{
|
|
88
|
+
code: `
|
|
89
|
+
import { styleVariants } from '@vanilla-extract/css';
|
|
90
|
+
const variants = styleVariants({
|
|
91
|
+
primary: {
|
|
92
|
+
position: 'relative',
|
|
93
|
+
display: 'flex',
|
|
94
|
+
margin: '1rem',
|
|
95
|
+
padding: '0.5rem',
|
|
96
|
+
backgroundColor: 'blue',
|
|
97
|
+
color: 'white'
|
|
98
|
+
},
|
|
99
|
+
secondary: {
|
|
100
|
+
color: 'black',
|
|
101
|
+
backgroundColor: 'gray',
|
|
102
|
+
padding: '0.4rem',
|
|
103
|
+
margin: '0.8rem',
|
|
104
|
+
display: 'flex',
|
|
105
|
+
position: 'relative'
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
`,
|
|
109
|
+
errors: [{ messageId: 'incorrectOrder' }, { messageId: 'incorrectOrder' }],
|
|
110
|
+
output: `
|
|
111
|
+
import { styleVariants } from '@vanilla-extract/css';
|
|
112
|
+
const variants = styleVariants({
|
|
113
|
+
primary: {
|
|
114
|
+
position: 'relative',
|
|
115
|
+
display: 'flex',
|
|
116
|
+
margin: '1rem',
|
|
117
|
+
backgroundColor: 'blue',
|
|
118
|
+
padding: '0.5rem',
|
|
119
|
+
color: 'white'
|
|
120
|
+
},
|
|
121
|
+
secondary: {
|
|
122
|
+
position: 'relative',
|
|
123
|
+
display: 'flex',
|
|
124
|
+
margin: '0.8rem',
|
|
125
|
+
backgroundColor: 'gray',
|
|
126
|
+
padding: '0.4rem',
|
|
127
|
+
color: 'black'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
`,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
});
|
|
@@ -12,8 +12,8 @@ const reportOrderingIssue = (ruleContext, currentProperty, nextProperty, cssProp
|
|
|
12
12
|
node: nextProperty.node,
|
|
13
13
|
messageId: 'incorrectOrder',
|
|
14
14
|
data: {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
nextProperty: nextProperty.name,
|
|
16
|
+
currentProperty: currentProperty.name,
|
|
17
17
|
},
|
|
18
18
|
fix: (fixer) => generateFixesForCSSOrder(fixer, ruleContext, cssPropertyInfoList, compareProperties, (propertyInfo) => propertyInfo.node),
|
|
19
19
|
});
|
|
@@ -6,11 +6,13 @@ const concentricOrderRule = {
|
|
|
6
6
|
description: 'enforce concentric CSS property ordering in vanilla-extract styles',
|
|
7
7
|
category: 'Stylistic Issues',
|
|
8
8
|
recommended: true,
|
|
9
|
+
url: 'https://rhodesmill.org/brandon/2011/concentric-css/',
|
|
9
10
|
},
|
|
10
11
|
fixable: 'code',
|
|
11
12
|
schema: [],
|
|
12
13
|
messages: {
|
|
13
|
-
incorrectOrder: "Property '{{
|
|
14
|
+
incorrectOrder: "Property '{{nextProperty}}' should come before '{{currentProperty}}' according to concentric CSS ordering.",
|
|
15
|
+
fontFaceOrder: "Properties in fontFace should be ordered with 'src' first, followed by other properties in alphabetical order. Property '{{nextProperty}}' should come before '{{currentProperty}}'.",
|
|
14
16
|
},
|
|
15
17
|
},
|
|
16
18
|
create(context) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|