@antebudimir/eslint-plugin-vanilla-extract 1.4.7 → 1.6.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 +52 -6
- package/dist/css-rules/alphabetical-order/property-order-enforcer.js +3 -3
- package/dist/css-rules/alphabetical-order/recipe-order-enforcer.js +3 -4
- package/dist/css-rules/alphabetical-order/style-object-processor.js +7 -8
- package/dist/css-rules/concentric-order/property-order-enforcer.js +10 -11
- package/dist/css-rules/concentric-order/recipe-order-enforcer.js +3 -4
- package/dist/css-rules/concentric-order/style-object-processor.js +15 -16
- package/dist/css-rules/concentric-order/types.d.ts +1 -0
- package/dist/css-rules/custom-order/property-order-enforcer.d.ts +2 -2
- package/dist/css-rules/custom-order/property-order-enforcer.js +50 -46
- package/dist/css-rules/custom-order/recipe-order-enforcer.d.ts +2 -1
- package/dist/css-rules/custom-order/recipe-order-enforcer.js +4 -5
- package/dist/css-rules/custom-order/rule-definition.js +3 -1
- package/dist/css-rules/custom-order/style-object-processor.d.ts +3 -2
- package/dist/css-rules/custom-order/style-object-processor.js +28 -29
- package/dist/css-rules/no-empty-blocks/conditional-processor.d.ts +6 -0
- package/dist/css-rules/no-empty-blocks/conditional-processor.js +26 -0
- package/dist/css-rules/no-empty-blocks/empty-nested-style-processor.d.ts +6 -0
- package/dist/css-rules/no-empty-blocks/empty-nested-style-processor.js +65 -0
- package/dist/css-rules/no-empty-blocks/empty-style-visitor-creator.d.ts +12 -0
- package/dist/css-rules/no-empty-blocks/empty-style-visitor-creator.js +183 -0
- package/dist/css-rules/no-empty-blocks/fix-utils.d.ts +22 -0
- package/dist/css-rules/no-empty-blocks/fix-utils.js +75 -0
- package/dist/css-rules/no-empty-blocks/index.d.ts +2 -0
- package/dist/css-rules/no-empty-blocks/index.js +2 -0
- package/dist/css-rules/no-empty-blocks/node-remover.d.ts +10 -0
- package/dist/css-rules/no-empty-blocks/node-remover.js +15 -0
- package/dist/css-rules/no-empty-blocks/property-utils.d.ts +9 -0
- package/dist/css-rules/no-empty-blocks/property-utils.js +28 -0
- package/dist/css-rules/no-empty-blocks/recipe-processor.d.ts +11 -0
- package/dist/css-rules/no-empty-blocks/recipe-processor.js +122 -0
- package/dist/css-rules/no-empty-blocks/rule-definition.d.ts +3 -0
- package/dist/css-rules/no-empty-blocks/rule-definition.js +30 -0
- package/dist/css-rules/no-empty-blocks/style-variants-processor.d.ts +10 -0
- package/dist/css-rules/no-empty-blocks/style-variants-processor.js +45 -0
- package/dist/css-rules/shared-utils/alphabetical-property-comparator.js +3 -3
- package/dist/css-rules/shared-utils/empty-object-processor.d.ts +11 -0
- package/dist/css-rules/shared-utils/empty-object-processor.js +15 -0
- package/dist/css-rules/shared-utils/font-face-property-order-enforcer.js +3 -3
- package/dist/css-rules/shared-utils/order-strategy-visitor-creator.d.ts +3 -1
- package/dist/css-rules/shared-utils/order-strategy-visitor-creator.js +1 -1
- package/dist/css-rules/shared-utils/property-separator.d.ts +1 -1
- package/dist/css-rules/shared-utils/property-separator.js +2 -2
- package/dist/css-rules/types.d.ts +1 -0
- package/dist/css-rules/types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -3
- package/package.json +13 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
import { generateFixesForCSSOrder } from '../shared-utils/css-order-fixer.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getPropertyNameForSorting, separateProperties } from '../shared-utils/property-separator.js';
|
|
4
4
|
import { comparePropertiesAlphabetically } from './alphabetical-property-comparator.js';
|
|
5
5
|
/**
|
|
6
6
|
* Processes a font face declaration to enforce property ordering:
|
|
@@ -24,8 +24,8 @@ export const enforceFontFaceOrder = (ruleContext, fontFaceObject) => {
|
|
|
24
24
|
}));
|
|
25
25
|
const violatingPair = propertyPairs.find(({ currentProperty, nextProperty }) => comparePropertiesAlphabetically(currentProperty, nextProperty) > 0);
|
|
26
26
|
if (violatingPair) {
|
|
27
|
-
const nextPropertyName =
|
|
28
|
-
const currentPropertyName =
|
|
27
|
+
const nextPropertyName = getPropertyNameForSorting(violatingPair.nextProperty);
|
|
28
|
+
const currentPropertyName = getPropertyNameForSorting(violatingPair.currentProperty);
|
|
29
29
|
ruleContext.report({
|
|
30
30
|
node: violatingPair.nextProperty,
|
|
31
31
|
messageId: 'fontFaceOrder',
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
+
import type { SortRemainingProperties } from '../concentric-order/types.js';
|
|
3
|
+
import type { OrderingStrategy } from '../types.js';
|
|
2
4
|
/**
|
|
3
5
|
* Creates an ESLint rule listener with visitors for style-related function calls.
|
|
4
6
|
* @param ruleContext The ESLint rule context.
|
|
@@ -15,4 +17,4 @@ import type { Rule } from 'eslint';
|
|
|
15
17
|
*
|
|
16
18
|
* Each visitor applies the appropriate ordering strategy to the style objects in these function calls.
|
|
17
19
|
*/
|
|
18
|
-
export declare const createNodeVisitors: (ruleContext: Rule.RuleContext, orderingStrategy:
|
|
20
|
+
export declare const createNodeVisitors: (ruleContext: Rule.RuleContext, orderingStrategy: OrderingStrategy, userDefinedGroupOrder?: string[], sortRemainingProperties?: SortRemainingProperties) => Rule.RuleListener;
|
|
@@ -33,7 +33,7 @@ export const createNodeVisitors = (ruleContext, orderingStrategy, userDefinedGro
|
|
|
33
33
|
return enforceConcentricCSSOrderInStyleObject;
|
|
34
34
|
case 'userDefinedGroupOrder':
|
|
35
35
|
if (!userDefinedGroupOrder || userDefinedGroupOrder.length === 0) {
|
|
36
|
-
|
|
36
|
+
return enforceAlphabeticalCSSOrderInStyleObject;
|
|
37
37
|
}
|
|
38
38
|
return (ruleContext, node) => enforceUserDefinedGroupOrderInStyleObject(ruleContext, node, userDefinedGroupOrder, sortRemainingProperties);
|
|
39
39
|
default:
|
|
@@ -9,7 +9,7 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
9
9
|
* - Literal (string): Returns the string value.
|
|
10
10
|
* For any other type of key, it returns an empty string.
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const getPropertyNameForSorting: (property: TSESTree.Property) => string;
|
|
13
13
|
/**
|
|
14
14
|
* Separates object properties into regular and special categories.
|
|
15
15
|
* @param properties An array of object literal elements to be categorized.
|
|
@@ -9,7 +9,7 @@ import { TSESTree } from '@typescript-eslint/utils';
|
|
|
9
9
|
* - Literal (string): Returns the string value.
|
|
10
10
|
* For any other type of key, it returns an empty string.
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
12
|
+
export const getPropertyNameForSorting = (property) => {
|
|
13
13
|
if (property.key.type === 'Identifier') {
|
|
14
14
|
return property.key.name;
|
|
15
15
|
}
|
|
@@ -36,7 +36,7 @@ export const separateProperties = (properties) => {
|
|
|
36
36
|
// Separate regular CSS properties from special ones (pseudo selectors, etc.)
|
|
37
37
|
properties.forEach((property) => {
|
|
38
38
|
if (property.type === 'Property') {
|
|
39
|
-
const propName =
|
|
39
|
+
const propName = getPropertyNameForSorting(property);
|
|
40
40
|
if (propName.startsWith(':') || propName.startsWith('@') || propName === 'selectors') {
|
|
41
41
|
specialProperties.push(property);
|
|
42
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type OrderingStrategy = 'alphabetical' | 'concentric' | 'userDefinedGroupOrder';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const vanillaExtract: {
|
|
|
7
7
|
'alphabetical-order': import("eslint").Rule.RuleModule;
|
|
8
8
|
'concentric-order': import("eslint").Rule.RuleModule;
|
|
9
9
|
'custom-order': import("eslint").Rule.RuleModule;
|
|
10
|
+
'no-empty-style-blocks': import("eslint").Rule.RuleModule;
|
|
10
11
|
};
|
|
11
12
|
configs: {
|
|
12
13
|
recommended: {
|
|
@@ -14,11 +15,13 @@ export declare const vanillaExtract: {
|
|
|
14
15
|
'vanilla-extract': {
|
|
15
16
|
rules: {
|
|
16
17
|
'concentric-order': import("eslint").Rule.RuleModule;
|
|
18
|
+
'no-empty-style-blocks': import("eslint").Rule.RuleModule;
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
22
|
rules: {
|
|
21
23
|
'vanilla-extract/concentric-order': string;
|
|
24
|
+
'vanilla-extract/no-empty-style-blocks': string;
|
|
22
25
|
};
|
|
23
26
|
}[];
|
|
24
27
|
alphabetical: {
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
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
|
+
import noEmptyStyleBlocksRule from './css-rules/no-empty-blocks/rule-definition.js';
|
|
4
5
|
export const vanillaExtract = {
|
|
5
6
|
meta: {
|
|
6
7
|
name: '@antebudimir/eslint-plugin-vanilla-extract',
|
|
7
|
-
version: '1.
|
|
8
|
+
version: '1.6.0',
|
|
8
9
|
},
|
|
9
10
|
rules: {
|
|
10
11
|
'alphabetical-order': alphabeticalOrderRule,
|
|
11
12
|
'concentric-order': concentricOrderRule,
|
|
12
13
|
'custom-order': customOrderRule,
|
|
14
|
+
'no-empty-style-blocks': noEmptyStyleBlocksRule,
|
|
13
15
|
},
|
|
14
16
|
configs: {
|
|
15
17
|
recommended: [
|
|
16
18
|
{
|
|
17
19
|
plugins: {
|
|
18
20
|
'vanilla-extract': {
|
|
19
|
-
rules: {
|
|
21
|
+
rules: {
|
|
22
|
+
'concentric-order': concentricOrderRule,
|
|
23
|
+
'no-empty-style-blocks': noEmptyStyleBlocksRule,
|
|
24
|
+
},
|
|
20
25
|
},
|
|
21
26
|
},
|
|
22
|
-
rules: {
|
|
27
|
+
rules: {
|
|
28
|
+
'vanilla-extract/concentric-order': 'warn',
|
|
29
|
+
'vanilla-extract/no-empty-style-blocks': 'warn',
|
|
30
|
+
},
|
|
23
31
|
},
|
|
24
32
|
],
|
|
25
33
|
alphabetical: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antebudimir/eslint-plugin-vanilla-extract",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|
|
@@ -49,24 +49,24 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@eslint/eslintrc": "^3.3.0",
|
|
52
|
-
"@types/node": "^20.17.
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
54
|
-
"@typescript-eslint/parser": "^8.
|
|
55
|
-
"@typescript-eslint/rule-tester": "^8.26.
|
|
56
|
-
"@typescript-eslint/utils": "^8.
|
|
52
|
+
"@types/node": "^20.17.24",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
54
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
55
|
+
"@typescript-eslint/rule-tester": "^8.26.1",
|
|
56
|
+
"@typescript-eslint/utils": "^8.26.1",
|
|
57
57
|
"@vanilla-extract/css": "^1.17.1",
|
|
58
58
|
"@vanilla-extract/recipes": "^0.5.5",
|
|
59
59
|
"@vitest/coverage-v8": "3.0.8",
|
|
60
|
-
"eslint": "^9.
|
|
61
|
-
"eslint-config-prettier": "^10.
|
|
62
|
-
"eslint-import-resolver-typescript": "^3.8.
|
|
60
|
+
"eslint": "^9.22.0",
|
|
61
|
+
"eslint-config-prettier": "^10.1.1",
|
|
62
|
+
"eslint-import-resolver-typescript": "^3.8.5",
|
|
63
63
|
"eslint-plugin-eslint-plugin": "^6.4.0",
|
|
64
64
|
"eslint-plugin-import": "^2.31.0",
|
|
65
65
|
"eslint-vitest-rule-tester": "^1.1.0",
|
|
66
|
-
"prettier": "^3.5.
|
|
67
|
-
"typescript": "^5.
|
|
68
|
-
"typescript-eslint": "^8.
|
|
69
|
-
"vitest": "
|
|
66
|
+
"prettier": "^3.5.3",
|
|
67
|
+
"typescript": "^5.8.2",
|
|
68
|
+
"typescript-eslint": "^8.26.1",
|
|
69
|
+
"vitest": "3.0.8"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsc",
|