Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hue-degree-notation false negatives for oklch #7015

Merged
merged 4 commits into from Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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