Skip to content

Commit

Permalink
Ignore interpolated properties in property-no-unknown (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelalozano16 committed Mar 9, 2024
1 parent 735aece commit 4513387
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rules/property-no-unknown/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { messages, ruleName } = require("..");
testRule({
ruleName,
config: [true],
customSyntax: "postcss-scss",

accept: [
{
Expand Down Expand Up @@ -37,6 +38,13 @@ testRule({
{
code: ".foo { --custom-property-set: { colr: blue; } }",
description: "ignore custom property sets"
},
{
code: `
$custom-property-set: '--custom-property-set';
.b { #{$custom-property-set}: blue; }
`,
description: "ignore custom property sets"
}
],

Expand Down
2 changes: 2 additions & 0 deletions src/rules/property-no-unknown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const isType = require("../../utils/isType");
const optionsMatches = require("../../utils/optionsMatches");
const namespace = require("../../utils/namespace");
const ruleUrl = require("../../utils/ruleUrl");
const hasInterpolation = require("../../utils/hasInterpolation");
const properties = require("known-css-properties").all;

const { utils } = require("stylelint");
Expand Down Expand Up @@ -67,6 +68,7 @@ function rule(primary, secondaryOptions) {
!isStandardSyntaxDeclaration(decl) ||
isCustomPropertySet(prop) ||
prop.startsWith("--") ||
hasInterpolation(prop) ||
(!shouldCheckPrefixed && vendorPrefix(prop)) ||
optionsMatches(secondaryOptions, "ignoreProperties", prop)
) {
Expand Down

0 comments on commit 4513387

Please sign in to comment.