Repository: stylelint-scss/stylelint-scss (js)

Issue:
at-rule-no-redundant triggers incorrectly when some (but not all) selector has "&"
Example input in Sass:
```scss
.foo {
  @at-root .bar,
  &baz {
    a: b;
  }
}

.foo {
  .bar,
  &baz {
    a: b;
  }
}
```
https://sass-lang.com/playground/#eJwzNNRLy89XqOZSUHBILNEtys8vUdBLSizSAQqoJSVWgWUUFBKtFJKsgaxarlouLrgO/AoBMc4WWQ==

The rule for `@at-root` will trigger saying it's redundant and should be removed. This implies both rules have the same output, however that's not correct. So rather than showing the linter error when _any_ selector has `&`, it should happen only when `_every_` selector does.

cc: @pamelalozano16 

Pull request description:
Check if all selectors followed by @at-root include '&' outside interpolation
Fix #868.

Patch:
diff --git a/src/rules/at-root-no-redundant/index.js b/src/rules/at-root-no-redundant/index.js
index 695f659..6d346c6 100644
--- a/src/rules/at-root-no-redundant/index.js
+++ b/src/rules/at-root-no-redundant/index.js
@@ -38,7 +38,10 @@ function rule(actual, _, context) {
     root.walkAtRules("at-root", node => {
       if (
         node.parent.type === "root" ||
-        node.params.replace(/#{.*}/g, "").includes("&") ||
+        node.params
+          .replace(/#{.*}/g, "")
+          .split(",")
+          .every(param => param.includes("&")) ||
         isWithinKeyframes(node)
       ) {
         if (context.fix) {


Test patch:
diff --git a/src/rules/at-root-no-redundant/__tests__/index.js b/src/rules/at-root-no-redundant/__tests__/index.js
index 880bf74..c63d57e 100644
--- a/src/rules/at-root-no-redundant/__tests__/index.js
+++ b/src/rules/at-root-no-redundant/__tests__/index.js
@@ -62,6 +62,18 @@ testRule({
         }
       }`,
       description: "Other at-rules nested inside @keyframes block."
+    },
+    {
+      code: `
+      .foo {
+        @at-root .bar,
+        &baz {
+          a: b;
+        }
+      }
+      `,
+      description:
+        "@at-root is followed by a nested selector containing`&` outside interpolation."
     }
   ],
   reject: [
@@ -131,6 +143,21 @@ testRule({
       column: 14,
       message: messages.rejected,
       description: "@at-root inside a @keyframes block, nested."
+    },
+    {
+      code: `
+      .foo {
+        @at-root &.bar,
+        &baz {
+          a: b;
+        }
+      }
+      `,
+      line: 3,
+      column: 9,
+      message: messages.rejected,
+      description:
+        "@at-root is followed by selectors all containing `&` outside interpolation."
     }
   ]
 });
@@ -198,6 +225,29 @@ testRule({
       column: 9,
       message: messages.rejected,
       description: "@at-root inside a @keyframes block, nested."
+    },
+    {
+      code: `
+      .foo {
+        @at-root &.bar,
+        &baz {
+          a: b;
+        }
+      }
+      `,
+      fixed: `
+      .foo {
+        &.bar,
+        &baz {
+          a: b;
+        }
+      }
+      `,
+      line: 3,
+      column: 9,
+      message: messages.rejected,
+      description:
+        "@at-root is followed by selectors all containing `&` outside interpolation."
     }
   ]
 });