Skip to content

Commit

Permalink
Fix hue-degree-notation performance (#7012)
Browse files Browse the repository at this point in the history
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
jeddy3 and ybiquitous committed Jun 30, 2023
1 parent 3ec4821 commit ef7e77e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-starfishes-leave.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `hue-degree-notation` performance
3 changes: 3 additions & 0 deletions lib/rules/hue-degree-notation/index.js
Expand Up @@ -24,6 +24,7 @@ const meta = {
const HUE_FIRST_ARG_FUNCS = ['hsl', 'hsla', 'hwb'];
const HUE_THIRD_ARG_FUNCS = ['lch'];
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');

/** @type {import('stylelint').Rule} */
const rule = (primary, _secondaryOptions, context) => {
Expand All @@ -36,6 +37,8 @@ const rule = (primary, _secondaryOptions, context) => {
if (!validOptions) return;

root.walkDecls((decl) => {
if (!HAS_HUE_COLOR_FUNC.test(decl.value)) return;

let needsFix = false;
const parsedValue = valueParser(getDeclarationValue(decl));

Expand Down

0 comments on commit ef7e77e

Please sign in to comment.