@antebudimir/eslint-plugin-vanilla-extract 1.15.0 → 1.15.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.
@@ -1,5 +1,5 @@
1
1
  import { TSESTree } from '@typescript-eslint/utils';
2
- import { isEmptyObject } from '../shared-utils/empty-object-processor.js';
2
+ import { isCallExpressionWithEmptyObject, isEmptyObject } from '../shared-utils/empty-object-processor.js';
3
3
  import { ReferenceTracker, createReferenceTrackingVisitor } from '../shared-utils/reference-tracker.js';
4
4
  import { processConditionalExpression } from './conditional-processor.js';
5
5
  import { processEmptyNestedStyles } from './empty-nested-style-processor.js';
@@ -48,7 +48,13 @@ export const isEffectivelyEmptyStylesObject = (stylesObject) => {
48
48
  }
49
49
  if (propertyName === 'base') {
50
50
  hasBaseProperty = true;
51
- if (property.value.type === 'ObjectExpression' && !isEmptyObject(property.value)) {
51
+ // CallExpression (e.g., sprinkles(), style()) is considered non-empty unless it has an empty object argument, e.g. sprinkles({})
52
+ if (property.value.type === 'CallExpression') {
53
+ if (!isCallExpressionWithEmptyObject(property.value)) {
54
+ isBaseEmpty = false;
55
+ }
56
+ }
57
+ else if (property.value.type === 'ObjectExpression' && !isEmptyObject(property.value)) {
52
58
  isBaseEmpty = false;
53
59
  }
54
60
  }
@@ -1,5 +1,5 @@
1
1
  import { TSESTree } from '@typescript-eslint/utils';
2
- import { isEmptyObject } from '../shared-utils/empty-object-processor.js';
2
+ import { isCallExpressionWithEmptyObject, isEmptyObject } from '../shared-utils/empty-object-processor.js';
3
3
  import { processEmptyNestedStyles } from './empty-nested-style-processor.js';
4
4
  import { removeNodeWithComma } from './node-remover.js';
5
5
  import { areAllChildrenEmpty, getStyleKeyName } from './property-utils.js';
@@ -71,8 +71,28 @@ export const processRecipeProperties = (ruleContext, recipeNode, reportedNodes)
71
71
  if (variantValueProperty.type !== 'Property') {
72
72
  return;
73
73
  }
74
- // Check for non-object variant values
75
- if (variantValueProperty.value.type !== 'ObjectExpression') {
74
+ const valueType = variantValueProperty.value.type;
75
+ // Allow CallExpression (e.g., sprinkles(), style()) as valid variant values unless it has an empty object argument, e.g. sprinkles({})
76
+ if (valueType === 'CallExpression') {
77
+ const callExpression = variantValueProperty.value;
78
+ if (isCallExpressionWithEmptyObject(callExpression)) {
79
+ // Treat sprinkles({}) or style({}) as empty
80
+ if (!reportedNodes.has(variantValueProperty)) {
81
+ reportedNodes.add(variantValueProperty);
82
+ ruleContext.report({
83
+ node: variantValueProperty,
84
+ messageId: 'emptyVariantValue',
85
+ fix(fixer) {
86
+ return removeNodeWithComma(ruleContext, variantValueProperty, fixer);
87
+ },
88
+ });
89
+ }
90
+ }
91
+ // Valid CallExpressions with arguments are fine
92
+ return;
93
+ }
94
+ // Check for non-object variant values (excluding CallExpression)
95
+ if (valueType !== 'ObjectExpression') {
76
96
  if (!reportedNodes.has(variantValueProperty)) {
77
97
  reportedNodes.add(variantValueProperty);
78
98
  // Get a user-friendly type description as a string
@@ -9,3 +9,8 @@ export declare const isObjectExpression: (node: TSESTree.Node) => node is TSESTr
9
9
  * @returns True if the node is an ObjectExpression with no properties.
10
10
  */
11
11
  export declare const isEmptyObject: (node: TSESTree.Node) => boolean;
12
+ /**
13
+ * Checks if a CallExpression has an empty object as its first argument.
14
+ * Examples: sprinkles({}), style({}), recipe({})
15
+ */
16
+ export declare const isCallExpressionWithEmptyObject: (node: TSESTree.CallExpression) => boolean;
@@ -13,3 +13,14 @@ export const isObjectExpression = (node) => {
13
13
  export const isEmptyObject = (node) => {
14
14
  return isObjectExpression(node) && node.properties.length === 0;
15
15
  };
16
+ /**
17
+ * Checks if a CallExpression has an empty object as its first argument.
18
+ * Examples: sprinkles({}), style({}), recipe({})
19
+ */
20
+ export const isCallExpressionWithEmptyObject = (node) => {
21
+ if (node.arguments.length === 0) {
22
+ return false;
23
+ }
24
+ const firstArgument = node.arguments[0];
25
+ return firstArgument?.type === 'ObjectExpression' && isEmptyObject(firstArgument);
26
+ };
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import preferThemeTokensRule from './css-rules/prefer-theme-tokens/index.js';
11
11
  const vanillaExtract = {
12
12
  meta: {
13
13
  name: '@antebudimir/eslint-plugin-vanilla-extract',
14
- version: '1.15.0',
14
+ version: '1.15.1',
15
15
  },
16
16
  rules: {
17
17
  'alphabetical-order': alphabeticalOrderRule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antebudimir/eslint-plugin-vanilla-extract",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Comprehensive ESLint plugin for vanilla-extract with CSS property ordering, style validation, and best practices enforcement. Supports alphabetical, concentric and custom CSS ordering, auto-fixing, and zero-runtime safety.",
5
5
  "author": "Ante Budimir",
6
6
  "license": "MIT",
@@ -60,6 +60,7 @@
60
60
  "@typescript-eslint/utils": "^8.26.1",
61
61
  "@vanilla-extract/css": "^1.17.1",
62
62
  "@vanilla-extract/recipes": "^0.5.5",
63
+ "@vanilla-extract/sprinkles": "^1.6.0",
63
64
  "@vitest/coverage-v8": "3.0.8",
64
65
  "eslint": "^9.22.0",
65
66
  "eslint-config-prettier": "^10.1.1",
@@ -1,2 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- export declare const createNoPxUnitVisitors: (context: Rule.RuleContext) => Rule.RuleListener;
@@ -1,55 +0,0 @@
1
- import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
2
- import { processRecipeProperties } from '../shared-utils/recipe-property-processor.js';
3
- import { ReferenceTracker, createReferenceTrackingVisitor } from '../shared-utils/reference-tracker.js';
4
- import { processStyleNode } from '../shared-utils/style-node-processor.js';
5
- import { processNoPxUnitInStyleObject } from './processor.js';
6
- export const createNoPxUnitVisitors = (context) => {
7
- const tracker = new ReferenceTracker();
8
- const trackingVisitor = createReferenceTrackingVisitor(tracker);
9
- const options = context.options?.[0] || {};
10
- const allowSet = new Set((options.allow ?? []).map((s) => s));
11
- const process = (ctx, obj) => processNoPxUnitInStyleObject(ctx, obj, allowSet);
12
- return {
13
- ...trackingVisitor,
14
- CallExpression(node) {
15
- if (node.callee.type !== AST_NODE_TYPES.Identifier)
16
- return;
17
- const functionName = node.callee.name;
18
- if (!tracker.isTrackedFunction(functionName))
19
- return;
20
- const originalName = tracker.getOriginalName(functionName);
21
- if (!originalName)
22
- return;
23
- switch (originalName) {
24
- case 'fontFace':
25
- if (node.arguments.length > 0 && node.arguments[0]?.type === AST_NODE_TYPES.ObjectExpression) {
26
- process(context, node.arguments[0]);
27
- }
28
- break;
29
- case 'globalFontFace':
30
- if (node.arguments.length > 1 && node.arguments[1]?.type === AST_NODE_TYPES.ObjectExpression) {
31
- process(context, node.arguments[1]);
32
- }
33
- break;
34
- case 'style':
35
- case 'styleVariants':
36
- case 'keyframes':
37
- if (node.arguments.length > 0) {
38
- processStyleNode(context, node.arguments[0], (ctx, obj) => process(ctx, obj));
39
- }
40
- break;
41
- case 'globalStyle':
42
- case 'globalKeyframes':
43
- if (node.arguments.length >= 2) {
44
- processStyleNode(context, node.arguments[1], (ctx, obj) => process(ctx, obj));
45
- }
46
- break;
47
- case 'recipe':
48
- if (node.arguments.length > 0 && node.arguments[0]?.type === AST_NODE_TYPES.ObjectExpression) {
49
- processRecipeProperties(context, node.arguments[0], (ctx, obj) => process(ctx, obj));
50
- }
51
- break;
52
- }
53
- },
54
- };
55
- };
@@ -1,3 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import { TSESTree } from '@typescript-eslint/utils';
3
- export declare const processNoPxUnitInStyleObject: (context: Rule.RuleContext, node: TSESTree.ObjectExpression, allowSet: Set<string>) => void;
@@ -1,93 +0,0 @@
1
- import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
2
- const containsPx = (text) => /(^|\W)-?\d*\.?\d*px(?![a-zA-Z])/i.test(text);
3
- const replacePxWith = (text, replacement) => text.replace(/px(?![a-zA-Z])/g, replacement);
4
- const toKebab = (name) => name.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
5
- const getValueText = (node) => {
6
- if (node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string') {
7
- return node.value;
8
- }
9
- if (node.type === AST_NODE_TYPES.TemplateLiteral) {
10
- // Join all quasis (ignore expressions content)
11
- const raw = node.quasis.map((q) => q.value.raw ?? '').join('');
12
- return raw;
13
- }
14
- return null;
15
- };
16
- const canSuggestFix = (node) => {
17
- if (node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string')
18
- return 'literal';
19
- if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0)
20
- return 'simple-template';
21
- return null;
22
- };
23
- export const processNoPxUnitInStyleObject = (context, node, allowSet) => {
24
- for (const property of node.properties) {
25
- if (property.type !== AST_NODE_TYPES.Property)
26
- continue;
27
- // Determine property name when possible
28
- let propertyName = null;
29
- if (property.key.type === AST_NODE_TYPES.Identifier) {
30
- propertyName = property.key.name;
31
- }
32
- else if (property.key.type === AST_NODE_TYPES.Literal && typeof property.key.value === 'string') {
33
- propertyName = property.key.value;
34
- }
35
- // Recurse into known nested containers
36
- if (propertyName === '@media' || propertyName === 'selectors') {
37
- if (property.value.type === AST_NODE_TYPES.ObjectExpression) {
38
- for (const nested of property.value.properties) {
39
- if (nested.type === AST_NODE_TYPES.Property && nested.value.type === AST_NODE_TYPES.ObjectExpression) {
40
- processNoPxUnitInStyleObject(context, nested.value, allowSet);
41
- }
42
- }
43
- }
44
- continue;
45
- }
46
- // Traverse any nested object
47
- if (property.value.type === AST_NODE_TYPES.ObjectExpression) {
48
- processNoPxUnitInStyleObject(context, property.value, allowSet);
49
- continue;
50
- }
51
- // Skip if property is whitelisted (supports both camelCase and kebab-case)
52
- if (propertyName) {
53
- const kebab = toKebab(propertyName);
54
- if (allowSet.has(propertyName) || allowSet.has(kebab)) {
55
- continue;
56
- }
57
- }
58
- // Check string or template literal values
59
- const text = getValueText(property.value);
60
- if (text && containsPx(text)) {
61
- const fixability = canSuggestFix(property.value);
62
- context.report({
63
- node: property.value,
64
- messageId: 'noPxUnit',
65
- suggest: fixability
66
- ? [
67
- {
68
- messageId: 'removePx',
69
- fix: (fixer) => {
70
- const newText = replacePxWith(text, '');
71
- if (fixability === 'literal') {
72
- return fixer.replaceText(property.value, `'${newText}'`);
73
- }
74
- // simple template with no expressions
75
- return fixer.replaceText(property.value, `\`${newText}\``);
76
- },
77
- },
78
- {
79
- messageId: 'replaceWithRem',
80
- fix: (fixer) => {
81
- const newText = replacePxWith(text, 'rem');
82
- if (fixability === 'literal') {
83
- return fixer.replaceText(property.value, `'${newText}'`);
84
- }
85
- return fixer.replaceText(property.value, `\`${newText}\``);
86
- },
87
- },
88
- ]
89
- : undefined,
90
- });
91
- }
92
- }
93
- };
@@ -1,2 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- export declare const createNoPxUnitVisitors: (context: Rule.RuleContext) => Rule.RuleListener;
@@ -1,55 +0,0 @@
1
- import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
2
- import { processRecipeProperties } from '../shared-utils/recipe-property-processor.js';
3
- import { ReferenceTracker, createReferenceTrackingVisitor } from '../shared-utils/reference-tracker.js';
4
- import { processStyleNode } from '../shared-utils/style-node-processor.js';
5
- import { processNoPxUnitInStyleObject } from './processor.js';
6
- export const createNoPxUnitVisitors = (context) => {
7
- const tracker = new ReferenceTracker();
8
- const trackingVisitor = createReferenceTrackingVisitor(tracker);
9
- const options = context.options?.[0] || {};
10
- const allowSet = new Set((options.allow ?? []).map((s) => s));
11
- const process = (ctx, obj) => processNoPxUnitInStyleObject(ctx, obj, allowSet);
12
- return {
13
- ...trackingVisitor,
14
- CallExpression(node) {
15
- if (node.callee.type !== AST_NODE_TYPES.Identifier)
16
- return;
17
- const functionName = node.callee.name;
18
- if (!tracker.isTrackedFunction(functionName))
19
- return;
20
- const originalName = tracker.getOriginalName(functionName);
21
- if (!originalName)
22
- return;
23
- switch (originalName) {
24
- case 'fontFace':
25
- if (node.arguments.length > 0 && node.arguments[0]?.type === AST_NODE_TYPES.ObjectExpression) {
26
- process(context, node.arguments[0]);
27
- }
28
- break;
29
- case 'globalFontFace':
30
- if (node.arguments.length > 1 && node.arguments[1]?.type === AST_NODE_TYPES.ObjectExpression) {
31
- process(context, node.arguments[1]);
32
- }
33
- break;
34
- case 'style':
35
- case 'styleVariants':
36
- case 'keyframes':
37
- if (node.arguments.length > 0) {
38
- processStyleNode(context, node.arguments[0], (ctx, obj) => process(ctx, obj));
39
- }
40
- break;
41
- case 'globalStyle':
42
- case 'globalKeyframes':
43
- if (node.arguments.length >= 2) {
44
- processStyleNode(context, node.arguments[1], (ctx, obj) => process(ctx, obj));
45
- }
46
- break;
47
- case 'recipe':
48
- if (node.arguments.length > 0 && node.arguments[0]?.type === AST_NODE_TYPES.ObjectExpression) {
49
- processRecipeProperties(context, node.arguments[0], (ctx, obj) => process(ctx, obj));
50
- }
51
- break;
52
- }
53
- },
54
- };
55
- };
@@ -1,4 +0,0 @@
1
- export declare const button: string;
2
- export declare const card: string;
3
- export declare const text: string;
4
- export declare const container: string;
@@ -1,45 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- // This file has hard-coded values that will trigger eslint errors
3
- // when the prefer-theme-tokens rule is enabled
4
- export const button = style({
5
- // ❌ Hard-coded color - should use theme.colors.text
6
- color: '#ffffff',
7
- // ❌ Hard-coded color - should use theme.colors.primary
8
- backgroundColor: '#3b82f6',
9
- // ❌ Hard-coded spacing - should use theme.spacing
10
- padding: '12px 24px',
11
- // ❌ Hard-coded font size - should use theme.fontSizes
12
- fontSize: '14px',
13
- // ❌ Hard-coded border radius - should use theme.radii
14
- borderRadius: '6px',
15
- // ❌ Hard-coded color in border
16
- border: '1px solid #e5e7eb',
17
- });
18
- export const card = style({
19
- // ❌ Multiple hard-coded colors
20
- backgroundColor: 'white',
21
- color: 'black',
22
- // ❌ Hard-coded spacing values
23
- padding: '16px',
24
- margin: '8px',
25
- gap: '12px',
26
- // ❌ Hard-coded border radius
27
- borderRadius: '8px',
28
- });
29
- export const text = style({
30
- // ❌ Hard-coded font sizes
31
- fontSize: '16px',
32
- lineHeight: '24px',
33
- // ❌ Hard-coded colors
34
- color: 'rgb(31, 41, 55)',
35
- });
36
- export const container = style({
37
- // ❌ Hard-coded spacing in multiple properties
38
- marginTop: '20px',
39
- paddingLeft: '16px',
40
- paddingRight: '16px',
41
- // ❌ Hard-coded width (though percentages are allowed)
42
- width: '300px',
43
- // ❌ Hard-coded color
44
- borderColor: '#e5e7eb',
45
- });
@@ -1,5 +0,0 @@
1
- export declare const button: string;
2
- export declare const card: string;
3
- export declare const text: string;
4
- export declare const container: string;
5
- export declare const allowedValues: string;
@@ -1,48 +0,0 @@
1
- import { style } from '@vanilla-extract/css';
2
- import { theme } from './demo-theme.css';
3
- // This file uses theme tokens - no eslint errors!
4
- export const button = style({
5
- // ✅ Using theme tokens for colors
6
- color: theme.colors.text,
7
- backgroundColor: theme.colors.primary,
8
- // ✅ Using theme tokens for spacing
9
- padding: `${theme.spacing.sm} ${theme.spacing.md}`,
10
- // ✅ Using theme tokens for font size
11
- fontSize: theme.fontSizes.sm,
12
- // ✅ Using theme tokens for border radius
13
- borderRadius: theme.radii.md,
14
- // ✅ Using theme tokens in border
15
- border: `1px solid ${theme.colors.border}`,
16
- });
17
- export const card = style({
18
- // ✅ All theme tokens
19
- backgroundColor: theme.colors.background,
20
- color: theme.colors.text,
21
- padding: theme.spacing.md,
22
- margin: theme.spacing.sm,
23
- gap: theme.spacing.sm,
24
- borderRadius: theme.radii.lg,
25
- });
26
- export const text = style({
27
- // ✅ Theme tokens for typography
28
- fontSize: theme.fontSizes.base,
29
- lineHeight: theme.fontSizes.lg,
30
- color: theme.colors.text,
31
- });
32
- export const container = style({
33
- // ✅ Theme tokens for spacing
34
- marginTop: theme.spacing.lg,
35
- paddingLeft: theme.spacing.md,
36
- paddingRight: theme.spacing.md,
37
- // ✅ Percentages are allowed by default
38
- width: '100%',
39
- // ✅ Theme token for color
40
- borderColor: theme.colors.border,
41
- });
42
- export const allowedValues = style({
43
- // ✅ These special values are allowed by default
44
- margin: '0', // Zero is allowed
45
- padding: 'auto', // Auto is allowed
46
- width: '100%', // Percentages are allowed
47
- height: 'inherit', // CSS keywords are allowed
48
- });
@@ -1,37 +0,0 @@
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
- };
@@ -1,39 +0,0 @@
1
- import { createTheme } from '@vanilla-extract/css';
2
- // Create a theme with design tokens
3
- export const [themeClass, theme] = createTheme({
4
- colors: {
5
- primary: '#3b82f6',
6
- secondary: '#8b5cf6',
7
- background: '#ffffff',
8
- text: '#1f2937',
9
- error: '#ef4444',
10
- success: '#10b981',
11
- warning: '#f59e0b',
12
- hover: '#2563eb',
13
- border: '#e5e7eb',
14
- },
15
- spacing: {
16
- xs: '0.25rem',
17
- sm: '0.5rem',
18
- md: '1rem',
19
- lg: '1.5rem',
20
- xl: '2rem',
21
- '2xl': '3rem',
22
- },
23
- fontSizes: {
24
- xs: '0.75rem',
25
- sm: '0.875rem',
26
- base: '1rem',
27
- lg: '1.125rem',
28
- xl: '1.25rem',
29
- '2xl': '1.5rem',
30
- '3xl': '1.875rem',
31
- },
32
- radii: {
33
- none: '0',
34
- sm: '0.125rem',
35
- md: '0.375rem',
36
- lg: '0.5rem',
37
- full: '9999px',
38
- },
39
- });
@@ -1,26 +0,0 @@
1
- export declare const badButton: string;
2
- export declare const badCard: string;
3
- export declare const badText: string;
4
- export declare const badBox: string;
5
- export declare const badComponent: string;
6
- export declare const badRecipe: import("@vanilla-extract/recipes").RuntimeFn<{
7
- size: {
8
- small: {
9
- fontSize: "12px";
10
- padding: "8px";
11
- };
12
- large: {
13
- fontSize: "18px";
14
- padding: "24px";
15
- };
16
- };
17
- variant: {
18
- primary: {
19
- backgroundColor: "#3b82f6";
20
- };
21
- danger: {
22
- backgroundColor: "#ef4444";
23
- };
24
- };
25
- }>;
26
- export declare const badResponsive: string;
@@ -1,85 +0,0 @@
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
- });
@@ -1,27 +0,0 @@
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;