Skip to content

Commit

Permalink
fix: require-baseline should not warn for cursor property (#52)
Browse files Browse the repository at this point in the history
refs #51
  • Loading branch information
nzakas authored Feb 18, 2025
1 parent 2c14710 commit 21b5aad
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 44 deletions.
2 changes: 2 additions & 0 deletions docs/rules/require-baseline.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ a {
}
```

**Important:** While the `cursor` property is not considered baseline, it has wide support and will likely be considered baseline once the WebDX Community Group adds [an editorial step](https://github.com/web-platform-dx/web-features/issues/1038). In the meantime, this rule does not warn when `cursor` is used.

### Options

This rule accepts an option object with the following properties:
Expand Down
43 changes: 0 additions & 43 deletions src/data/baseline-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export const properties = new Map([
["counter-set", 5],
["counter-increment", 10],
["counter-reset", 10],
["cursor", 0],
["custom-property", 10],
["display", 10],
["dominant-baseline", 10],
Expand Down Expand Up @@ -1377,48 +1376,6 @@ export const propertyValues = new Map([
["smooth", 0],
]),
],
[
"cursor",
new Map([
["alias", 0],
["all-scroll", 0],
["auto", 0],
["cell", 0],
["col-resize", 0],
["context-menu", 0],
["copy", 0],
["crosshair", 0],
["default", 0],
["e-resize", 0],
["ew-resize", 0],
["grab", 0],
["grabbing", 0],
["help", 0],
["move", 0],
["n-resize", 0],
["ne-resize", 0],
["nesw-resize", 0],
["no-drop", 0],
["none", 0],
["not-allowed", 0],
["ns-resize", 0],
["nw-resize", 0],
["nwse-resize", 0],
["pointer", 0],
["progress", 0],
["row-resize", 0],
["s-resize", 0],
["se-resize", 0],
["sw-resize", 0],
["text", 0],
["url", 0],
["vertical-text", 0],
["w-resize", 0],
["wait", 0],
["zoom-in", 0],
["zoom-out", 0],
]),
],
[
"text-overflow",
new Map([
Expand Down
1 change: 1 addition & 0 deletions tests/rules/require-baseline.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ruleTester.run("require-baseline", rule, {
`@supports (width: abs(20% - 100px)) {
a { width: abs(20% - 100px); }
}`,
"div { cursor: pointer; }",
{
code: `@property --foo {
syntax: "*";
Expand Down
17 changes: 16 additions & 1 deletion tools/generate-baseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import fs from "node:fs";
// Helpers
//------------------------------------------------------------------------------

/*
* Properties that aren't considered baseline but have wide support.
* https://github.com/web-platform-dx/web-features/issues/1038#issuecomment-2627370691
*/

const WIDE_SUPPORT_PROPERTIES = new Set(["cursor"]);

const BASELINE_HIGH = 10;
const BASELINE_LOW = 5;
const BASELINE_FALSE = 0;
Expand Down Expand Up @@ -78,13 +85,21 @@ function extractCSSFeatures(features) {
let match;

// property names
if ((match = cssPropertyPattern.exec(key)) !== null) {
if (
(match = cssPropertyPattern.exec(key)) !== null &&
!WIDE_SUPPORT_PROPERTIES.has(match.groups.property)
) {
properties[match.groups.property] = baselineIds.get(baseline);
continue;
}

// property values
if ((match = cssPropertyValuePattern.exec(key)) !== null) {
// don't include values for these properties
if (WIDE_SUPPORT_PROPERTIES.has(match.groups.property)) {
continue;
}

if (!propertyValues[match.groups.property]) {
propertyValues[match.groups.property] = {};
}
Expand Down

0 comments on commit 21b5aad

Please sign in to comment.