@bigcommerce/stencil-cli 7.2.2 → 7.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,19 +13,28 @@ class BaseRulesFixer extends BaseFixer {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
transform() {
|
|
16
|
+
const self = this;
|
|
16
17
|
return {
|
|
17
18
|
postcssPlugin: 'Transform Base Rules Issues into Comments',
|
|
18
19
|
Rule(rule, { Comment }) {
|
|
19
20
|
if (
|
|
20
21
|
rule.parent.type === 'root' &&
|
|
21
|
-
(rule.selector.startsWith('
|
|
22
|
+
(rule.selector.startsWith('&') ||
|
|
23
|
+
rule.selector.startsWith(':not(&)') ||
|
|
24
|
+
rule.selector.startsWith('* &'))
|
|
22
25
|
) {
|
|
23
|
-
const comment = new Comment({ text:
|
|
26
|
+
const comment = new Comment({ text: self.replaceInnerComments(rule) });
|
|
24
27
|
rule.replaceWith(comment);
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
};
|
|
28
31
|
}
|
|
32
|
+
|
|
33
|
+
// when we replace rule with comment, there might be a case when comment is inside another rule
|
|
34
|
+
// which breaks the commenting root rule
|
|
35
|
+
replaceInnerComments(rule) {
|
|
36
|
+
return rule.toString().replace(/\/\*(.*)\*\//g, '//$1');
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
module.exports = BaseRulesFixer;
|