@antebudimir/eslint-plugin-vanilla-extract 1.11.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,16 @@
5
5
  [![npm version](https://img.shields.io/npm/v/@antebudimir/eslint-plugin-vanilla-extract.svg)](https://www.npmjs.com/package/@antebudimir/eslint-plugin-vanilla-extract)
6
6
  ![NPM Downloads](https://img.shields.io/npm/d18m/%40antebudimir%2Feslint-plugin-vanilla-extract)
7
7
 
8
+ ---
9
+
10
+ **Maintaining this plugin takes time and care! If you find it valuable, please consider supporting its development:**
11
+ 💖 GitHub Sponsors: <https://github.com/sponsors/antebudimir>
12
+ ☕ Ko-fi: <https://ko-fi.com/antebudimir>
13
+ 💸 Revolut: <https://revolut.me/antebudimir>
14
+ 🟡 Liberapay: <https://liberapay.com/antebudimir>
15
+
16
+ ---
17
+
8
18
  An ESLint plugin for enforcing best practices in
9
19
  [vanilla-extract](https://github.com/vanilla-extract-css/vanilla-extract) CSS styles, including CSS property ordering
10
20
  and additional linting rules. Available presets are for alphabetical and
@@ -67,7 +77,7 @@ There are two main ways to configure this plugin in your ESLint flat config:
67
77
 
68
78
  ### Option 1: Using extends (recommended, available from v1.10.0)
69
79
 
70
- The simplest way to apply the recommended ruleset:
80
+ The simplest and most concise way to apply the recommended ruleset:
71
81
 
72
82
  ```typescript
73
83
  import { defineConfig } from 'eslint/config';
@@ -78,13 +88,18 @@ export default defineConfig([
78
88
  files: ['**/*.css.ts'],
79
89
  ignores: ['src/**/theme-contract.css.ts'],
80
90
  extends: [vanillaExtract.configs.recommended],
91
+ // You can still override rules when using extends
92
+ // rules: {
93
+ // 'vanilla-extract/concentric-order': 'off',
94
+ // 'vanilla-extract/alphabetical-order': 'error',
95
+ // },
81
96
  },
82
97
  ];
83
98
  ```
84
99
 
85
- ### Option 2: Using plugins with explicit rule configuration
100
+ ### Option 2: Using plugins with explicit rule spreading
86
101
 
87
- This approach gives you more control over individual rules:
102
+ This approach is more explicit - you manually register the plugin and spread the recommended rules:
88
103
 
89
104
  ```typescript
90
105
  import { defineConfig } from 'eslint/config';
@@ -106,13 +121,64 @@ export default defineConfig([
106
121
  // 'vanilla-extract/no-empty-style-blocks': 'off', // Disable a recommended rule
107
122
  // 'vanilla-extract/no-zero-unit': 'warn', // Change severity from error to warn
108
123
 
109
- // Add additional rules not in recommended config
110
- // 'vanilla-extract/alphabetical-order': 'error', // Override concentric-order rule
124
+ // Switch to a different ordering rule (see "Important" section below)
125
+ // 'vanilla-extract/concentric-order': 'off',
126
+ // 'vanilla-extract/alphabetical-order': 'error',
127
+ },
128
+ },
129
+ ];
130
+ ```
131
+
132
+ #### Important: Only Enable One Ordering Rule at a Time
133
+
134
+ The plugin includes three CSS property ordering rules: `alphabetical-order`, `concentric-order`, and `custom-order`. **Only one ordering rule should be enabled at a time** to avoid conflicting auto-fixes.
135
+
136
+ If you want to use a different ordering rule than the one in the recommended config, you must explicitly disable the default rule.
137
+
138
+ ##### Example: Switching from concentric to alphabetical ordering
139
+
140
+ ```typescript
141
+ export default [
142
+ {
143
+ files: ['**/*.css.ts'],
144
+ plugins: {
145
+ 'vanilla-extract': vanillaExtract,
146
+ },
147
+ rules: {
148
+ ...vanillaExtract.configs.recommended.rules,
149
+ 'vanilla-extract/concentric-order': 'off', // Disable the default
150
+ 'vanilla-extract/alphabetical-order': 'error', // Enable alphabetical
151
+ },
152
+ },
153
+ ];
154
+ ```
155
+
156
+ ##### Example: Using custom-order instead of the recommended concentric-order
157
+
158
+ ```typescript
159
+ export default [
160
+ {
161
+ files: ['**/*.css.ts'],
162
+ plugins: {
163
+ 'vanilla-extract': vanillaExtract,
164
+ },
165
+ rules: {
166
+ ...vanillaExtract.configs.recommended.rules,
167
+ 'vanilla-extract/concentric-order': 'off', // Disable the default
168
+ 'vanilla-extract/custom-order': [
169
+ 'error',
170
+ {
171
+ groupOrder: ['font', 'dimensions', 'margin', 'padding', 'position', 'border'],
172
+ sortRemainingProperties: 'alphabetical',
173
+ },
174
+ ],
111
175
  },
112
176
  },
113
177
  ];
114
178
  ```
115
179
 
180
+ > **⚠️ Warning:** If multiple ordering rules are enabled simultaneously, they will produce conflicting auto-fixes that ESLint cannot apply, causing auto-fix on save to fail. Always ensure only one ordering rule is active.
181
+
116
182
  ### Using with FlatCompat (for ESLint 8.57.0 & 8.57.1)
117
183
 
118
184
  If you're migrating from legacy ESLint configurations, you can use the `FlatCompat` utility to convert them while adding
@@ -193,10 +259,15 @@ The recommended configuration enables the following rules with error severity:
193
259
 
194
260
  - `vanilla-extract/concentric-order`: Enforces concentric CSS property ordering
195
261
  - `vanilla-extract/no-empty-style-blocks`: Prevents empty style blocks
196
- - `vanilla-extract/no-unknown-unit`: prohibits usage of unrecognized CSS units.
197
- - `vanilla-extract/no-zero-unit`: removes unnecessary units for zero values
262
+ - `vanilla-extract/no-unknown-unit`: Prohibits usage of unrecognized CSS units
263
+ - `vanilla-extract/no-zero-unit`: Removes unnecessary units for zero values
264
+
265
+ **Additional rules available** (not enabled by default):
198
266
 
199
- You can use the recommended configuration as a starting point and override rules as needed for your project.
267
+ - `vanilla-extract/alphabetical-order`: Alternative ordering rule (alphabetical sorting)
268
+ - `vanilla-extract/custom-order`: Alternative ordering rule (custom group-based sorting)
269
+
270
+ You can use the recommended configuration as a starting point and override rules as needed for your project. See the configuration examples above for how to switch between ordering rules.
200
271
 
201
272
  ### Custom Configuration
202
273
 
@@ -230,6 +301,8 @@ export default [
230
301
  ];
231
302
  ```
232
303
 
304
+ > **Note:** Remember to enable only one ordering rule at a time. See the "Important" section above for details on switching between ordering rules.
305
+
233
306
  ## Rules
234
307
 
235
308
  ### vanilla-extract/alphabetical-order
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import noZeroUnitRule from './css-rules/no-zero-unit/rule-definition.js';
7
7
  const vanillaExtract = {
8
8
  meta: {
9
9
  name: '@antebudimir/eslint-plugin-vanilla-extract',
10
- version: '1.11.0',
10
+ version: '1.11.1',
11
11
  },
12
12
  rules: {
13
13
  'alphabetical-order': alphabeticalOrderRule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antebudimir/eslint-plugin-vanilla-extract",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
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",