From 1c44f18c7322449990f790e92ae4a50188a3dac8 Mon Sep 17 00:00:00 2001 From: Romain Menke <11521496+romainmenke@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:02:14 +0200 Subject: [PATCH] Fix `function-no-unknown` false positives for SCSS functions with namespace (#6921) --- .changeset/brave-balloons-rescue.md | 5 +++++ lib/rules/function-no-unknown/__tests__/index.js | 4 ++++ lib/utils/isStandardSyntaxValue.js | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 .changeset/brave-balloons-rescue.md diff --git a/.changeset/brave-balloons-rescue.md b/.changeset/brave-balloons-rescue.md new file mode 100644 index 0000000000..26e54f5538 --- /dev/null +++ b/.changeset/brave-balloons-rescue.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `function-no-unknown` false positives for SCSS functions with namespace diff --git a/lib/rules/function-no-unknown/__tests__/index.js b/lib/rules/function-no-unknown/__tests__/index.js index fe6e87ab04..a0a9d5cacf 100644 --- a/lib/rules/function-no-unknown/__tests__/index.js +++ b/lib/rules/function-no-unknown/__tests__/index.js @@ -28,6 +28,10 @@ testRule({ { code: 'a { height: calc(10px*(5*(10 - 5))); }', }, + { + code: 'a { transform: color.adjust(1px); transform: rgb(color.adjust(1px)); }', + description: 'ignore scss namespaced functions', + }, ], reject: [ diff --git a/lib/utils/isStandardSyntaxValue.js b/lib/utils/isStandardSyntaxValue.js index d19100b83a..54d75474c0 100644 --- a/lib/utils/isStandardSyntaxValue.js +++ b/lib/utils/isStandardSyntaxValue.js @@ -26,6 +26,11 @@ module.exports = function isStandardSyntaxValue(value) { return false; } + // SCSS namespace (example namespace.function-name()) + if (/^.+\.[-\w]+\(/.test(value)) { + return false; + } + // Less variable if (normalizedValue.startsWith('@')) { return false;