diff --git a/.changeset/ten-mirrors-clean.md b/.changeset/ten-mirrors-clean.md new file mode 100644 index 0000000000..35116a269e --- /dev/null +++ b/.changeset/ten-mirrors-clean.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `hue-degree-notation` false negatives for `oklch` diff --git a/lib/rules/hue-degree-notation/__tests__/index.js b/lib/rules/hue-degree-notation/__tests__/index.js index 1899e157e0..d5cfbd31ed 100644 --- a/lib/rules/hue-degree-notation/__tests__/index.js +++ b/lib/rules/hue-degree-notation/__tests__/index.js @@ -23,6 +23,9 @@ testRule({ code: 'a { color: lch(56.29% 19.86) }', description: 'malformed lch', }, + { + code: 'a { color: oklch(56.29% 19.86 10deg) }', + }, { code: 'a { color: hsl(170deg 60% 50% / 15%) }', }, @@ -98,6 +101,15 @@ testRule({ endLine: 1, endColumn: 31, }, + { + code: 'a { color: oklch(56.29% 19.86 10) }', + fixed: 'a { color: oklch(56.29% 19.86 10deg) }', + message: messages.expected('10', '10deg'), + line: 1, + column: 31, + endLine: 1, + endColumn: 33, + }, { code: 'a { color: hsl(/*comment*/120 60% 70%) }', fixed: 'a { color: hsl(/*comment*/120deg 60% 70%) }', @@ -200,6 +212,15 @@ testRule({ endLine: 1, endColumn: 34, }, + { + code: 'a { color: oklch(56.29% 19.86 10deg) }', + fixed: 'a { color: oklch(56.29% 19.86 10) }', + message: messages.expected('10deg', '10'), + line: 1, + column: 31, + endLine: 1, + endColumn: 36, + }, { code: stripIndent` a { diff --git a/lib/rules/hue-degree-notation/index.js b/lib/rules/hue-degree-notation/index.js index bad4598f0a..d596c15bcb 100644 --- a/lib/rules/hue-degree-notation/index.js +++ b/lib/rules/hue-degree-notation/index.js @@ -22,7 +22,7 @@ const meta = { }; const HUE_FIRST_ARG_FUNCS = ['hsl', 'hsla', 'hwb']; -const HUE_THIRD_ARG_FUNCS = ['lch']; +const HUE_THIRD_ARG_FUNCS = ['lch', 'oklch']; const HUE_FUNCS = new Set([...HUE_FIRST_ARG_FUNCS, ...HUE_THIRD_ARG_FUNCS]); const HAS_HUE_COLOR_FUNC = new RegExp(`\\b(?:${[...HUE_FUNCS].join('|')})\\(`, 'i');