| 9 | } |
| 10 | |
| 11 | transform() { |
| 12 | const self = this; |
| 13 | return { |
| 14 | postcssPlugin: 'Transform Base Rules Issues into Comments', |
| 15 | Rule(rule, { Comment }) { |
| 16 | if ( |
| 17 | rule.parent.type === 'root' && |
| 18 | (rule.selector.startsWith('&') || |
| 19 | rule.selector.startsWith(':not(&)') || |
| 20 | rule.selector.startsWith('* &')) |
| 21 | ) { |
| 22 | const comment = new Comment({ text: self.replaceInnerComments(rule) }); |
| 23 | rule.replaceWith(comment); |
| 24 | } |
| 25 | }, |
| 26 | }; |
| 27 | } |
| 28 | |
| 29 | // when we replace rule with comment, there might be a case when comment is inside another rule |
| 30 | // which breaks the commenting root rule |