Skip to content

Commit

Permalink
Fix hue-degree-notation false negatives for oklch (#7015)
Browse files Browse the repository at this point in the history
* Fix `hue-degree-notation` false negatives for `oklch`

* Create ten-mirrors-clean.md

* increase test coverage
  • Loading branch information
romainmenke committed Jun 30, 2023
1 parent ef7e77e commit d2c398c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/ten-mirrors-clean.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `hue-degree-notation` false negatives for `oklch`
21 changes: 21 additions & 0 deletions lib/rules/hue-degree-notation/__tests__/index.js
Expand Up @@ -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%) }',
},
Expand Down Expand Up @@ -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%) }',
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/hue-degree-notation/index.js
Expand Up @@ -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');

Expand Down

0 comments on commit d2c398c

Please sign in to comment.