diff --git a/.changeset/heavy-pandas-cheer.md b/.changeset/heavy-pandas-cheer.md new file mode 100644 index 0000000000..ce4a855fe6 --- /dev/null +++ b/.changeset/heavy-pandas-cheer.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `custom-property-no-missing-var-function` performance diff --git a/lib/rules/custom-property-no-missing-var-function/index.js b/lib/rules/custom-property-no-missing-var-function/index.js index 6477997df1..f6378ff7f3 100644 --- a/lib/rules/custom-property-no-missing-var-function/index.js +++ b/lib/rules/custom-property-no-missing-var-function/index.js @@ -3,7 +3,6 @@ const valueParser = require('postcss-value-parser'); const declarationValueIndex = require('../../utils/declarationValueIndex'); -const isCustomProperty = require('../../utils/isCustomProperty'); const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); @@ -32,12 +31,15 @@ const rule = (primary) => { knownCustomProperties.add(atRule.params); }); - root.walkDecls(({ prop }) => { - if (isCustomProperty(prop)) knownCustomProperties.add(prop); + root.walkDecls(/^--/, ({ prop }) => { + knownCustomProperties.add(prop); }); root.walkDecls((decl) => { const { value } = decl; + + if (!value.includes('--')) return; + const parsedValue = valueParser(value); parsedValue.walk((node) => {