From c49290a0f4d9bd3bef4d65e7db024d182056aa1c Mon Sep 17 00:00:00 2001 From: Richard Hallows Date: Fri, 30 Jun 2023 11:53:00 +0100 Subject: [PATCH] Fix function-url-quotes performance (#7011) --- .changeset/tender-apes-count.md | 5 +++++ lib/rules/function-url-quotes/index.js | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 .changeset/tender-apes-count.md diff --git a/.changeset/tender-apes-count.md b/.changeset/tender-apes-count.md new file mode 100644 index 0000000000..e725efc37b --- /dev/null +++ b/.changeset/tender-apes-count.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `function-url-quotes` performance diff --git a/lib/rules/function-url-quotes/index.js b/lib/rules/function-url-quotes/index.js index b402ba7450..efe959ea44 100644 --- a/lib/rules/function-url-quotes/index.js +++ b/lib/rules/function-url-quotes/index.js @@ -24,6 +24,8 @@ const meta = { fixable: true, }; +const URL_FUNC_REGEX = /url\(/i; + /** @type {import('stylelint').Rule} */ const rule = (primary, secondaryOptions, context) => { return (root, result) => { @@ -57,6 +59,8 @@ const rule = (primary, secondaryOptions, context) => { * @param {import('postcss').Declaration} decl */ function checkDeclParams(decl) { + if (!URL_FUNC_REGEX.test(decl.value)) return; + if (!isStandardSyntaxDeclaration(decl)) return; const value = getDeclarationValue(decl);