feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const stylelint = require('stylelint');
|
||||
|
||||
const ruleName = 'plugin/disallow-first-level-global';
|
||||
|
||||
module.exports = stylelint.createPlugin(ruleName, function (ruleValue) {
|
||||
if (ruleValue === null || ruleValue === undefined || ruleValue === false) {
|
||||
return () => {
|
||||
// Nop.
|
||||
};
|
||||
}
|
||||
return function (postcssRoot, postcssResult) {
|
||||
postcssRoot.walkRules(rule => {
|
||||
if (rule.parent.type === 'root' && /:global/.test(rule.selector)) {
|
||||
stylelint.utils.report({
|
||||
ruleName,
|
||||
result: postcssResult,
|
||||
node: rule,
|
||||
message: 'Disallow :global class with nesting level of 1',
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
module.exports.ruleName = ruleName;
|
||||
module.exports.messages = stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: 'Disallow :global class with nesting level of 1',
|
||||
});
|
||||
Reference in New Issue
Block a user