diff --git a/.changeset/empty-starfishes-leave.md b/.changeset/empty-starfishes-leave.md new file mode 100644 index 0000000000..0fae632491 --- /dev/null +++ b/.changeset/empty-starfishes-leave.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `hue-degree-notation` performance diff --git a/lib/rules/hue-degree-notation/index.js b/lib/rules/hue-degree-notation/index.js index 234c41d451..bad4598f0a 100644 --- a/lib/rules/hue-degree-notation/index.js +++ b/lib/rules/hue-degree-notation/index.js @@ -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) => { @@ -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));