File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = function getContainingNode ( node ) {
2
- // For styled-components: declarations are children of Root node
3
- if ( node . type !== 'rule' && node . type !== 'atrule' && node . parent . type === 'root' ) {
2
+ if ( node . type === 'rule' || node . type === 'atrule' ) {
3
+ return node ;
4
+ }
5
+
6
+ // postcss-styled-syntax: declarations are children of Root node
7
+ if ( node . parent ?. type === 'root' && node . parent ?. raws . styledSyntaxIsComponent ) {
8
+ return node . parent ;
9
+ }
10
+
11
+ // @stylelint /postcss-css-in-js: declarations are children of Root node
12
+ if ( node . parent ?. document ?. nodes ?. some ( ( item ) => item . type === 'root' ) ) {
4
13
return node . parent ;
5
14
}
6
15
Original file line number Diff line number Diff line change @@ -496,6 +496,17 @@ groupTest([
496
496
}
497
497
` ,
498
498
} ,
499
+ {
500
+ description : 'should not change in the root' ,
501
+ fixture : `
502
+ display: none;
503
+ @include hello;
504
+ ` ,
505
+ expected : `
506
+ display: none;
507
+ @include hello;
508
+ ` ,
509
+ } ,
499
510
{
500
511
fixture : `
501
512
a {
You can’t perform that action at this time.
0 commit comments