Skip to content

Commit

Permalink
Fix custom-property-no-missing-var-function performance (#6922)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Jun 17, 2023
1 parent 1c44f18 commit aba1d97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-pandas-cheer.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `custom-property-no-missing-var-function` performance
8 changes: 5 additions & 3 deletions lib/rules/custom-property-no-missing-var-function/index.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit aba1d97

Please sign in to comment.