Skip to content

Commit 96c3f95

Browse files
authored
fix: expand supported types in baseline-data (eslint#74)
* fix type regex * use non-capturing group * add mdn-data for css functions * regenerate baseline data
1 parent 8fcae6c commit 96c3f95

File tree

4 files changed

+84
-30
lines changed

4 files changed

+84
-30
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"got": "^14.4.2",
101101
"lint-staged": "^15.2.7",
102102
"mdast-util-from-markdown": "^2.0.2",
103+
"mdn-data": "^2.17.0",
103104
"mocha": "^10.4.0",
104105
"prettier": "^3.4.1",
105106
"rollup": "^4.16.2",

src/data/baseline-data.js

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -565,60 +565,91 @@ export const types = new Map([
565565
["sign", "0:"],
566566
["anchor", "0:"],
567567
["anchor-size", "0:"],
568-
["time", "10:2015"],
568+
["inset", "10:2020"],
569569
["attr", "10:2015"],
570-
["blend-mode", "10:2020"],
571-
["line-style", "10:2015"],
572570
["calc", "10:2015"],
573-
["calc-keyword", "5:2022"],
574571
["calc-size", "0:"],
575-
["shape", "0:"],
576-
["color", "10:2015"],
577-
["string", "10:2015"],
572+
["rect", "0:"],
573+
["color", "5:2024"],
574+
["color-mix", "5:2023"],
575+
["conic-gradient", "5:2024"],
576+
["repeating-conic-gradient", "5:2024"],
578577
["counter", "10:2015"],
579578
["counters", "10:2015"],
580-
["easing-function", "10:2015"],
579+
["cross-fade", "0:"],
581580
["var", "10:2017"],
581+
["element", "0:"],
582582
["exp", "5:2023"],
583583
["hypot", "5:2023"],
584584
["log", "5:2023"],
585585
["pow", "5:2023"],
586586
["sqrt", "5:2023"],
587-
["filter-function", "10:2016"],
588-
["url", "10:2015"],
589-
["gradient", "10:2015"],
587+
["blur", "10:2016"],
588+
["brightness", "10:2016"],
589+
["contrast", "10:2016"],
590+
["drop-shadow", "10:2016"],
591+
["grayscale", "10:2016"],
592+
["hue-rotate", "10:2016"],
593+
["invert", "10:2016"],
594+
["opacity", "10:2016"],
595+
["saturate", "10:2016"],
596+
["sepia", "10:2016"],
597+
["linear-gradient", "10:2017"],
598+
["radial-gradient", "10:2021"],
599+
["repeating-linear-gradient", "10:2017"],
600+
["repeating-radial-gradient", "10:2020"],
590601
["image", "10:2015"],
591-
["flex", "10:2017"],
592-
["ratio", "10:2015"],
602+
["hsl", "5:2024"],
603+
["hwb", "5:2024"],
604+
["image-set", "5:2023"],
605+
["lab", "5:2024"],
606+
["lch", "5:2024"],
607+
["light-dark", "5:2024"],
593608
["clamp", "10:2020"],
594609
["max", "10:2020"],
595610
["min", "10:2020"],
596611
["ray", "5:2024"],
597-
["number", "10:2015"],
598-
["overflow", "10:2015"],
599-
["resolution", "5:2022"],
600-
["mod", "5:2024"],
612+
["oklab", "5:2024"],
613+
["oklch", "5:2024"],
614+
["paint", "0:"],
615+
["path", "0:"],
616+
["rgb", "10:2015"],
601617
["rem", "5:2024"],
618+
["mod", "5:2024"],
602619
["round", "5:2024"],
603620
["env", "10:2020"],
604-
["basic-shape", "10:2020"],
605-
["text-edge", "0:"],
606-
["angle", "10:2015"],
607-
["angle-percentage", "10:2015"],
608-
["position", "10:2015"],
609-
["transform-function", "10:2015"],
621+
["circle", "10:2020"],
622+
["ellipse", "10:2020"],
623+
["polygon", "10:2020"],
624+
["xywh", "0:"],
625+
["matrix", "10:2015"],
626+
["rotate", "10:2015"],
627+
["scale", "10:2015"],
628+
["scaleX", "10:2015"],
629+
["scaleY", "10:2015"],
630+
["skew", "10:2015"],
631+
["skewX", "10:2015"],
632+
["skewY", "10:2015"],
633+
["translate", "10:2015"],
634+
["translateX", "10:2015"],
635+
["translateY", "10:2015"],
636+
["matrix3d", "10:2015"],
637+
["perspective", "10:2022"],
638+
["rotate3d", "10:2015"],
639+
["rotateX", "10:2015"],
640+
["rotateY", "10:2015"],
641+
["rotateZ", "10:2015"],
642+
["scale3d", "10:2015"],
643+
["scaleZ", "10:2015"],
644+
["translate3d", "10:2015"],
645+
["translateZ", "10:2015"],
610646
["acos", "5:2023"],
611647
["asin", "5:2023"],
612648
["atan", "5:2023"],
613649
["atan2", "5:2023"],
614650
["cos", "5:2023"],
615651
["sin", "5:2023"],
616652
["tan", "5:2023"],
617-
["dimension", "10:2015"],
618-
["length", "10:2015"],
619-
["length-percentage", "10:2015"],
620-
["percentage", "10:2015"],
621-
["integer", "10:2015"],
622653
]);
623654
export const selectors = new Map([
624655
["active-view-transition", "0:"],

tests/rules/require-baseline.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,22 @@ ruleTester.run("require-baseline", rule, {
276276
},
277277
],
278278
},
279+
{
280+
code: "a { color: color-mix(in hsl, hsl(200 50 80), coral 80%); }",
281+
errors: [
282+
{
283+
messageId: "notBaselineType",
284+
data: {
285+
type: "color-mix",
286+
availability: "widely",
287+
},
288+
line: 1,
289+
column: 12,
290+
endLine: 1,
291+
endColumn: 56,
292+
},
293+
],
294+
},
279295
{
280296
code: "@media (color-gamut: srgb) { a { color: red; } }",
281297
errors: [

tools/generate-baseline.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import { getStatus as getBaselineStatus } from "compute-baseline";
1313
import { features as webFeatures } from "web-features";
14+
import mdnData from "mdn-data";
1415
import prettier from "prettier";
1516
import fs from "node:fs";
1617

@@ -101,7 +102,8 @@ function extractCSSFeatures(features) {
101102
const cssAtRulePattern = /^css\.at-rules\.(?<atRule>[a-zA-Z$\d-]+)$/u;
102103
const cssMediaConditionPattern =
103104
/^css\.at-rules\.media\.(?<condition>[a-zA-Z$\d-]+)$/u;
104-
const cssTypePattern = /^css\.types\.(?<type>[a-zA-Z$\d-]+)$/u;
105+
const cssTypePattern =
106+
/^css\.types\.(?:.*?\.)?(?<type>[a-zA-Z\d-]+)(?:\.[^.]*$|[^.]*$)/u;
105107
const cssSelectorPattern = /^css\.selectors\.(?<selector>[a-zA-Z$\d-]+)$/u;
106108

107109
const properties = {};
@@ -153,7 +155,11 @@ function extractCSSFeatures(features) {
153155

154156
// types
155157
if ((match = cssTypePattern.exec(key)) !== null) {
156-
types[match.groups.type] = mapFeatureStatus(status);
158+
const type = match.groups.type;
159+
if (!(`${type}()` in mdnData.css.functions)) {
160+
continue;
161+
}
162+
types[type] = mapFeatureStatus(status);
157163
continue;
158164
}
159165

0 commit comments

Comments
 (0)