@antebudimir/eslint-plugin-vanilla-extract 1.4.6 → 1.5.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.
Files changed (63) hide show
  1. package/README.md +12 -3
  2. package/dist/css-rules/alphabetical-order/recipe-order-enforcer.js +3 -4
  3. package/dist/css-rules/alphabetical-order/style-object-processor.js +7 -8
  4. package/dist/css-rules/concentric-order/property-order-enforcer.js +10 -11
  5. package/dist/css-rules/concentric-order/recipe-order-enforcer.js +3 -4
  6. package/dist/css-rules/concentric-order/style-object-processor.js +13 -14
  7. package/dist/css-rules/custom-order/property-order-enforcer.js +51 -46
  8. package/dist/css-rules/custom-order/recipe-order-enforcer.js +3 -4
  9. package/dist/css-rules/custom-order/rule-definition.js +3 -1
  10. package/dist/css-rules/custom-order/style-object-processor.js +25 -26
  11. package/dist/css-rules/shared-utils/order-strategy-visitor-creator.js +1 -1
  12. package/dist/index.js +1 -1
  13. package/package.json +2 -1
  14. package/dist/css-rules/alphabetical-order/__tests__/animation.test.d.ts +0 -1
  15. package/dist/css-rules/alphabetical-order/__tests__/animation.test.js +0 -108
  16. package/dist/css-rules/alphabetical-order/__tests__/font-face.test.d.ts +0 -1
  17. package/dist/css-rules/alphabetical-order/__tests__/font-face.test.js +0 -138
  18. package/dist/css-rules/alphabetical-order/__tests__/global.test.d.ts +0 -1
  19. package/dist/css-rules/alphabetical-order/__tests__/global.test.js +0 -51
  20. package/dist/css-rules/alphabetical-order/__tests__/recipe.test.d.ts +0 -1
  21. package/dist/css-rules/alphabetical-order/__tests__/recipe.test.js +0 -91
  22. package/dist/css-rules/alphabetical-order/__tests__/style.test.d.ts +0 -1
  23. package/dist/css-rules/alphabetical-order/__tests__/style.test.js +0 -108
  24. package/dist/css-rules/alphabetical-order/__tests__/variants.test.d.ts +0 -1
  25. package/dist/css-rules/alphabetical-order/__tests__/variants.test.js +0 -63
  26. package/dist/css-rules/concentric-order/__tests__/animation.test.d.ts +0 -1
  27. package/dist/css-rules/concentric-order/__tests__/animation.test.js +0 -69
  28. package/dist/css-rules/concentric-order/__tests__/font-face.test.d.ts +0 -1
  29. package/dist/css-rules/concentric-order/__tests__/font-face.test.js +0 -94
  30. package/dist/css-rules/concentric-order/__tests__/global.test.d.ts +0 -1
  31. package/dist/css-rules/concentric-order/__tests__/global.test.js +0 -57
  32. package/dist/css-rules/concentric-order/__tests__/recipe.test.d.ts +0 -1
  33. package/dist/css-rules/concentric-order/__tests__/recipe.test.js +0 -100
  34. package/dist/css-rules/concentric-order/__tests__/style.test.d.ts +0 -1
  35. package/dist/css-rules/concentric-order/__tests__/style.test.js +0 -126
  36. package/dist/css-rules/concentric-order/__tests__/variants.test.d.ts +0 -1
  37. package/dist/css-rules/concentric-order/__tests__/variants.test.js +0 -133
  38. package/dist/css-rules/custom-order/__tests__/animation.test.d.ts +0 -1
  39. package/dist/css-rules/custom-order/__tests__/animation.test.js +0 -148
  40. package/dist/css-rules/custom-order/__tests__/font-face.test.d.ts +0 -1
  41. package/dist/css-rules/custom-order/__tests__/font-face.test.js +0 -124
  42. package/dist/css-rules/custom-order/__tests__/global.test.d.ts +0 -1
  43. package/dist/css-rules/custom-order/__tests__/global.test.js +0 -124
  44. package/dist/css-rules/custom-order/__tests__/recipe.test.d.ts +0 -1
  45. package/dist/css-rules/custom-order/__tests__/recipe.test.js +0 -208
  46. package/dist/css-rules/custom-order/__tests__/style.test.d.ts +0 -1
  47. package/dist/css-rules/custom-order/__tests__/style.test.js +0 -249
  48. package/dist/css-rules/custom-order/__tests__/variants.test.d.ts +0 -1
  49. package/dist/css-rules/custom-order/__tests__/variants.test.js +0 -184
  50. package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.d.ts +0 -1
  51. package/dist/css-rules/shared-utils/__tests__/css-property-priority-map.test.js +0 -37
  52. package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.d.ts +0 -1
  53. package/dist/css-rules/shared-utils/__tests__/font-face-property-order-enforcer.test.js +0 -58
  54. package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.d.ts +0 -1
  55. package/dist/css-rules/shared-utils/__tests__/order-strategy-visitor-creator.test.js +0 -125
  56. package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.d.ts +0 -1
  57. package/dist/css-rules/shared-utils/__tests__/property-name-extractor.test.js +0 -53
  58. package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.d.ts +0 -1
  59. package/dist/css-rules/shared-utils/__tests__/recipe-property-processor.test.js +0 -116
  60. package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.d.ts +0 -1
  61. package/dist/css-rules/shared-utils/__tests__/style-node-processor.test.js +0 -55
  62. package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.d.ts +0 -3
  63. package/dist/css-rules/shared-utils/__tests__/test-property-name-rule.js +0 -30
