From 3028cf0efee976f950efdb70b0373a13a38017d2 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:15:56 +0900 Subject: [PATCH] Fix `unit-no-unknown` false positives for font-relative length units See https://w3c.github.io/csswg-drafts/css-values-4/#font-relative-lengths --- .changeset/old-moles-sort.md | 5 +++++ lib/reference/units.js | 12 +++++++++--- lib/rules/unit-no-unknown/__tests__/index.js | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .changeset/old-moles-sort.md diff --git a/.changeset/old-moles-sort.md b/.changeset/old-moles-sort.md new file mode 100644 index 0000000000..2ad24946c2 --- /dev/null +++ b/.changeset/old-moles-sort.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `unit-no-unknown` false positives for font-relative length units diff --git a/lib/reference/units.js b/lib/reference/units.js index b7ee630b0a..72ab5ead0d 100644 --- a/lib/reference/units.js +++ b/lib/reference/units.js @@ -3,13 +3,19 @@ const uniteSets = require('../utils/uniteSets.js'); const lengthUnits = new Set([ - // Relative length units + // Font-relative length units + 'cap', + 'ch', 'em', 'ex', - 'ch', + 'ic', + 'lh', + 'rcap', + 'rch', 'rem', + 'rex', + 'ric', 'rlh', - 'lh', // Viewport-percentage lengths 'dvh', 'dvmax', diff --git a/lib/rules/unit-no-unknown/__tests__/index.js b/lib/rules/unit-no-unknown/__tests__/index.js index 2dc5fc82a6..5ebd859f57 100644 --- a/lib/rules/unit-no-unknown/__tests__/index.js +++ b/lib/rules/unit-no-unknown/__tests__/index.js @@ -239,6 +239,9 @@ testRule({ code: 'a { image-resolution: 1x; }', description: 'ignore `x` unit in image-resolution', }, + { + code: 'a { width: 8ic; }', + }, ], reject: [