From 815fa9456cfa05698a234773010382def6d2df1c Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Fri, 16 Jun 2023 18:17:37 +0200 Subject: [PATCH 1/3] Fix `function-calc-no-unspaced-operator` performance --- lib/rules/function-calc-no-unspaced-operator/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rules/function-calc-no-unspaced-operator/index.js b/lib/rules/function-calc-no-unspaced-operator/index.js index 57f42f2603..81a1fb9c8b 100644 --- a/lib/rules/function-calc-no-unspaced-operator/index.js +++ b/lib/rules/function-calc-no-unspaced-operator/index.js @@ -48,6 +48,8 @@ const rule = (primary, _secondaryOptions, context) => { } root.walkDecls((decl) => { + if (!OPERATOR_REGEX.test(getDeclarationValue(decl))) return; + let needsFix = false; const valueIndex = declarationValueIndex(decl); const parsedValue = valueParser(getDeclarationValue(decl)); From a6a8050e58a479e8b1b138fbd29cef79aeded700 Mon Sep 17 00:00:00 2001 From: Romain Menke <11521496+romainmenke@users.noreply.github.com> Date: Sat, 17 Jun 2023 09:36:36 +0200 Subject: [PATCH 2/3] Update lib/rules/function-calc-no-unspaced-operator/index.js Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> --- lib/rules/function-calc-no-unspaced-operator/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rules/function-calc-no-unspaced-operator/index.js b/lib/rules/function-calc-no-unspaced-operator/index.js index 81a1fb9c8b..0e7c00f07e 100644 --- a/lib/rules/function-calc-no-unspaced-operator/index.js +++ b/lib/rules/function-calc-no-unspaced-operator/index.js @@ -48,11 +48,13 @@ const rule = (primary, _secondaryOptions, context) => { } root.walkDecls((decl) => { - if (!OPERATOR_REGEX.test(getDeclarationValue(decl))) return; + const value = getDeclarationValue(decl); + + if (!OPERATOR_REGEX.test(value)) return; let needsFix = false; const valueIndex = declarationValueIndex(decl); - const parsedValue = valueParser(getDeclarationValue(decl)); + const parsedValue = valueParser(value); /** * @param {import('postcss-value-parser').Node} operatorNode From d647e47c5c0fe7abf2f04fb7264c26f509b22cec Mon Sep 17 00:00:00 2001 From: Romain Menke Date: Sat, 17 Jun 2023 09:47:51 +0200 Subject: [PATCH 3/3] changelog and cleanup --- .changeset/wet-countries-think.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wet-countries-think.md diff --git a/.changeset/wet-countries-think.md b/.changeset/wet-countries-think.md new file mode 100644 index 0000000000..7dd9a539de --- /dev/null +++ b/.changeset/wet-countries-think.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `function-calc-no-unspaced-operator` performance