-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: require-baseline rule #33
base: main
Are you sure you want to change the base?
Changes from 11 commits
f9935b4
7521367
37d167f
dae9f8e
0eed212
a3f90b3
a2626a9
197260b
a4a6194
5f1f770
3bbc969
4d936e7
c1ce678
7edcd62
cdf3861
7ccc9cf
cef99e5
c3c410c
ab1fd70
e5b7d96
1cfa739
61c18e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist | ||
CHANGELOG.md | ||
jsr.json | ||
src/data |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,71 @@ | ||||||
# baseline | ||||||
|
||||||
Enforce the use of baseline features | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Docs] This reads to me as the opposite of what the rule does. I see the rule as being in the family of "Disallow ..." because it reports to stop devs from using certain syntax. Suggesting making the description more in line with that:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only use "disallow" when the rule begins with "no". For others, we use "Enforce" (or "Suggest"). |
||||||
|
||||||
## Background | ||||||
|
||||||
[Baseline](https://web.dev/baseline) is an effort by the [W3C WebDX Community Group](https://github.com/web-platform-dx) to document which features are available in four core browsers: Chrome (desktop and Android), Edge, Firefox (desktop and Android), and Safari (macOS and iOS). This data allows developers to choose the technologies that are best supported for their audience. As part of this effort, Baseline tracks which CSS features are available in which browsers. | ||||||
|
||||||
Features are grouped into three levels: | ||||||
|
||||||
- **Widely available** features are those supported by all core browsers for at least 30 months. | ||||||
- **Newly available** features are those supported by all core browsers for less than 30 months. | ||||||
- **Limited availability** features are those supported by some but not all core browsers. | ||||||
|
||||||
Generally speaking, it's preferable to stick to widely available features to ensure the greatest interoperability across browsers. | ||||||
|
||||||
## Rule Details | ||||||
|
||||||
This rule warns when it finds any of the following: | ||||||
|
||||||
- A CSS property that isn't widely available or otherwise isn't enclosed in a `@supports` block. | ||||||
- An at-rule that isn't widely available. | ||||||
- A CSS property value that isn't widely available or otherwise isn't enclosed in a `@supports` block (currently limited to identifiers only). | ||||||
- A CSS property function that isn't widely available. | ||||||
|
||||||
The data is provided via the [web-features](https://npmjs.com/package/web-features) package. | ||||||
|
||||||
Here are some examples: | ||||||
|
||||||
```css | ||||||
/* invalid - accent-color is not widely available */ | ||||||
a { | ||||||
accent-color: red; | ||||||
} | ||||||
|
||||||
/* invalid - abs is not widely available */ | ||||||
.box { | ||||||
width: abs(20% - 100px); | ||||||
} | ||||||
|
||||||
/* invalid - property value doesn't match @supports indicator */ | ||||||
@supports (accent-color: auto) { | ||||||
a { | ||||||
accent-color: abs(20% - 10px); | ||||||
} | ||||||
} | ||||||
|
||||||
/* valid - @supports indicates you're choosing a limited availability property */ | ||||||
@supports (accent-color: auto) { | ||||||
a { | ||||||
accent-color: auto; | ||||||
} | ||||||
} | ||||||
|
||||||
/* invalid - @supports says that this property isn't available */ | ||||||
@supports not (accent-color: auto) { | ||||||
a { | ||||||
accent-color: auto; | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
### Options | ||||||
|
||||||
This rule accepts an option object with the following properties: | ||||||
|
||||||
- `available` (default: `"widely"`) - change to `"newly"` available to allow a larger number of properties and at-rules. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Docs] I think it'd be good to be a bit more precise. Many folks reading this file probably won't be confident enough to piece it together. Maybe...
Suggested change
I couldn't find a better single linkable resource on the web.dev site... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind adding a reference, but it should be a "Further Reading" section, not inline with the option. |
||||||
|
||||||
## When Not to Use It | ||||||
|
||||||
If your web application targets just one browser then you can safely disable this rule. | ||||||
nzakas marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Data | ||
|
||
Some of the files in this directory are auto-generated and should not be modified manually. | ||
|
||
## baseline-data.js (autogenerated) | ||
|
||
Contains the aggregated data for [baseline](https://web.dev/baseline). | ||
|
||
To generate baseline data, run: | ||
|
||
```shell | ||
npm run build:baseline | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Naming] Maybe,
baseline-support
orbaseline-supported
, to indicate it's about specifically the support aspect ofbaseline
? But that disambiguation is probably only useful if there are other baseline-related rules to disambiguate from. And there are none. So no strong preference here.