@antebudimir/eslint-plugin-vanilla-extract 1.7.0 → 1.8.0
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 +34 -3
- package/dist/css-rules/no-empty-blocks/conditional-processor.d.ts +1 -1
- package/dist/css-rules/no-empty-blocks/conditional-processor.js +2 -2
- package/dist/css-rules/no-empty-blocks/empty-nested-style-processor.d.ts +1 -1
- package/dist/css-rules/no-empty-blocks/empty-nested-style-processor.js +2 -2
- package/dist/css-rules/no-empty-blocks/empty-style-visitor-creator.d.ts +4 -4
- package/dist/css-rules/no-empty-blocks/empty-style-visitor-creator.js +79 -79
- package/dist/css-rules/no-empty-blocks/node-remover.d.ts +1 -1
- package/dist/css-rules/no-empty-blocks/node-remover.js +2 -2
- package/dist/css-rules/no-empty-blocks/property-utils.d.ts +1 -1
- package/dist/css-rules/no-empty-blocks/property-utils.js +2 -2
- package/dist/css-rules/no-empty-blocks/recipe-processor.d.ts +1 -1
- package/dist/css-rules/no-empty-blocks/recipe-processor.js +2 -2
- package/dist/css-rules/no-empty-blocks/style-variants-processor.d.ts +1 -1
- package/dist/css-rules/no-empty-blocks/style-variants-processor.js +2 -2
- package/dist/css-rules/no-zero-unit/_tests_/no-zero-unit.test.d.ts +1 -0
- package/dist/css-rules/no-zero-unit/_tests_/no-zero-unit.test.js +333 -0
- package/dist/css-rules/no-zero-unit/index.d.ts +2 -0
- package/dist/css-rules/no-zero-unit/index.js +2 -0
- package/dist/css-rules/no-zero-unit/rule-definition.d.ts +3 -0
- package/dist/css-rules/no-zero-unit/rule-definition.js +20 -0
- package/dist/css-rules/no-zero-unit/zero-unit-processor.d.ts +9 -0
- package/dist/css-rules/no-zero-unit/zero-unit-processor.js +29 -0
- package/dist/css-rules/no-zero-unit/zero-unit-visitor-creator.d.ts +14 -0
- package/dist/css-rules/no-zero-unit/zero-unit-visitor-creator.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ export default [
|
|
|
66
66
|
// Optionally override specific rules
|
|
67
67
|
// 'vanilla-extract/concentric-order': 'warn', // Change severity from error to warn
|
|
68
68
|
// 'vanilla-extract/no-empty-style-blocks': 'off', // Disable a recommended rule
|
|
69
|
+
// 'vanilla-extract/no-zero-unit': 'warn', // Change severity from error to warn
|
|
69
70
|
|
|
70
71
|
// Add additional rules not in recommended config
|
|
71
72
|
// 'vanilla-extract/alphabetical-order': 'error', // Override concentric-order rule
|
|
@@ -80,6 +81,7 @@ The recommended configuration enables the following rules with error severity:
|
|
|
80
81
|
|
|
81
82
|
- `vanilla-extract/concentric-order`: Enforces concentric CSS property ordering
|
|
82
83
|
- `vanilla-extract/no-empty-style-blocks`: Prevents empty style blocks
|
|
84
|
+
- `vanilla-extract/no-zero-unit`: removes unnecessary units for zero values
|
|
83
85
|
|
|
84
86
|
You can use the recommended configuration as a starting point and override rules as needed for your project.
|
|
85
87
|
|
|
@@ -108,6 +110,7 @@ export default [
|
|
|
108
110
|
sortRemainingProperties: 'concentric', // 'alphabetical' is default
|
|
109
111
|
},
|
|
110
112
|
],
|
|
113
|
+
'vanilla-extract/no-zero-unit': 'warn',
|
|
111
114
|
},
|
|
112
115
|
},
|
|
113
116
|
];
|
|
@@ -266,6 +269,34 @@ export const recipeWithEmptyVariants = recipe({
|
|
|
266
269
|
});
|
|
267
270
|
```
|
|
268
271
|
|
|
272
|
+
## vanilla-extract/no-zero-unit
|
|
273
|
+
|
|
274
|
+
This rule enforces the removal of unnecessary units for zero values in vanilla-extract style objects. It helps maintain cleaner and more consistent CSS by eliminating redundant units when the value is zero.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// ❌ Incorrect
|
|
278
|
+
import { style } from '@vanilla-extract/css';
|
|
279
|
+
|
|
280
|
+
export const myStyle = style({
|
|
281
|
+
margin: '0px',
|
|
282
|
+
padding: '0rem',
|
|
283
|
+
width: '0%',
|
|
284
|
+
height: '0vh',
|
|
285
|
+
top: '-0em',
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// ✅ Correct
|
|
289
|
+
import { style } from '@vanilla-extract/css';
|
|
290
|
+
|
|
291
|
+
export const myStyle = style({
|
|
292
|
+
margin: '0',
|
|
293
|
+
padding: '0',
|
|
294
|
+
width: '0',
|
|
295
|
+
height: '0',
|
|
296
|
+
top: '0',
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
269
300
|
## Font Face Declarations
|
|
270
301
|
|
|
271
302
|
For `fontFace` and `globalFontFace` API calls, all three ordering rules (alphabetical, concentric, and custom) enforce the same special ordering:
|
|
@@ -341,16 +372,16 @@ The roadmap outlines the project's current status and future plans:
|
|
|
341
372
|
- Support for multiple vanilla-extract APIs (e.g., `style`, `styleVariants`, `recipe`, `globalStyle`, `fontFace`, etc.).
|
|
342
373
|
- `no-empty-style-blocks` rule to disallow empty blocks.
|
|
343
374
|
- Recommended ESLint configuration for the plugin.
|
|
375
|
+
- `no-zero-unit` rule to disallow units when the value is zero.
|
|
344
376
|
- Comprehensive rule testing.
|
|
345
377
|
|
|
346
378
|
### Current Work
|
|
347
379
|
|
|
348
|
-
- `no-
|
|
380
|
+
- `no-unknown-unit` rule to disallow unknown units.
|
|
349
381
|
|
|
350
382
|
### Upcoming Features
|
|
351
383
|
|
|
352
|
-
- `no-
|
|
353
|
-
- `no-number-trailing-zeros` rule to disallow trailing zeros in numbers.
|
|
384
|
+
- `no-number-trailing-zero` rule to disallow trailing zeros in numbers.
|
|
354
385
|
- `no-px-unit` rule to disallow use of `px` units with configurable whitelist.
|
|
355
386
|
- `prefer-logical-properties` rule to enforce use of logical properties.
|
|
356
387
|
- `prefer-theme-tokens` rule to enforce use of theme tokens instead of hard-coded values when available.
|
|
@@ -3,4 +3,4 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
3
3
|
/**
|
|
4
4
|
* Handles conditional expressions with empty objects.
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare const processConditionalExpression: (context: Rule.RuleContext, node: TSESTree.ConditionalExpression, reportedNodes: Set<TSESTree.Node>, callNode: TSESTree.CallExpression) => void;
|
|
@@ -4,7 +4,7 @@ import { reportEmptyDeclaration } from './fix-utils.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Handles conditional expressions with empty objects.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export const processConditionalExpression = (context, node, reportedNodes, callNode) => {
|
|
8
8
|
const isConsequentEmpty = node.consequent.type === 'ObjectExpression' && isEmptyObject(node.consequent);
|
|
9
9
|
const isAlternateEmpty = node.alternate.type === 'ObjectExpression' && isEmptyObject(node.alternate);
|
|
10
10
|
// If both branches are empty, report the entire declaration for removal
|
|
@@ -23,4 +23,4 @@ export function processConditionalExpression(context, node, reportedNodes, callN
|
|
|
23
23
|
messageId: 'emptyConditionalStyle',
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
};
|
|
@@ -3,4 +3,4 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
3
3
|
/**
|
|
4
4
|
* Processes nested style objects like selectors and media queries.
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare const processEmptyNestedStyles: (ruleContext: Rule.RuleContext, node: TSESTree.ObjectExpression, reportedNodes: Set<TSESTree.Node>) => void;
|
|
@@ -5,7 +5,7 @@ import { areAllChildrenEmpty, getStyleKeyName } from './property-utils.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Processes nested style objects like selectors and media queries.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export const processEmptyNestedStyles = (ruleContext, node, reportedNodes) => {
|
|
9
9
|
node.properties.forEach((property) => {
|
|
10
10
|
if (property.type !== 'Property') {
|
|
11
11
|
return;
|
|
@@ -62,4 +62,4 @@ export function processEmptyNestedStyles(ruleContext, node, reportedNodes) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
|
-
}
|
|
65
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { TSESTree } from '@typescript-eslint/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a style object is effectively empty (contains only empty objects).
|
|
5
|
+
*/
|
|
6
|
+
export declare const isEffectivelyEmptyStylesObject: (stylesObject: TSESTree.ObjectExpression) => boolean;
|
|
3
7
|
/**
|
|
4
8
|
* Creates ESLint rule visitors for detecting empty style blocks in vanilla-extract.
|
|
5
9
|
* @param ruleContext The ESLint rule rule context.
|
|
6
10
|
* @returns An object with visitor functions for the ESLint rule.
|
|
7
11
|
*/
|
|
8
12
|
export declare const createEmptyStyleVisitors: (ruleContext: Rule.RuleContext) => Rule.RuleListener;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if a style object is effectively empty (contains only empty objects).
|
|
11
|
-
*/
|
|
12
|
-
export declare function isEffectivelyEmptyStylesObject(stylesObject: TSESTree.ObjectExpression): boolean;
|
|
@@ -7,6 +7,85 @@ import { removeNodeWithComma } from './node-remover.js';
|
|
|
7
7
|
import { getStyleKeyName } from './property-utils.js';
|
|
8
8
|
import { processRecipeProperties } from './recipe-processor.js';
|
|
9
9
|
import { processStyleVariants } from './style-variants-processor.js';
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a style object is effectively empty (contains only empty objects).
|
|
12
|
+
*/
|
|
13
|
+
export const isEffectivelyEmptyStylesObject = (stylesObject) => {
|
|
14
|
+
// Empty object itself
|
|
15
|
+
if (stylesObject.properties.length === 0) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
// For recipe objects, we need special handling
|
|
19
|
+
let hasBaseProperty = false;
|
|
20
|
+
let isBaseEmpty = true;
|
|
21
|
+
let hasVariantsProperty = false;
|
|
22
|
+
let areAllVariantsEmpty = true;
|
|
23
|
+
// First pass: identify recipe properties
|
|
24
|
+
for (const property of stylesObject.properties) {
|
|
25
|
+
if (property.type !== 'Property') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const propertyName = getStyleKeyName(property.key);
|
|
29
|
+
if (!propertyName) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (propertyName === 'base') {
|
|
33
|
+
hasBaseProperty = true;
|
|
34
|
+
if (property.value.type === 'ObjectExpression' && !isEmptyObject(property.value)) {
|
|
35
|
+
isBaseEmpty = false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (propertyName === 'variants') {
|
|
39
|
+
hasVariantsProperty = true;
|
|
40
|
+
if (property.value.type === 'ObjectExpression' && !isEmptyObject(property.value)) {
|
|
41
|
+
areAllVariantsEmpty = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// If this looks like a recipe object (has base or variants)
|
|
46
|
+
if (hasBaseProperty || hasVariantsProperty) {
|
|
47
|
+
// A recipe is effectively empty if both base and variants are empty
|
|
48
|
+
return isBaseEmpty && areAllVariantsEmpty;
|
|
49
|
+
}
|
|
50
|
+
// / For non-recipe objects, check if all special properties (selectors, media queries, variants) are effectively empty
|
|
51
|
+
function isSpecialProperty(propertyName) {
|
|
52
|
+
return (propertyName === 'selectors' || (propertyName && propertyName.startsWith('@')) || propertyName === 'variants');
|
|
53
|
+
}
|
|
54
|
+
const specialProperties = stylesObject.properties.filter((prop) => prop.type === 'Property' && isSpecialProperty(getStyleKeyName(prop.key)));
|
|
55
|
+
const allSpecialPropertiesEmpty = specialProperties.every((property) => {
|
|
56
|
+
if (property.value.type === 'ObjectExpression' && isEmptyObject(property.value)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
const propertyName = getStyleKeyName(property.key);
|
|
60
|
+
// This defensive check handles malformed AST nodes that lack valid property names.
|
|
61
|
+
// This is difficult to test because it's challenging to construct a valid AST
|
|
62
|
+
// where getStyleKeyName would return a falsy value.
|
|
63
|
+
if (!propertyName) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// For selectors, media queries and supports, check if all nested objects are empty
|
|
67
|
+
if ((propertyName === 'selectors' || (propertyName && propertyName.startsWith('@'))) &&
|
|
68
|
+
property.value.type === 'ObjectExpression') {
|
|
69
|
+
// This handles the edge case of an empty properties array.
|
|
70
|
+
// This code path is difficult to test in isolation because it requires
|
|
71
|
+
// constructing a specific AST structure that bypasses earlier conditions.
|
|
72
|
+
if (property.value.properties.length === 0) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return property.value.properties.every((nestedProperty) => {
|
|
76
|
+
return (nestedProperty.type === 'Property' &&
|
|
77
|
+
nestedProperty.value.type === 'ObjectExpression' &&
|
|
78
|
+
isEmptyObject(nestedProperty.value));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// Default fallback for cases not handled by the conditions above.
|
|
82
|
+
// This is difficult to test because it requires creating an AST structure
|
|
83
|
+
// that doesn't trigger any of the preceding return statements.
|
|
84
|
+
return false;
|
|
85
|
+
});
|
|
86
|
+
// If we have special properties and they're all empty, the style is effectively empty
|
|
87
|
+
return specialProperties.length > 0 && allSpecialPropertiesEmpty;
|
|
88
|
+
};
|
|
10
89
|
/**
|
|
11
90
|
* Creates ESLint rule visitors for detecting empty style blocks in vanilla-extract.
|
|
12
91
|
* @param ruleContext The ESLint rule rule context.
|
|
@@ -102,82 +181,3 @@ export const createEmptyStyleVisitors = (ruleContext) => {
|
|
|
102
181
|
},
|
|
103
182
|
};
|
|
104
183
|
};
|
|
105
|
-
/**
|
|
106
|
-
* Checks if a style object is effectively empty (contains only empty objects).
|
|
107
|
-
*/
|
|
108
|
-
export function isEffectivelyEmptyStylesObject(stylesObject) {
|
|
109
|
-
// Empty object itself
|
|
110
|
-
if (stylesObject.properties.length === 0) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
// For recipe objects, we need special handling
|
|
114
|
-
let hasBaseProperty = false;
|
|
115
|
-
let isBaseEmpty = true;
|
|
116
|
-
let hasVariantsProperty = false;
|
|
117
|
-
let areAllVariantsEmpty = true;
|
|
118
|
-
// First pass: identify recipe properties
|
|
119
|
-
for (const property of stylesObject.properties) {
|
|
120
|
-
if (property.type !== 'Property') {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const propertyName = getStyleKeyName(property.key);
|
|
124
|
-
if (!propertyName) {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (propertyName === 'base') {
|
|
128
|
-
hasBaseProperty = true;
|
|
129
|
-
if (property.value.type === 'ObjectExpression' && !isEmptyObject(property.value)) {
|
|
130
|
-
isBaseEmpty = false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else if (propertyName === 'variants') {
|
|
134
|
-
hasVariantsProperty = true;
|
|
135
|
-
if (property.value.type === 'ObjectExpression' && !isEmptyObject(property.value)) {
|
|
136
|
-
areAllVariantsEmpty = false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// If this looks like a recipe object (has base or variants)
|
|
141
|
-
if (hasBaseProperty || hasVariantsProperty) {
|
|
142
|
-
// A recipe is effectively empty if both base and variants are empty
|
|
143
|
-
return isBaseEmpty && areAllVariantsEmpty;
|
|
144
|
-
}
|
|
145
|
-
// / For non-recipe objects, check if all special properties (selectors, media queries, variants) are effectively empty
|
|
146
|
-
function isSpecialProperty(propertyName) {
|
|
147
|
-
return (propertyName === 'selectors' || (propertyName && propertyName.startsWith('@')) || propertyName === 'variants');
|
|
148
|
-
}
|
|
149
|
-
const specialProperties = stylesObject.properties.filter((prop) => prop.type === 'Property' && isSpecialProperty(getStyleKeyName(prop.key)));
|
|
150
|
-
const allSpecialPropertiesEmpty = specialProperties.every((property) => {
|
|
151
|
-
if (property.value.type === 'ObjectExpression' && isEmptyObject(property.value)) {
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
const propertyName = getStyleKeyName(property.key);
|
|
155
|
-
// This defensive check handles malformed AST nodes that lack valid property names.
|
|
156
|
-
// This is difficult to test because it's challenging to construct a valid AST
|
|
157
|
-
// where getStyleKeyName would return a falsy value.
|
|
158
|
-
if (!propertyName) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
// For selectors, media queries and supports, check if all nested objects are empty
|
|
162
|
-
if ((propertyName === 'selectors' || (propertyName && propertyName.startsWith('@'))) &&
|
|
163
|
-
property.value.type === 'ObjectExpression') {
|
|
164
|
-
// This handles the edge case of an empty properties array.
|
|
165
|
-
// This code path is difficult to test in isolation because it requires
|
|
166
|
-
// constructing a specific AST structure that bypasses earlier conditions.
|
|
167
|
-
if (property.value.properties.length === 0) {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
return property.value.properties.every((nestedProperty) => {
|
|
171
|
-
return (nestedProperty.type === 'Property' &&
|
|
172
|
-
nestedProperty.value.type === 'ObjectExpression' &&
|
|
173
|
-
isEmptyObject(nestedProperty.value));
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
// Default fallback for cases not handled by the conditions above.
|
|
177
|
-
// This is difficult to test because it requires creating an AST structure
|
|
178
|
-
// that doesn't trigger any of the preceding return statements.
|
|
179
|
-
return false;
|
|
180
|
-
});
|
|
181
|
-
// If we have special properties and they're all empty, the style is effectively empty
|
|
182
|
-
return specialProperties.length > 0 && allSpecialPropertiesEmpty;
|
|
183
|
-
}
|
|
@@ -7,4 +7,4 @@ import type { TSESTree } from '@typescript-eslint/utils';
|
|
|
7
7
|
* @param fixer The ESLint fixer.
|
|
8
8
|
* @returns The fix object.
|
|
9
9
|
*/
|
|
10
|
-
export declare
|
|
10
|
+
export declare const removeNodeWithComma: (ruleContext: Rule.RuleContext, node: TSESTree.Node, fixer: Rule.RuleFixer) => Rule.Fix;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* @param fixer The ESLint fixer.
|
|
6
6
|
* @returns The fix object.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export const removeNodeWithComma = (ruleContext, node, fixer) => {
|
|
9
9
|
const sourceCode = ruleContext.sourceCode;
|
|
10
10
|
const tokenAfter = sourceCode.getTokenAfter(node);
|
|
11
11
|
if (tokenAfter && tokenAfter.value === ',' && node.range && tokenAfter.range) {
|
|
12
12
|
return fixer.removeRange([node.range[0], tokenAfter.range[1]]);
|
|
13
13
|
}
|
|
14
14
|
return fixer.remove(node);
|
|
15
|
-
}
|
|
15
|
+
};
|
|
@@ -2,7 +2,7 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
2
2
|
/**
|
|
3
3
|
* Gets the property name regardless of whether it's an identifier or a literal.
|
|
4
4
|
*/
|
|
5
|
-
export declare
|
|
5
|
+
export declare const getStyleKeyName: (key: TSESTree.Expression | TSESTree.PrivateIdentifier) => string | null;
|
|
6
6
|
/**
|
|
7
7
|
* Checks if all properties in a style object are empty objects.
|
|
8
8
|
*/
|
|
@@ -3,7 +3,7 @@ import { isEmptyObject } from '../shared-utils/empty-object-processor.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Gets the property name regardless of whether it's an identifier or a literal.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export const getStyleKeyName = (key) => {
|
|
7
7
|
if (key.type === 'Identifier') {
|
|
8
8
|
return key.name;
|
|
9
9
|
}
|
|
@@ -11,7 +11,7 @@ export function getStyleKeyName(key) {
|
|
|
11
11
|
return key.value;
|
|
12
12
|
}
|
|
13
13
|
return null;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
/**
|
|
16
16
|
* Checks if all properties in a style object are empty objects.
|
|
17
17
|
*/
|
|
@@ -8,4 +8,4 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
8
8
|
* @param recipeNode The recipe object node to process.
|
|
9
9
|
* @param reportedNodes A set of nodes that have already been reported by other processors.
|
|
10
10
|
*/
|
|
11
|
-
export declare
|
|
11
|
+
export declare const processRecipeProperties: (ruleContext: Rule.RuleContext, recipeNode: TSESTree.ObjectExpression, reportedNodes: Set<TSESTree.Node>) => void;
|
|
@@ -11,7 +11,7 @@ import { areAllChildrenEmpty, getStyleKeyName } from './property-utils.js';
|
|
|
11
11
|
* @param recipeNode The recipe object node to process.
|
|
12
12
|
* @param reportedNodes A set of nodes that have already been reported by other processors.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export const processRecipeProperties = (ruleContext, recipeNode, reportedNodes) => {
|
|
15
15
|
recipeNode.properties.forEach((property) => {
|
|
16
16
|
if (property.type !== 'Property') {
|
|
17
17
|
return;
|
|
@@ -119,4 +119,4 @@ export function processRecipeProperties(ruleContext, recipeNode, reportedNodes)
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
|
-
}
|
|
122
|
+
};
|
|
@@ -7,4 +7,4 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
7
7
|
* @param node The styleVariants call argument (object expression).
|
|
8
8
|
* @param reportedNodes A set of nodes that have already been reported.
|
|
9
9
|
*/
|
|
10
|
-
export declare
|
|
10
|
+
export declare const processStyleVariants: (ruleContext: Rule.RuleContext, node: TSESTree.ObjectExpression, reportedNodes: Set<TSESTree.Node>) => void;
|
|
@@ -8,7 +8,7 @@ import { removeNodeWithComma } from './node-remover.js';
|
|
|
8
8
|
* @param node The styleVariants call argument (object expression).
|
|
9
9
|
* @param reportedNodes A set of nodes that have already been reported.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export const processStyleVariants = (ruleContext, node, reportedNodes) => {
|
|
12
12
|
node.properties.forEach((property) => {
|
|
13
13
|
if (property.type !== 'Property') {
|
|
14
14
|
return;
|
|
@@ -42,4 +42,4 @@ export function processStyleVariants(ruleContext, node, reportedNodes) {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
}
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import { run } from 'eslint-vitest-rule-tester';
|
|
3
|
+
import noZeroUnitRule from '../rule-definition.js';
|
|
4
|
+
run({
|
|
5
|
+
name: 'vanilla-extract/no-zero-unit',
|
|
6
|
+
rule: noZeroUnitRule,
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: 2022,
|
|
11
|
+
sourceType: 'module',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
valid: [
|
|
15
|
+
{
|
|
16
|
+
code: `
|
|
17
|
+
import { style } from '@vanilla-extract/css';
|
|
18
|
+
const myStyle = style({
|
|
19
|
+
margin: '0',
|
|
20
|
+
padding: 0,
|
|
21
|
+
width: '100%',
|
|
22
|
+
});
|
|
23
|
+
`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
code: `
|
|
27
|
+
import { recipe } from '@vanilla-extract/css';
|
|
28
|
+
const myRecipe = recipe({
|
|
29
|
+
base: {
|
|
30
|
+
margin: '0',
|
|
31
|
+
padding: 0,
|
|
32
|
+
},
|
|
33
|
+
variants: {
|
|
34
|
+
size: {
|
|
35
|
+
small: {
|
|
36
|
+
height: '0',
|
|
37
|
+
width: '10px',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: `
|
|
46
|
+
import { style } from '@vanilla-extract/css';
|
|
47
|
+
const myStyle = style({
|
|
48
|
+
...spreadProps,
|
|
49
|
+
margin: 0,
|
|
50
|
+
'@media': {
|
|
51
|
+
'0rem': '0' // Key shouldn't be checked
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
`,
|
|
55
|
+
name: 'should ignore spread elements and object keys',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
code: `
|
|
59
|
+
import { style } from '@vanilla-extract/css';
|
|
60
|
+
const myStyle = style({
|
|
61
|
+
margin: \`0\${someUnit}\`, // Template literal
|
|
62
|
+
padding: someVariable
|
|
63
|
+
});
|
|
64
|
+
`,
|
|
65
|
+
name: 'should ignore non-literal values',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
code: `
|
|
69
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
70
|
+
const callExpression = someObject.fontFace({ src: '...' }); // Non-Identifier callee
|
|
71
|
+
`,
|
|
72
|
+
name: 'should ignore member expression callees',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
code: `
|
|
76
|
+
import { fontFace } from '@vanilla-extract/css';
|
|
77
|
+
fontFace(); // Missing arguments
|
|
78
|
+
`,
|
|
79
|
+
name: 'should handle missing fontFace arguments',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
code: `
|
|
83
|
+
import { globalFontFace } from '@vanilla-extract/css';
|
|
84
|
+
globalFontFace('my-font'); // Missing style argument
|
|
85
|
+
`,
|
|
86
|
+
name: 'should handle missing globalFontFace style argument',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
invalid: [
|
|
90
|
+
{
|
|
91
|
+
code: `
|
|
92
|
+
import { style } from '@vanilla-extract/css';
|
|
93
|
+
const myStyle = style({
|
|
94
|
+
margin: '0px',
|
|
95
|
+
padding: '0rem',
|
|
96
|
+
});
|
|
97
|
+
`,
|
|
98
|
+
errors: [{ messageId: 'noZeroUnit' }, { messageId: 'noZeroUnit' }],
|
|
99
|
+
output: `
|
|
100
|
+
import { style } from '@vanilla-extract/css';
|
|
101
|
+
const myStyle = style({
|
|
102
|
+
margin: '0',
|
|
103
|
+
padding: '0',
|
|
104
|
+
});
|
|
105
|
+
`,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
code: `
|
|
109
|
+
import { recipe } from '@vanilla-extract/css';
|
|
110
|
+
const myRecipe = recipe({
|
|
111
|
+
base: {
|
|
112
|
+
margin: '0px',
|
|
113
|
+
},
|
|
114
|
+
variants: {
|
|
115
|
+
size: {
|
|
116
|
+
small: {
|
|
117
|
+
height: '0vh',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
`,
|
|
123
|
+
errors: [{ messageId: 'noZeroUnit' }, { messageId: 'noZeroUnit' }],
|
|
124
|
+
output: `
|
|
125
|
+
import { recipe } from '@vanilla-extract/css';
|
|
126
|
+
const myRecipe = recipe({
|
|
127
|
+
base: {
|
|
128
|
+
margin: '0',
|
|
129
|
+
},
|
|
130
|
+
variants: {
|
|
131
|
+
size: {
|
|
132
|
+
small: {
|
|
133
|
+
height: '0',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
`,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
code: `
|
|
142
|
+
import { style } from '@vanilla-extract/css';
|
|
143
|
+
const myStyle = style({
|
|
144
|
+
margin: '0px',
|
|
145
|
+
'@media': {
|
|
146
|
+
'(min-width: 768px)': {
|
|
147
|
+
padding: '0rem'
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
`,
|
|
152
|
+
errors: 2,
|
|
153
|
+
output: `
|
|
154
|
+
import { style } from '@vanilla-extract/css';
|
|
155
|
+
const myStyle = style({
|
|
156
|
+
margin: '0',
|
|
157
|
+
'@media': {
|
|
158
|
+
'(min-width: 768px)': {
|
|
159
|
+
padding: '0'
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
`,
|
|
164
|
+
name: 'should handle nested media queries',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
code: `
|
|
168
|
+
import { style } from '@vanilla-extract/css';
|
|
169
|
+
const myStyle = style({
|
|
170
|
+
'::before': {
|
|
171
|
+
content: '""',
|
|
172
|
+
margin: '0px'
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
`,
|
|
176
|
+
errors: 1,
|
|
177
|
+
output: `
|
|
178
|
+
import { style } from '@vanilla-extract/css';
|
|
179
|
+
const myStyle = style({
|
|
180
|
+
'::before': {
|
|
181
|
+
content: '""',
|
|
182
|
+
margin: '0'
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
`,
|
|
186
|
+
name: 'should handle pseudo-elements',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
code: `
|
|
190
|
+
import { style } from '@vanilla-extract/css';
|
|
191
|
+
const myStyle = style({
|
|
192
|
+
margin: '0px',
|
|
193
|
+
nested: {
|
|
194
|
+
object: {
|
|
195
|
+
padding: '0rem',
|
|
196
|
+
deeper: {
|
|
197
|
+
width: '0%'
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
`,
|
|
203
|
+
errors: 3,
|
|
204
|
+
output: `
|
|
205
|
+
import { style } from '@vanilla-extract/css';
|
|
206
|
+
const myStyle = style({
|
|
207
|
+
margin: '0',
|
|
208
|
+
nested: {
|
|
209
|
+
object: {
|
|
210
|
+
padding: '0',
|
|
211
|
+
deeper: {
|
|
212
|
+
width: '0'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
`,
|
|
218
|
+
name: 'should handle multiple levels of nesting',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
code: `
|
|
222
|
+
import { fontFace, globalFontFace } from '@vanilla-extract/css';
|
|
223
|
+
|
|
224
|
+
fontFace({
|
|
225
|
+
src: '...',
|
|
226
|
+
lineGap: '0rem'
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
globalFontFace('my-font', {
|
|
230
|
+
src: '...',
|
|
231
|
+
sizeAdjust: '0%'
|
|
232
|
+
});
|
|
233
|
+
`,
|
|
234
|
+
errors: 2,
|
|
235
|
+
output: `
|
|
236
|
+
import { fontFace, globalFontFace } from '@vanilla-extract/css';
|
|
237
|
+
|
|
238
|
+
fontFace({
|
|
239
|
+
src: '...',
|
|
240
|
+
lineGap: '0'
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
globalFontFace('my-font', {
|
|
244
|
+
src: '...',
|
|
245
|
+
sizeAdjust: '0'
|
|
246
|
+
});
|
|
247
|
+
`,
|
|
248
|
+
name: 'should handle fontFace and globalFontFace arguments',
|
|
249
|
+
},
|
|
250
|
+
// 0deg is valid (deg isn't in our unit check)
|
|
251
|
+
{
|
|
252
|
+
code: `
|
|
253
|
+
import { globalKeyframes, globalStyle } from '@vanilla-extract/css';
|
|
254
|
+
|
|
255
|
+
globalKeyframes('spin', {
|
|
256
|
+
'0%': { transform: 'rotate(0deg)' },
|
|
257
|
+
'100%': { transform: 'rotate(0deg)' }
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
globalStyle('html', {
|
|
261
|
+
margin: '0px',
|
|
262
|
+
padding: '0rem'
|
|
263
|
+
});
|
|
264
|
+
`,
|
|
265
|
+
errors: 2,
|
|
266
|
+
output: `
|
|
267
|
+
import { globalKeyframes, globalStyle } from '@vanilla-extract/css';
|
|
268
|
+
|
|
269
|
+
globalKeyframes('spin', {
|
|
270
|
+
'0%': { transform: 'rotate(0deg)' },
|
|
271
|
+
'100%': { transform: 'rotate(0deg)' }
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
globalStyle('html', {
|
|
275
|
+
margin: '0',
|
|
276
|
+
padding: '0'
|
|
277
|
+
});
|
|
278
|
+
`,
|
|
279
|
+
name: 'should handle globalKeyframes and globalStyle arguments',
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
code: `
|
|
283
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
284
|
+
globalStyle('html', {
|
|
285
|
+
'@media': {
|
|
286
|
+
'(min-width: 768px)': {
|
|
287
|
+
margin: '0px'
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
`,
|
|
292
|
+
errors: 1,
|
|
293
|
+
output: `
|
|
294
|
+
import { globalStyle } from '@vanilla-extract/css';
|
|
295
|
+
globalStyle('html', {
|
|
296
|
+
'@media': {
|
|
297
|
+
'(min-width: 768px)': {
|
|
298
|
+
margin: '0'
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
`,
|
|
303
|
+
name: 'should handle nested globalStyle arguments',
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
code: `
|
|
307
|
+
import { style } from '@vanilla-extract/css';
|
|
308
|
+
const myStyle = style({
|
|
309
|
+
margin: '-0px',
|
|
310
|
+
padding: '-0rem',
|
|
311
|
+
top: '-0vh',
|
|
312
|
+
left: '-0%',
|
|
313
|
+
});
|
|
314
|
+
`,
|
|
315
|
+
errors: [
|
|
316
|
+
{ messageId: 'noZeroUnit' },
|
|
317
|
+
{ messageId: 'noZeroUnit' },
|
|
318
|
+
{ messageId: 'noZeroUnit' },
|
|
319
|
+
{ messageId: 'noZeroUnit' },
|
|
320
|
+
],
|
|
321
|
+
output: `
|
|
322
|
+
import { style } from '@vanilla-extract/css';
|
|
323
|
+
const myStyle = style({
|
|
324
|
+
margin: '0',
|
|
325
|
+
padding: '0',
|
|
326
|
+
top: '0',
|
|
327
|
+
left: '0',
|
|
328
|
+
});
|
|
329
|
+
`,
|
|
330
|
+
name: 'should convert negative zero with units to simple zero',
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createZeroUnitVisitors } from './zero-unit-visitor-creator.js';
|
|
2
|
+
const noZeroUnitRule = {
|
|
3
|
+
meta: {
|
|
4
|
+
type: 'suggestion',
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'enforce unitless zero in numeric values',
|
|
7
|
+
category: 'Stylistic Issues',
|
|
8
|
+
recommended: true,
|
|
9
|
+
},
|
|
10
|
+
fixable: 'code',
|
|
11
|
+
schema: [],
|
|
12
|
+
messages: {
|
|
13
|
+
noZeroUnit: 'Unit with zero value is unnecessary. Use 0 instead.',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
create(context) {
|
|
17
|
+
return createZeroUnitVisitors(context);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export default noZeroUnitRule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively processes a style object, reporting and fixing instances of zero values with units.
|
|
5
|
+
*
|
|
6
|
+
* @param ruleContext The ESLint rule context.
|
|
7
|
+
* @param node The ObjectExpression node representing the style object to be processed.
|
|
8
|
+
*/
|
|
9
|
+
export declare const processZeroUnitInStyleObject: (ruleContext: Rule.RuleContext, node: TSESTree.ObjectExpression) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
const ZERO_VALUE_WITH_UNIT_REGEX = /^-?0(px|em|rem|%|vh|vw|vmin|vmax|ex|ch|cm|mm|in|pt|pc|Q|fr)$/;
|
|
3
|
+
/**
|
|
4
|
+
* Recursively processes a style object, reporting and fixing instances of zero values with units.
|
|
5
|
+
*
|
|
6
|
+
* @param ruleContext The ESLint rule context.
|
|
7
|
+
* @param node The ObjectExpression node representing the style object to be processed.
|
|
8
|
+
*/
|
|
9
|
+
export const processZeroUnitInStyleObject = (ruleContext, node) => {
|
|
10
|
+
node.properties.forEach((property) => {
|
|
11
|
+
if (property.type !== 'Property') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// Process direct string literal values
|
|
15
|
+
if (property.value.type === 'Literal' &&
|
|
16
|
+
typeof property.value.value === 'string' &&
|
|
17
|
+
ZERO_VALUE_WITH_UNIT_REGEX.test(property.value.value)) {
|
|
18
|
+
ruleContext.report({
|
|
19
|
+
node: property.value,
|
|
20
|
+
messageId: 'noZeroUnit',
|
|
21
|
+
fix: (fixer) => fixer.replaceText(property.value, "'0'"),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// Process nested objects (selectors, media queries, etc.)
|
|
25
|
+
if (property.value.type === 'ObjectExpression') {
|
|
26
|
+
processZeroUnitInStyleObject(ruleContext, property.value);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* Creates ESLint rule visitors for detecting and processing zero values with units in style-related function calls.
|
|
4
|
+
*
|
|
5
|
+
* @param context The ESLint rule context.
|
|
6
|
+
* @returns An object with visitor functions for the ESLint rule.
|
|
7
|
+
*
|
|
8
|
+
* This function sets up visitors for the following cases:
|
|
9
|
+
* 1. The `fontFace` and `globalFontFace` functions, processing their object arguments.
|
|
10
|
+
* 2. Style-related functions: `keyframes`, `style`, `styleVariants`, processing their style objects.
|
|
11
|
+
* 3. The `globalKeyframes` and `globalStyle` functions, processing the second argument as style objects.
|
|
12
|
+
* 4. The `recipe` function, processing the first argument as the recipe object.
|
|
13
|
+
*/
|
|
14
|
+
export declare const createZeroUnitVisitors: (context: Rule.RuleContext) => Rule.RuleListener;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import { processRecipeProperties } from '../shared-utils/recipe-property-processor.js';
|
|
3
|
+
import { processStyleNode } from '../shared-utils/style-node-processor.js';
|
|
4
|
+
import { processZeroUnitInStyleObject } from './zero-unit-processor.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates ESLint rule visitors for detecting and processing zero values with units in style-related function calls.
|
|
7
|
+
*
|
|
8
|
+
* @param context The ESLint rule context.
|
|
9
|
+
* @returns An object with visitor functions for the ESLint rule.
|
|
10
|
+
*
|
|
11
|
+
* This function sets up visitors for the following cases:
|
|
12
|
+
* 1. The `fontFace` and `globalFontFace` functions, processing their object arguments.
|
|
13
|
+
* 2. Style-related functions: `keyframes`, `style`, `styleVariants`, processing their style objects.
|
|
14
|
+
* 3. The `globalKeyframes` and `globalStyle` functions, processing the second argument as style objects.
|
|
15
|
+
* 4. The `recipe` function, processing the first argument as the recipe object.
|
|
16
|
+
*/
|
|
17
|
+
export const createZeroUnitVisitors = (context) => {
|
|
18
|
+
return {
|
|
19
|
+
CallExpression(node) {
|
|
20
|
+
if (node.callee.type !== AST_NODE_TYPES.Identifier) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (['fontFace', 'globalFontFace'].includes(node.callee.name)) {
|
|
24
|
+
const argumentIndex = node.callee.name === 'fontFace' ? 0 : 1;
|
|
25
|
+
if (node.arguments.length > argumentIndex &&
|
|
26
|
+
node.arguments[argumentIndex]?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
27
|
+
processZeroUnitInStyleObject(context, node.arguments[argumentIndex]);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (['keyframes', 'style', 'styleVariants'].includes(node.callee.name)) {
|
|
32
|
+
if (node.arguments.length > 0) {
|
|
33
|
+
processStyleNode(context, node.arguments[0], processZeroUnitInStyleObject);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (['globalKeyframes', 'globalStyle'].includes(node.callee.name) && node.arguments.length >= 2) {
|
|
37
|
+
processStyleNode(context, node.arguments[1], processZeroUnitInStyleObject);
|
|
38
|
+
}
|
|
39
|
+
if (node.callee.name === 'recipe' &&
|
|
40
|
+
node.arguments.length > 0 &&
|
|
41
|
+
node.arguments[0]?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
42
|
+
processRecipeProperties(context, node.arguments[0], processZeroUnitInStyleObject);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const vanillaExtract: {
|
|
|
8
8
|
'concentric-order': import("eslint").Rule.RuleModule;
|
|
9
9
|
'custom-order': import("eslint").Rule.RuleModule;
|
|
10
10
|
'no-empty-style-blocks': import("eslint").Rule.RuleModule;
|
|
11
|
+
'no-zero-unit': import("eslint").Rule.RuleModule;
|
|
11
12
|
};
|
|
12
13
|
configs: {
|
|
13
14
|
recommended: {
|
|
@@ -15,6 +16,7 @@ export declare const vanillaExtract: {
|
|
|
15
16
|
rules: {
|
|
16
17
|
'vanilla-extract/concentric-order': string;
|
|
17
18
|
'vanilla-extract/no-empty-style-blocks': string;
|
|
19
|
+
'vanilla-extract/no-zero-unit': string;
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
22
|
};
|
package/dist/index.js
CHANGED
|
@@ -2,16 +2,18 @@ import alphabeticalOrderRule from './css-rules/alphabetical-order/index.js';
|
|
|
2
2
|
import concentricOrderRule from './css-rules/concentric-order/index.js';
|
|
3
3
|
import customOrderRule from './css-rules/custom-order/rule-definition.js';
|
|
4
4
|
import noEmptyStyleBlocksRule from './css-rules/no-empty-blocks/rule-definition.js';
|
|
5
|
+
import noZeroUnitRule from './css-rules/no-zero-unit/rule-definition.js';
|
|
5
6
|
export const vanillaExtract = {
|
|
6
7
|
meta: {
|
|
7
8
|
name: '@antebudimir/eslint-plugin-vanilla-extract',
|
|
8
|
-
version: '1.
|
|
9
|
+
version: '1.8.0',
|
|
9
10
|
},
|
|
10
11
|
rules: {
|
|
11
12
|
'alphabetical-order': alphabeticalOrderRule,
|
|
12
13
|
'concentric-order': concentricOrderRule,
|
|
13
14
|
'custom-order': customOrderRule,
|
|
14
15
|
'no-empty-style-blocks': noEmptyStyleBlocksRule,
|
|
16
|
+
'no-zero-unit': noZeroUnitRule,
|
|
15
17
|
},
|
|
16
18
|
configs: {
|
|
17
19
|
recommended: {
|
|
@@ -19,6 +21,7 @@ export const vanillaExtract = {
|
|
|
19
21
|
rules: {
|
|
20
22
|
'vanilla-extract/concentric-order': 'error',
|
|
21
23
|
'vanilla-extract/no-empty-style-blocks': 'error',
|
|
24
|
+
'vanilla-extract/no-zero-unit': 'error',
|
|
22
25
|
},
|
|
23
26
|
},
|
|
24
27
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antebudimir/eslint-plugin-vanilla-extract",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "ESLint plugin for enforcing best practices in vanilla-extract CSS styles, including CSS property ordering and additional linting rules.",
|
|
5
5
|
"author": "Ante Budimir",
|
|
6
6
|
"license": "MIT",
|