@antebudimir/eslint-plugin-vanilla-extract 1.17.0 → 1.17.1
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 +29 -4
- package/dist/css-rules/no-empty-blocks/fix-utils.d.ts +4 -0
- package/dist/css-rules/no-empty-blocks/fix-utils.js +71 -22
- package/dist/css-rules/no-px-unit/no-px-unit-visitor-creator.d.ts +2 -0
- package/dist/css-rules/no-px-unit/no-px-unit-visitor-creator.js +55 -0
- package/dist/css-rules/no-px-unit/processor.d.ts +3 -0
- package/dist/css-rules/no-px-unit/processor.js +93 -0
- package/dist/css-rules/no-px-unit/visitor-creator.d.ts +2 -0
- package/dist/css-rules/no-px-unit/visitor-creator.js +55 -0
- package/dist/demo-bad-example.css.d.ts +4 -0
- package/dist/demo-bad-example.css.js +45 -0
- package/dist/demo-good-example.css.d.ts +5 -0
- package/dist/demo-good-example.css.js +48 -0
- package/dist/demo-theme.css.d.ts +37 -0
- package/dist/demo-theme.css.js +39 -0
- package/dist/index.js +1 -1
- package/dist/sample-bad.css.d.ts +26 -0
- package/dist/sample-bad.css.js +85 -0
- package/dist/sample-good.css.d.ts +27 -0
- package/dist/sample-good.css.js +94 -0
- package/dist/sample-theme.css.d.ts +37 -0
- package/dist/sample-theme.css.js +38 -0
- package/dist/sample.css.d.ts +75 -0
- package/dist/sample.css.js +530 -0
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { style, globalStyle } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
3
|
+
// ❌ BAD: Hard-coded colors
|
|
4
|
+
export const badButton = style({
|
|
5
|
+
color: '#ffffff', // Should use theme.colors.text
|
|
6
|
+
backgroundColor: '#3b82f6', // Should use theme.colors.primary
|
|
7
|
+
borderColor: 'rgb(59, 130, 246)', // Should use theme.colors.primary
|
|
8
|
+
});
|
|
9
|
+
// ❌ BAD: Hard-coded spacing
|
|
10
|
+
export const badCard = style({
|
|
11
|
+
padding: '16px', // Should use theme.spacing.md
|
|
12
|
+
margin: '8px', // Should use theme.spacing.sm
|
|
13
|
+
gap: '12px', // Should use theme.spacing between sm and md
|
|
14
|
+
width: '200px', // Should use theme or percentage
|
|
15
|
+
});
|
|
16
|
+
// ❌ BAD: Hard-coded font sizes
|
|
17
|
+
export const badText = style({
|
|
18
|
+
fontSize: '14px', // Should use theme.fontSizes.sm
|
|
19
|
+
lineHeight: '1.5rem', // Should use theme.fontSizes
|
|
20
|
+
});
|
|
21
|
+
// ❌ BAD: Hard-coded border radius
|
|
22
|
+
export const badBox = style({
|
|
23
|
+
borderRadius: '8px', // Should use theme.radii.md
|
|
24
|
+
borderTopLeftRadius: '4px', // Should use theme.radii.sm
|
|
25
|
+
});
|
|
26
|
+
// ❌ BAD: Multiple violations
|
|
27
|
+
export const badComponent = style({
|
|
28
|
+
color: 'red', // Hard-coded color
|
|
29
|
+
backgroundColor: '#f0f0f0', // Hard-coded color
|
|
30
|
+
padding: '20px', // Hard-coded spacing
|
|
31
|
+
margin: '10px 15px', // Hard-coded spacing
|
|
32
|
+
fontSize: '16px', // Hard-coded font size
|
|
33
|
+
borderRadius: '6px', // Hard-coded border radius
|
|
34
|
+
border: '1px solid #ccc', // Hard-coded color in border
|
|
35
|
+
});
|
|
36
|
+
// ❌ BAD: Recipe with hard-coded values
|
|
37
|
+
export const badRecipe = recipe({
|
|
38
|
+
base: {
|
|
39
|
+
color: '#000000', // Hard-coded color
|
|
40
|
+
padding: '12px', // Hard-coded spacing
|
|
41
|
+
},
|
|
42
|
+
variants: {
|
|
43
|
+
size: {
|
|
44
|
+
small: {
|
|
45
|
+
fontSize: '12px', // Hard-coded font size
|
|
46
|
+
padding: '8px', // Hard-coded spacing
|
|
47
|
+
},
|
|
48
|
+
large: {
|
|
49
|
+
fontSize: '18px', // Hard-coded font size
|
|
50
|
+
padding: '24px', // Hard-coded spacing
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
variant: {
|
|
54
|
+
primary: {
|
|
55
|
+
backgroundColor: '#3b82f6', // Hard-coded color
|
|
56
|
+
},
|
|
57
|
+
danger: {
|
|
58
|
+
backgroundColor: '#ef4444', // Hard-coded color
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
// ❌ BAD: Nested structures with hard-coded values
|
|
64
|
+
export const badResponsive = style({
|
|
65
|
+
color: '#333',
|
|
66
|
+
'@media': {
|
|
67
|
+
'(min-width: 768px)': {
|
|
68
|
+
padding: '32px', // Hard-coded spacing
|
|
69
|
+
fontSize: '20px', // Hard-coded font size
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
selectors: {
|
|
73
|
+
'&:hover': {
|
|
74
|
+
backgroundColor: '#e0e0e0', // Hard-coded color
|
|
75
|
+
borderColor: 'blue', // Hard-coded color
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
// ❌ BAD: Global styles with hard-coded values
|
|
80
|
+
globalStyle('body', {
|
|
81
|
+
color: '#1f2937', // Hard-coded color
|
|
82
|
+
backgroundColor: '#ffffff', // Hard-coded color
|
|
83
|
+
margin: '0px', // Hard-coded spacing (though 0 is often allowed)
|
|
84
|
+
padding: '0px', // Hard-coded spacing
|
|
85
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const goodButton: string;
|
|
2
|
+
export declare const goodCard: string;
|
|
3
|
+
export declare const goodText: string;
|
|
4
|
+
export declare const goodBox: string;
|
|
5
|
+
export declare const goodComponent: string;
|
|
6
|
+
export declare const goodRecipe: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
7
|
+
size: {
|
|
8
|
+
small: {
|
|
9
|
+
fontSize: any;
|
|
10
|
+
padding: any;
|
|
11
|
+
};
|
|
12
|
+
large: {
|
|
13
|
+
fontSize: any;
|
|
14
|
+
padding: any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
variant: {
|
|
18
|
+
primary: {
|
|
19
|
+
backgroundColor: any;
|
|
20
|
+
};
|
|
21
|
+
danger: {
|
|
22
|
+
backgroundColor: any;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
export declare const goodResponsive: string;
|
|
27
|
+
export declare const goodMixed: string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { style, globalStyle } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
3
|
+
import { theme } from './sample-theme.css';
|
|
4
|
+
// ✅ GOOD: Using theme tokens for colors
|
|
5
|
+
export const goodButton = style({
|
|
6
|
+
color: theme.colors.text,
|
|
7
|
+
backgroundColor: theme.colors.primary,
|
|
8
|
+
borderColor: theme.colors.border,
|
|
9
|
+
});
|
|
10
|
+
// ✅ GOOD: Using theme tokens for spacing
|
|
11
|
+
export const goodCard = style({
|
|
12
|
+
padding: theme.spacing.md,
|
|
13
|
+
margin: theme.spacing.sm,
|
|
14
|
+
gap: theme.spacing.md,
|
|
15
|
+
width: '100%', // Percentages are allowed
|
|
16
|
+
});
|
|
17
|
+
// ✅ GOOD: Using theme tokens for font sizes
|
|
18
|
+
export const goodText = style({
|
|
19
|
+
fontSize: theme.fontSizes.sm,
|
|
20
|
+
lineHeight: theme.fontSizes.base,
|
|
21
|
+
});
|
|
22
|
+
// ✅ GOOD: Using theme tokens for border radius
|
|
23
|
+
export const goodBox = style({
|
|
24
|
+
borderRadius: theme.radii.md,
|
|
25
|
+
borderTopLeftRadius: theme.radii.sm,
|
|
26
|
+
});
|
|
27
|
+
// ✅ GOOD: All theme tokens
|
|
28
|
+
export const goodComponent = style({
|
|
29
|
+
color: theme.colors.text,
|
|
30
|
+
backgroundColor: theme.colors.background,
|
|
31
|
+
padding: theme.spacing.lg,
|
|
32
|
+
margin: `${theme.spacing.sm} ${theme.spacing.md}`,
|
|
33
|
+
fontSize: theme.fontSizes.base,
|
|
34
|
+
borderRadius: theme.radii.md,
|
|
35
|
+
border: `1px solid ${theme.colors.border}`,
|
|
36
|
+
});
|
|
37
|
+
// ✅ GOOD: Recipe with theme tokens
|
|
38
|
+
export const goodRecipe = recipe({
|
|
39
|
+
base: {
|
|
40
|
+
color: theme.colors.text,
|
|
41
|
+
padding: theme.spacing.md,
|
|
42
|
+
},
|
|
43
|
+
variants: {
|
|
44
|
+
size: {
|
|
45
|
+
small: {
|
|
46
|
+
fontSize: theme.fontSizes.sm,
|
|
47
|
+
padding: theme.spacing.sm,
|
|
48
|
+
},
|
|
49
|
+
large: {
|
|
50
|
+
fontSize: theme.fontSizes.xl,
|
|
51
|
+
padding: theme.spacing.xl,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
variant: {
|
|
55
|
+
primary: {
|
|
56
|
+
backgroundColor: theme.colors.primary,
|
|
57
|
+
},
|
|
58
|
+
danger: {
|
|
59
|
+
backgroundColor: theme.colors.error,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
// ✅ GOOD: Nested structures with theme tokens
|
|
65
|
+
export const goodResponsive = style({
|
|
66
|
+
color: theme.colors.text,
|
|
67
|
+
'@media': {
|
|
68
|
+
'(min-width: 768px)': {
|
|
69
|
+
padding: theme.spacing['2xl'],
|
|
70
|
+
fontSize: theme.fontSizes['2xl'],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
selectors: {
|
|
74
|
+
'&:hover': {
|
|
75
|
+
backgroundColor: theme.colors.hover,
|
|
76
|
+
borderColor: theme.colors.primary,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
// ✅ GOOD: Global styles with theme tokens
|
|
81
|
+
globalStyle('body', {
|
|
82
|
+
color: theme.colors.text,
|
|
83
|
+
backgroundColor: theme.colors.background,
|
|
84
|
+
margin: '0', // Special values like '0' are allowed
|
|
85
|
+
padding: '0',
|
|
86
|
+
});
|
|
87
|
+
// ✅ GOOD: Mixed with allowed values
|
|
88
|
+
export const goodMixed = style({
|
|
89
|
+
color: theme.colors.text,
|
|
90
|
+
margin: '0', // '0' is allowed
|
|
91
|
+
padding: 'auto', // 'auto' is allowed
|
|
92
|
+
width: '100%', // Percentages are allowed
|
|
93
|
+
height: 'inherit', // CSS keywords are allowed
|
|
94
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const themeClass: string, theme: {
|
|
2
|
+
colors: {
|
|
3
|
+
primary: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
4
|
+
secondary: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
5
|
+
background: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
6
|
+
text: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
7
|
+
error: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
8
|
+
success: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
9
|
+
warning: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
10
|
+
hover: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
11
|
+
border: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
12
|
+
};
|
|
13
|
+
spacing: {
|
|
14
|
+
xs: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
15
|
+
sm: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
16
|
+
md: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
17
|
+
lg: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
18
|
+
xl: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
19
|
+
'2xl': `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
20
|
+
};
|
|
21
|
+
fontSizes: {
|
|
22
|
+
xs: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
23
|
+
sm: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
24
|
+
base: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
25
|
+
lg: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
26
|
+
xl: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
27
|
+
'2xl': `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
28
|
+
'3xl': `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
29
|
+
};
|
|
30
|
+
radii: {
|
|
31
|
+
none: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
32
|
+
sm: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
33
|
+
md: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
34
|
+
lg: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
35
|
+
full: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createTheme } from '@vanilla-extract/css';
|
|
2
|
+
export const [themeClass, theme] = createTheme({
|
|
3
|
+
colors: {
|
|
4
|
+
primary: '#3b82f6',
|
|
5
|
+
secondary: '#8b5cf6',
|
|
6
|
+
background: '#ffffff',
|
|
7
|
+
text: '#1f2937',
|
|
8
|
+
error: '#ef4444',
|
|
9
|
+
success: '#10b981',
|
|
10
|
+
warning: '#f59e0b',
|
|
11
|
+
hover: '#2563eb',
|
|
12
|
+
border: '#e5e7eb',
|
|
13
|
+
},
|
|
14
|
+
spacing: {
|
|
15
|
+
xs: '0.25rem',
|
|
16
|
+
sm: '0.5rem',
|
|
17
|
+
md: '1rem',
|
|
18
|
+
lg: '1.5rem',
|
|
19
|
+
xl: '2rem',
|
|
20
|
+
'2xl': '3rem',
|
|
21
|
+
},
|
|
22
|
+
fontSizes: {
|
|
23
|
+
xs: '0.75rem',
|
|
24
|
+
sm: '0.875rem',
|
|
25
|
+
base: '1rem',
|
|
26
|
+
lg: '1.125rem',
|
|
27
|
+
xl: '1.25rem',
|
|
28
|
+
'2xl': '1.5rem',
|
|
29
|
+
'3xl': '1.875rem',
|
|
30
|
+
},
|
|
31
|
+
radii: {
|
|
32
|
+
none: '0',
|
|
33
|
+
sm: '0.125rem',
|
|
34
|
+
md: '0.375rem',
|
|
35
|
+
lg: '0.5rem',
|
|
36
|
+
full: '9999px',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const theFont: string;
|
|
2
|
+
export declare const spinster: void;
|
|
3
|
+
export declare const starter: string;
|
|
4
|
+
export declare const accordionContent: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
5
|
+
isOpen: {
|
|
6
|
+
false: {
|
|
7
|
+
boxSizing: "inherit";
|
|
8
|
+
position: "relative";
|
|
9
|
+
right: "inherit";
|
|
10
|
+
display: "flex";
|
|
11
|
+
gap: "revert";
|
|
12
|
+
transform: "none";
|
|
13
|
+
margin: "11rem";
|
|
14
|
+
outline: "none";
|
|
15
|
+
border: "Background";
|
|
16
|
+
borderRight: "ActiveBorder";
|
|
17
|
+
borderLeft: "ActiveBorder";
|
|
18
|
+
borderRadius: "initial";
|
|
19
|
+
borderBottomLeftRadius: "initial";
|
|
20
|
+
borderBottomRightRadius: "initial";
|
|
21
|
+
boxShadow: "none";
|
|
22
|
+
backgroundColor: "initial";
|
|
23
|
+
cursor: "pointer";
|
|
24
|
+
width: "100%";
|
|
25
|
+
color: "red";
|
|
26
|
+
fontSize: "large";
|
|
27
|
+
};
|
|
28
|
+
true: {
|
|
29
|
+
boxSizing: "inherit";
|
|
30
|
+
position: "relative";
|
|
31
|
+
right: "inherit";
|
|
32
|
+
display: "flex";
|
|
33
|
+
gap: "revert";
|
|
34
|
+
transform: "none";
|
|
35
|
+
margin: "11rem";
|
|
36
|
+
outline: "none";
|
|
37
|
+
border: "Background";
|
|
38
|
+
borderRight: "ActiveBorder";
|
|
39
|
+
borderLeft: "ActiveBorder";
|
|
40
|
+
borderRadius: "initial";
|
|
41
|
+
borderBottomLeftRadius: "initial";
|
|
42
|
+
borderBottomRightRadius: "initial";
|
|
43
|
+
boxShadow: "none";
|
|
44
|
+
backgroundColor: "initial";
|
|
45
|
+
cursor: "pointer";
|
|
46
|
+
width: "100%";
|
|
47
|
+
color: "red";
|
|
48
|
+
fontSize: "large";
|
|
49
|
+
':hover': {
|
|
50
|
+
boxSizing: "inherit";
|
|
51
|
+
position: "relative";
|
|
52
|
+
right: "inherit";
|
|
53
|
+
display: "flex";
|
|
54
|
+
gap: "revert";
|
|
55
|
+
transform: "none";
|
|
56
|
+
margin: "11rem";
|
|
57
|
+
outline: "none";
|
|
58
|
+
border: "Background";
|
|
59
|
+
borderRight: "ActiveBorder";
|
|
60
|
+
borderLeft: "ActiveBorder";
|
|
61
|
+
borderRadius: "initial";
|
|
62
|
+
borderBottomLeftRadius: "initial";
|
|
63
|
+
borderBottomRightRadius: "initial";
|
|
64
|
+
boxShadow: "none";
|
|
65
|
+
backgroundColor: "initial";
|
|
66
|
+
cursor: "pointer";
|
|
67
|
+
width: "100%";
|
|
68
|
+
color: "red";
|
|
69
|
+
fontSize: "large";
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
export declare const item: string;
|
|
75
|
+
export declare const selectButtonVariants: Record<"bordered" | "borderless", string>;
|