stylelint-plugin-use-baseline 0.5.0 → 0.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 CHANGED
@@ -28,7 +28,7 @@ export default {
28
28
  "plugin/use-baseline": [
29
29
  true,
30
30
  {
31
- // "available" can be "widely" (default) or "newly"
31
+ // "widely" (default), "newly", or YYYY (e.g. 2023)
32
32
  available: "widely",
33
33
  },
34
34
  ],
@@ -51,67 +51,266 @@ This rule reports the following cases:
51
51
 
52
52
  The data is sourced from [`web-features`](https://npmjs.com/package/web-features).
53
53
 
54
- ### Note
55
-
56
- Although `cursor` is not yet labeled as Baseline, it has broad support. By default, **this plugin does not flag `cursor`** because it is [expected to be added to Baseline soon](https://github.com/web-platform-dx/web-features/issues/1038).
54
+ **Note:** Although `cursor` is not yet labeled as Baseline, it has broad support. By default, **this plugin does not flag `cursor`** because it is [expected to be added to Baseline soon](https://github.com/web-platform-dx/web-features/issues/1038).
57
55
 
58
56
  ## Options
59
57
 
60
- ### `available`: `"widely" | "newly"` | `YYYY`
61
-
62
- _Default_: `"widely"`
58
+ ### `true`
63
59
 
64
- - `"widely"` (default) – Allows features supported in all Baseline browsers for at least 30 months.
65
- - `"newly"` – Allows features supported in all Baseline browsers for less than 30 months. Limited availability features still trigger warnings.
66
- - `YYYY` – Allows features that became Baseline newly available that year, or earlier. For example, `2023`.
60
+ ```json
61
+ {
62
+ "plugin/use-baseline": true
63
+ }
64
+ ```
67
65
 
68
- ## Examples
66
+ The following patterns are considered problems:
69
67
 
70
68
  ```css
71
- /* invalid - accent-color is not widely available */
69
+ /* accent-color is not widely available */
72
70
  a {
73
71
  accent-color: red;
74
72
  }
73
+ ```
75
74
 
76
- /* valid - using @supports for accent-color */
75
+ ```css
76
+ /* abs() is not widely available */
77
+ .box {
78
+ width: abs(20% - 100px);
79
+ }
80
+ ```
81
+
82
+ ```css
83
+ /* :has() is not widely available */
84
+ h1:has(+ h2) {
85
+ margin: 0;
86
+ }
87
+ ```
88
+
89
+ ```css
90
+ /* property value doesn't match @supports indicator */
77
91
  @supports (accent-color: auto) {
78
92
  a {
79
- accent-color: auto;
93
+ accent-color: abs(20% - 10px);
80
94
  }
81
95
  }
96
+ ```
82
97
 
83
- /* invalid - abs() is not widely available */
84
- .box {
85
- width: abs(20% - 100px);
98
+ ```css
99
+ /* device-posture is not widely available */
100
+ @media (device-posture: folded) {
101
+ a {
102
+ color: red;
103
+ }
86
104
  }
105
+ ```
87
106
 
88
- /* invalid - :has() is not widely available */
89
- h1:has(+ h2) {
90
- margin: 0;
107
+ The following patterns are _not_ considered problems:
108
+
109
+ ```css
110
+ /* using @supports for accent-color */
111
+ @supports (accent-color: auto) {
112
+ a {
113
+ accent-color: auto;
114
+ }
91
115
  }
116
+ ```
92
117
 
93
- /* valid - @supports indicates limited availability */
118
+ ```css
119
+ /* @supports indicates limited availability */
94
120
  @supports selector(:has()) {
95
121
  h1:has(+ h2) {
96
122
  margin: 0;
97
123
  }
98
124
  }
125
+ ```
99
126
 
100
- /* invalid - property value doesn't match @supports indicator */
101
- @supports (accent-color: auto) {
127
+ ```css
128
+ /* widely supported properties */
129
+ a {
130
+ color: red;
131
+ background-color: blue;
132
+ transition: none;
133
+ }
134
+ ```
135
+
136
+ ## Optional secondary options
137
+
138
+ ### `available`
139
+
140
+ Specify which level of Baseline availability to enforce.
141
+
142
+ - `"widely"` (default) – Allows features supported in all Baseline browsers for at least 30 months.
143
+ - `"newly"` – Allows features supported in all Baseline browsers for less than 30 months. Limited availability features still trigger warnings.
144
+ - `YYYY` – Allows features that became Baseline newly available that year, or earlier. For example, `2023`.
145
+
146
+ #### `"widely"` (default)
147
+
148
+ Allows features supported in all Baseline browsers for at least 30 months.
149
+
150
+ Given:
151
+
152
+ ```json
153
+ {
154
+ "plugin/use-baseline": [true, { "available": "widely" }]
155
+ }
156
+ ```
157
+
158
+ #### `"newly"`
159
+
160
+ Allows features supported in all Baseline browsers for less than 30 months. Limited availability features still trigger warnings.
161
+
162
+ Given:
163
+
164
+ ```json
165
+ {
166
+ "plugin/use-baseline": [true, { "available": "newly" }]
167
+ }
168
+ ```
169
+
170
+ The following patterns are _not_ considered problems:
171
+
172
+ ```css
173
+ h1:has(+ h2) {
174
+ margin: 0;
175
+ }
176
+ ```
177
+
178
+ #### `YYYY`
179
+
180
+ Allows features that became Baseline newly available that year, or earlier. For example, `2023`.
181
+
182
+ Given:
183
+
184
+ ```json
185
+ {
186
+ "plugin/use-baseline": [true, { "available": 2023 }]
187
+ }
188
+ ```
189
+
190
+ The following patterns are _not_ considered problems:
191
+
192
+ ```css
193
+ div {
194
+ @starting-style {
195
+ opacity: 0;
196
+ }
197
+ }
198
+ ```
199
+
200
+ ### `ignoreSelectors`
201
+
202
+ ```json
203
+ { "ignoreSelectors": ["array", "of", "selectors", "/regex/"] }
204
+ ```
205
+
206
+ Given:
207
+
208
+ ```json
209
+ {
210
+ "plugin/use-baseline": [true, { "ignoreSelectors": ["nesting", "/^has/"] }]
211
+ }
212
+ ```
213
+
214
+ The following patterns are _not_ considered problems:
215
+
216
+ ```css
217
+ a {
218
+ img {
219
+ width: 100%;
220
+ }
221
+ }
222
+ ```
223
+
224
+ ```css
225
+ h1:has(+ h2) {
226
+ margin: 0;
227
+ }
228
+ ```
229
+
230
+ ```css
231
+ h1:has-slotted {
232
+ color: red;
233
+ }
234
+ ```
235
+
236
+ ### `ignoreProperties`
237
+
238
+ ```json
239
+ { "ignoreProperties": ["array", "of", "properties", "/regex/"] }
240
+ ```
241
+
242
+ Given:
243
+
244
+ ```json
245
+ {
246
+ "plugin/use-baseline": [
247
+ true,
248
+ { "ignoreProperties": ["accent-color", "/^animation-/"] }
249
+ ]
250
+ }
251
+ ```
252
+
253
+ The following patterns are _not_ considered problems:
254
+
255
+ ```css
256
+ a {
257
+ accent-color: red;
258
+ }
259
+ ```
260
+
261
+ ```css
262
+ div {
263
+ animation-composition: add;
264
+ }
265
+ ```
266
+
267
+ ```css
268
+ div {
269
+ animation-range: 20%;
270
+ }
271
+ ```
272
+
273
+ ### `ignoreAtRules`
274
+
275
+ ```json
276
+ { "ignoreAtRules": ["array", "of", "at-rules", "/regex/"] }
277
+ ```
278
+
279
+ Given:
280
+
281
+ ```json
282
+ {
283
+ "plugin/use-baseline": [true, { "ignoreAtRules": ["container", "/^font-/"] }]
284
+ }
285
+ ```
286
+
287
+ The following patterns are _not_ considered problems:
288
+
289
+ ```css
290
+ @container (min-width: 800px) {
102
291
  a {
103
- accent-color: abs(20% - 10px); /* mismatch */
292
+ color: red;
104
293
  }
105
294
  }
295
+ ```
106
296
 
107
- /* invalid - device-posture is not widely available */
108
- @media (device-posture: folded) {
109
- .foldable {
110
- padding: 1rem;
297
+ ```css
298
+ @font-feature-values Font One {
299
+ @styleset {
300
+ nice-style: 12;
111
301
  }
112
302
  }
113
303
  ```
114
304
 
305
+ ```css
306
+ @font-palette-values --foo {
307
+ font-family: Bixa;
308
+ override-colors:
309
+ 0 red,
310
+ 1 blue;
311
+ }
312
+ ```
313
+
115
314
  ## Prior art
116
315
 
117
316
  [eslint/css use-baseline](https://github.com/eslint/css/blob/main/docs/rules/use-baseline.md)