stylelint-plugin-use-baseline 0.5.0 → 0.6.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 +234 -28
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +23 -13
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# stylelint-plugin-use-baseline
|
|
2
2
|
|
|
3
|
+
[![npm version][npm-version-img]][npm] [![npm downloads last month][npm-downloads-img]][npm]
|
|
4
|
+
|
|
3
5
|
Disallow CSS features not in [Baseline](https://web.dev/baseline).
|
|
4
6
|
|
|
5
7
|

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