Skip to content

Commit

Permalink
property-no-unknown for deeper nested properties
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelalozano16 committed Jan 16, 2024
1 parent d245813 commit d910673
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 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 @@ -105,6 +105,14 @@ testRule({
{
code: ".foo { border: { style: solid; } }",
description: "ignore nested properties"
},
{
code: ".foo { border: { style: solid; } }",
description: "ignore nested properties"
},
{
code: ".foo { background: { position: { x: left; } } }",
description: "ignore deeper nested properties"
}
]
});
Expand Down
16 changes: 9 additions & 7 deletions src/rules/property-no-unknown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@ function rule(primary, secondaryOptions) {
}

// Nested properties
if (
parent &&
isType(parent, "rule") &&
parent.selector &&
parent.selector[parent.selector.length - 1] === ":" &&
parent.selector.substring(0, 2) !== "--"
let pointer = parent;
while (
pointer &&
isType(pointer, "rule") &&
pointer.selector &&
pointer.selector[pointer.selector.length - 1] === ":" &&
pointer.selector.substring(0, 2) !== "--"
) {
prop = parent.selector.replace(":", "") + "-" + prop;
prop = pointer.selector.replace(":", "") + "-" + prop;
pointer = pointer.parent;
}

if (allValidProperties.has(prop.toLowerCase())) {
Expand Down

0 comments on commit d910673

Please sign in to comment.