Repository: eslint/css
Pull request #52 (2025-02-18 18:35:08)

fix: require-baseline should not warn for cursor property
<!--
    Thank you for contributing!

    ESLint adheres to the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct).
-->

#### Prerequisites checklist

- [x] I have read the [contributing guidelines](https://github.com/eslint/eslint/blob/HEAD/CONTRIBUTING.md).

<!--
    Please ensure your pull request is ready:

    - Read the pull request guide (https://eslint.org/docs/latest/contribute/pull-requests)
    - Update or create tests
    - If performance-related, include a benchmark
    - Update documentation for this change (if appropriate)
-->

<!--
    The following is required for all pull requests:
-->

#### What is the purpose of this pull request?

Update `require-baseline` rule does it doesn't warn for `cursor`.

#### What changes did you make? (Give an overview)

- Updated `generate-baseline.js` to not include data for `cursor`.
- Added a test to the `require-baseline` rule to validate that `cursor` doesn't trigger a warning.
- Updated the `require-baseline` docs to highlight that we are deviating from baseline in this case.

#### Related Issues

refs #51

<!-- include tags like "fixes #123" or "refs #123" -->

#### Is there anything you'd like reviewers to focus on?

<!-- markdownlint-disable-file MD004 -->



Patch:
diff --git a/docs/rules/require-baseline.md b/docs/rules/require-baseline.md
index 2d498ef..cfeaca7 100644
--- a/docs/rules/require-baseline.md
+++ b/docs/rules/require-baseline.md
@@ -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:
diff --git a/src/data/baseline-data.js b/src/data/baseline-data.js
index f19df6b..c57f7ff 100644
--- a/src/data/baseline-data.js
+++ b/src/data/baseline-data.js
@@ -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],
@@ -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([
diff --git a/tools/generate-baseline.js b/tools/generate-baseline.js
index 8dcaf8a..9aba6a5 100644
--- a/tools/generate-baseline.js
+++ b/tools/generate-baseline.js
@@ -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;
@@ -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] = {};
 			}


Test patch:
diff --git a/tests/rules/require-baseline.test.js b/tests/rules/require-baseline.test.js
index b584c9f..a8ac83b 100644
--- a/tests/rules/require-baseline.test.js
+++ b/tests/rules/require-baseline.test.js
@@ -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: "*";