Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positives for multiple match in declaration-property-value-allowed-list #6190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -85,3 +85,17 @@ testRule({
},
],
});

testRule({
ruleName,
config: {
'/.*/': ['rebeccapurple'],
'background-color': ['none'],
},

accept: [
{
code: 'a { color: rebeccapurple; background-color: none; }',
},
],
});
13 changes: 6 additions & 7 deletions lib/rules/declaration-property-value-allowed-list/index.js
Expand Up @@ -32,20 +32,19 @@ const rule = (primary) => {
return;
}

const propKeys = Object.keys(primary);

root.walkDecls((decl) => {
const prop = decl.prop;
const value = decl.value;
const { prop, value } = decl;

const unprefixedProp = vendor.unprefixed(prop);
const propKey = Object.keys(primary).find((propIdentifier) =>
matchesStringOrRegExp(unprefixedProp, propIdentifier),
);
const propPatterns = propKeys.filter((key) => matchesStringOrRegExp(unprefixedProp, key));

if (!propKey) {
if (propPatterns.length === 0) {
return;
}

if (optionsMatches(primary, propKey, value)) {
if (propPatterns.some((pattern) => optionsMatches(primary, pattern, value))) {
return;
}

Expand Down