Skip to content

Commit

Permalink
Fix selector-not-notation autofix of the "simple" option (#7703)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mouvedia committed May 23, 2024
1 parent c4ea9d4 commit 8364760
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-falcons-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-not-notation` autofix of the `"simple"` option
9 changes: 9 additions & 0 deletions lib/rules/selector-not-notation/__tests__/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ testRule({
endLine: 1,
endColumn: 13,
},
{
code: 'p, :not(a, div) {}',
fixed: 'p, :not(a):not(div) {}',
message: messages.expected('simple'),
line: 1,
column: 4,
endLine: 1,
endColumn: 16,
},
{
code: ':not(.bar, .baz, .foo) {}',
fixed: ':not(.bar):not(.baz):not(.foo) {}',
Expand Down
4 changes: 3 additions & 1 deletion lib/rules/selector-not-notation/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ function fixSimple(not) {

for (const s of simpleSelectors) {
const last = getLastConsecutiveNot(not);
const clone = last.clone({ nodes: [s] });

not.parent.insertAfter(last, last.clone({ nodes: [s] }));
clone.rawSpaceBefore = '';
not.parent.insertAfter(last, clone);
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/rules/selector-not-notation/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ function fixSimple(not) {

for (const s of simpleSelectors) {
const last = getLastConsecutiveNot(not);
const clone = last.clone({ nodes: [s] });

not.parent.insertAfter(last, last.clone({ nodes: [s] }));
clone.rawSpaceBefore = '';
not.parent.insertAfter(last, clone);
}
}

Expand Down

0 comments on commit 8364760

Please sign in to comment.