@@ -1,58 +0,0 @@
1
- import tsParser from '@typescript-eslint/parser';
2
- import { run } from 'eslint-vitest-rule-tester';
3
- import alphabeticalOrderRule from '../../alphabetical-order/rule-definition.js';
4
- import { enforceFontFaceOrder } from '../font-face-property-order-enforcer.js';
5
- // A modified version of the rule that tests the edge cases
6
- const fontFaceEdgeCasesRule = {
7
- ...alphabeticalOrderRule,
8
- create(context) {
9
- return {
10
- // Test case for null/undefined fontFaceObject
11
- CallExpression(node) {
12
- if (node.callee.type === 'Identifier' && node.callee.name === 'testNullCase') {
13
- // This will trigger the first early return
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- enforceFontFaceOrder(context, null);
16
- }
17
- // Test case for non-ObjectExpression node
18
- if (node.callee.type === 'Identifier' && node.callee.name === 'testNonObjectCase') {
19
- // This will trigger the first early return (wrong type)
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- enforceFontFaceOrder(context, { type: 'Literal' });
22
- }
23
- // Test case for empty or single property object
24
- if (node.callee.type === 'Identifier' && node.callee.name === 'testSinglePropertyCase') {
25
- // This will trigger the second early return (regularProperties.length <= 1)
26
- enforceFontFaceOrder(context, {
27
- type: 'ObjectExpression',
28
- properties: [
29
- {
30
- type: 'Property',
31
- key: { type: 'Identifier', name: 'fontFamily' },
32
- value: { type: 'Literal', value: 'Arial' },
33
- computed: false,
34
- kind: 'init',
35
- method: false,
36
- shorthand: false,
37
- },
38
- ],
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- });
41
- }
42
- },
43
- };
44
- },
45
- };
46
- run({
47
- name: 'vanilla-extract/font-face-edge-cases',
48
- rule: fontFaceEdgeCasesRule,
49
- languageOptions: {
50
- parser: tsParser,
51
- parserOptions: {
52
- ecmaVersion: 2022,
53
- sourceType: 'module',
54
- },
55
- },
56
- valid: [`testNullCase();`, `testNonObjectCase();`, `testSinglePropertyCase();`],
57
- invalid: [],
58
- });
@@ -1,125 +0,0 @@
1
- import tsParser from '@typescript-eslint/parser';
2
- import { run } from 'eslint-vitest-rule-tester';
3
- import alphabeticalOrderRule from '../../alphabetical-order/rule-definition.js';
4
- import customGroupOrderRule from '../../custom-order/rule-definition.js';
5
- import { createNodeVisitors } from '../order-strategy-visitor-creator.js';
6
- // Modified version of the custom order rule with empty group order
7
- const emptyGroupOrderRule = {
8
- ...customGroupOrderRule,
9
- create(context) {
10
- // Trigger the error for empty userDefinedGroupOrder
11
- try {
12
- return customGroupOrderRule.create({
13
- ...context,
14
- options: [{ groupOrder: [], sortRemainingProperties: 'alphabetical' }],
15
- });
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- }
18
- catch (error) {
19
- // Just catch the error but continue with the test
20
- return {};
21
- }
22
- },
23
- };
24
- // A rule that tests the default case in the switch statement
25
- const defaultCaseRule = {
26
- ...alphabeticalOrderRule,
27
- create(context) {
28
- // Force the default case by passing an invalid ordering strategy
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- const visitors = createNodeVisitors(context, 'invalid-strategy');
31
- return visitors;
32
- },
33
- };
34
- // A rule that tests non-Identifier callee
35
- const nonIdentifierCalleeRule = {
36
- ...alphabeticalOrderRule,
37
- create(context) {
38
- return {
39
- CallExpression(node) {
40
- // Original rule's visitor will be called first
41
- const visitors = alphabeticalOrderRule.create(context);
42
- if (visitors.CallExpression) {
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- visitors.CallExpression(node);
45
- }
46
- },
47
- };
48
- },
49
- };
50
- // Test the empty group order case
51
- run({
52
- name: 'vanilla-extract/empty-group-order-test',
53
- rule: emptyGroupOrderRule,
54
- languageOptions: {
55
- parser: tsParser,
56
- parserOptions: {
57
- ecmaVersion: 2022,
58
- sourceType: 'module',
59
- },
60
- },
61
- valid: [
62
- // Simple test case to execute the rule
63
- `
64
- import { style } from '@vanilla-extract/css';
65
-
66
- const myStyle = style({
67
- backgroundColor: 'white',
68
- color: 'blue'
69
- });
70
- `,
71
- ],
72
- invalid: [],
73
- });
74
- // Test the default case in the switch statement
75
- run({
76
- name: 'vanilla-extract/default-case-test',
77
- rule: defaultCaseRule,
78
- languageOptions: {
79
- parser: tsParser,
80
- parserOptions: {
81
- ecmaVersion: 2022,
82
- sourceType: 'module',
83
- },
84
- },
85
- valid: [
86
- // Simple test case to execute the rule
87
- `
88
- import { style } from '@vanilla-extract/css';
89
-
90
- const myStyle = style({
91
- backgroundColor: 'white',
92
- color: 'blue'
93
- });
94
- `,
95
- ],
96
- invalid: [],
97
- });
98
- // Test the non-Identifier callee case
99
- run({
100
- name: 'vanilla-extract/non-identifier-callee-test',
101
- rule: nonIdentifierCalleeRule,
102
- languageOptions: {
103
- parser: tsParser,
104
- parserOptions: {
105
- ecmaVersion: 2022,
106
- sourceType: 'module',
107
- },
108
- },
109
- valid: [
110
- // Test with a member expression callee (not an Identifier)
111
- `
112
- import { css } from '@vanilla-extract/css';
113
-
114
- const utils = {
115
- createStyle: function(obj) { return obj; }
116
- };
117
-
118
- const myStyle = utils.createStyle({
119
- backgroundColor: 'white',
120
- color: 'blue'
121
- });
122
- `,
123
- ],
124
- invalid: [],
125
- });
@@ -1,53 +0,0 @@
1
- import tsParser from '@typescript-eslint/parser';
2
- import { run } from 'eslint-vitest-rule-tester';
3
- import testRuleForPropertyNameExtractor from './test-property-name-rule.js';
4
- run({
5
- name: 'vanilla-extract/property-name-extractor-tests',
6
- rule: testRuleForPropertyNameExtractor,
7
- languageOptions: {
8
- parser: tsParser,
9
- parserOptions: {
10
- ecmaVersion: 2022,
11
- sourceType: 'module',
12
- },
13
- },
14
- valid: [
15
- // Test for identifier and string literal keys (should return names)
16
- `
17
- import { style } from '@vanilla-extract/css';
18
-
19
- const myStyle = style({
20
- color: 'blue',
21
- 'background-color': 'white',
22
- fontSize: '16px'
23
- });
24
- `,
25
- // Test for computed property with non-string literal (should return empty string)
26
- `
27
- import { style } from '@vanilla-extract/css';
28
-
29
- const myStyle = style({
30
- [42]: 'numeric key',
31
- [true]: 'boolean key'
32
- });
33
- `,
34
- // Test for computed property with complex expression
35
- `
36
- import { style } from '@vanilla-extract/css';
37
-
38
- const myStyle = style({
39
- [Math.random() > 0.5 ? 'dynamicKey' : 'otherKey']: 'dynamic value'
40
- });
41
- `,
42
- // Test for property with template literal key
43
- `
44
- import { style } from '@vanilla-extract/css';
45
-
46
- const prefix = 'webkit';
47
- const myStyle = style({
48
- [\`-\${prefix}-appearance\`]: 'none'
49
- });
50
- `,
51
- ],
52
- invalid: [],
53
- });
@@ -1,116 +0,0 @@
1
- import tsParser from '@typescript-eslint/parser';
2
- import { run } from 'eslint-vitest-rule-tester';
3
- import alphabeticalOrderRule from '../../alphabetical-order/rule-definition.js';
4
- run({
5
- name: 'vanilla-extract/recipe-property-processor-tests',
6
- rule: alphabeticalOrderRule,
7
- languageOptions: {
8
- parser: tsParser,
9
- parserOptions: {
10
- ecmaVersion: 2022,
11
- sourceType: 'module',
12
- },
13
- },
14
- valid: [
15
- // Test for recipe with spread element (should trigger the early return)
16
- `
17
- import { recipe } from '@vanilla-extract/recipes';
18
- import { style } from '@vanilla-extract/css';
19
-
20
- const baseStyle = style({ backgroundColor: 'blue', color: 'white' });
21
-
22
- const myRecipe = recipe({
23
- base: baseStyle,
24
- ...{ someSpreadProperty: true },
25
- variants: {
26
- size: {
27
- small: style({ fontSize: '1.2rem', padding: '4rem' }),
28
- large: style({ fontSize: '1.8rem', padding: '12rem' })
29
- }
30
- }
31
- });
32
- `,
33
- // Test for recipe with computed property (non-Identifier key)
34
- `
35
- import { recipe } from '@vanilla-extract/recipes';
36
- import { style } from '@vanilla-extract/css';
37
-
38
- const propName = 'dynamicProp';
39
- const baseStyle = style({ backgroundColor: 'blue', color: 'white' });
40
-
41
- const myRecipe = recipe({
42
- base: baseStyle,
43
- [propName]: style({ fontSize: '1.4rem' }),
44
- variants: {
45
- size: {
46
- small: style({ fontSize: '1.2rem', padding: '4rem' }),
47
- large: style({ fontSize: '1.8rem', padding: '12rem' })
48
- }
49
- }
50
- });
51
- `,
52
- // Test for recipe with non-object values (should skip processing)
53
- `
54
- import { recipe } from '@vanilla-extract/recipes';
55
- import { style } from '@vanilla-extract/css';
56
-
57
- const baseStyle = style({ backgroundColor: 'blue', color: 'white' });
58
-
59
- const myRecipe = recipe({
60
- base: baseStyle,
61
- nonObjectProp: 'string value',
62
- numericProp: 42,
63
- booleanProp: true,
64
- nullProp: null,
65
- variants: {
66
- size: {
67
- small: style({ fontSize: '1.2rem', padding: '4rem' }),
68
- large: style({ fontSize: '1.8rem', padding: '12rem' })
69
- }
70
- }
71
- });
72
- `,
73
- ],
74
- invalid: [
75
- // Basic recipe with incorrect ordering in style calls
76
- {
77
- code: `
78
- import { recipe } from '@vanilla-extract/recipes';
79
- import { style } from '@vanilla-extract/css';
80
-
81
- const baseStyle = style({ color: 'blue', backgroundColor: 'white' });
82
-
83
- const myRecipe = recipe({
84
- base: baseStyle,
85
- variants: {
86
- size: {
87
- small: style({ padding: '4rem', fontSize: '1.2rem' }),
88
- large: style({ padding: '12rem', fontSize: '1.8rem' })
89
- }
90
- }
91
- });
92
- `,
93
- errors: [
94
- { messageId: 'alphabeticalOrder' },
95
- { messageId: 'alphabeticalOrder' },
96
- { messageId: 'alphabeticalOrder' },
97
- ],
98
- output: `
99
- import { recipe } from '@vanilla-extract/recipes';
100
- import { style } from '@vanilla-extract/css';
101
-
102
- const baseStyle = style({ backgroundColor: 'white', color: 'blue' });
103
-
104
- const myRecipe = recipe({
105
- base: baseStyle,
106
- variants: {
107
- size: {
108
- small: style({ fontSize: '1.2rem', padding: '4rem' }),
109
- large: style({ fontSize: '1.8rem', padding: '12rem' })
110
- }
111
- }
112
- });
113
- `,
114
- },
115
- ],
116
- });
@@ -1,55 +0,0 @@
1
- import tsParser from '@typescript-eslint/parser';
2
- import { run } from 'eslint-vitest-rule-tester';
3
- import alphabeticalOrderRule from '../../alphabetical-order/rule-definition.js';
4
- run({
5
- name: 'vanilla-extract/style-node-processor-tests',
6
- rule: alphabeticalOrderRule,
7
- languageOptions: {
8
- parser: tsParser,
9
- parserOptions: {
10
- ecmaVersion: 2022,
11
- sourceType: 'module',
12
- },
13
- },
14
- valid: [
15
- // Test for empty array
16
- `
17
- import { style } from '@vanilla-extract/css';
18
-
19
- const emptyStyle = style([]);
20
- `,
21
- // Test for null/undefined handling
22
- `
23
- import { style } from '@vanilla-extract/css';
24
-
25
- const dynamicStyle = style(undefined);
26
- const nullStyle = style(null);
27
- `,
28
- ],
29
- invalid: [
30
- // Test for array with mixed content
31
- {
32
- code: `
33
- import { style } from '@vanilla-extract/css';
34
-
35
- const myStyle = style([
36
- { zIndex: 1, position: 'relative' },
37
- null,
38
- undefined,
39
- { display: 'flex', alignItems: 'center' }
40
- ]);
41
- `,
42
- errors: [{ messageId: 'alphabeticalOrder' }, { messageId: 'alphabeticalOrder' }],
43
- output: `
44
- import { style } from '@vanilla-extract/css';
45
-
46
- const myStyle = style([
47
- { position: 'relative', zIndex: 1 },
48
- null,
49
- undefined,
50
- { alignItems: 'center', display: 'flex' }
51
- ]);
52
- `,
53
- },
54
- ],
55
- });
@@ -1,3 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- declare const testRuleForPropertyNameExtractor: Rule.RuleModule;
3
- export default testRuleForPropertyNameExtractor;
@@ -1,30 +0,0 @@
1
- import { getPropertyName } from '../property-separator.js';
2
- const testRuleForPropertyNameExtractor = {
3
- meta: {
4
- type: 'suggestion',
5
- docs: {
6
- description: 'enforce test rule for property name extraction',
7
- category: 'Stylistic Issues',
8
- recommended: false,
9
- },
10
- fixable: undefined,
11
- schema: [],
12
- messages: {
13
- emptyName: 'Property name extraction returned an empty string for this property',
14
- },
15
- },
16
- create() {
17
- return {
18
- ObjectExpression(node) {
19
- // Extract property names without enforcing any order
20
- node.properties.forEach((property) => {
21
- if (property.type === 'Property') {
22
- // Test the getPropertyName function
23
- getPropertyName(property);
24
- }
25
- });
26
- },
27
- };
28
- },
29
- };
30
- export default testRuleForPropertyNameExtractor;