Skip to content

Commit

Permalink
Check selector list for parent selectors in at-root-no-redundant (sty…
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelalozano16 committed Nov 27, 2023
1 parent 62ed2dc commit ee96bef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/rules/at-root-no-redundant/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ testRule({
`,
description:
"@at-root is followed by a nested selector containing`&` outside interpolation."
},
{
code: `
.a { @at-root c &, .a#{&}.b { c: d } }
`,
description: "selector list, contains interpolation"
}
],
reject: [
Expand Down Expand Up @@ -158,6 +164,15 @@ testRule({
message: messages.rejected,
description:
"@at-root is followed by selectors all containing `&` outside interpolation."
},
{
code: `
.a { @at-root .a & .b, .c & { c: d } }
`,
line: 2,
column: 12,
message: messages.rejected,
description: "selector list, all redundant"
}
]
});
Expand Down
3 changes: 1 addition & 2 deletions src/rules/at-root-no-redundant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ function rule(actual, _, context) {
if (
node.parent.type === "root" ||
node.params
.replace(/#{.*}/g, "")
.split(",")
.every(param => param.includes("&")) ||
.every(elem => elem.replace(/#{.*}/g, "").includes("&")) ||
isWithinKeyframes(node)
) {
if (context.fix) {
Expand Down

0 comments on commit ee96bef

Please sign in to comment.