stylelint
Version:
A mighty CSS linter that helps you avoid errors and enforce conventions.
56 lines (44 loc) • 1.33 kB
JavaScript
// NOTICE: This file is generated by Rollup. To modify it,
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
;
const isStandardSyntaxComment = require('../../utils/isStandardSyntaxComment.cjs');
const report = require('../../utils/report.cjs');
const ruleMessages = require('../../utils/ruleMessages.cjs');
const validateOptions = require('../../utils/validateOptions.cjs');
const ruleName = 'comment-no-empty';
const messages = ruleMessages(ruleName, {
rejected: 'Unexpected empty comment',
});
const meta = {
url: 'https://stylelint.io/user-guide/rules/comment-no-empty',
};
/** @type {import('stylelint').CoreRules[ruleName]} */
const rule = (primary) => {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, { actual: primary });
if (!validOptions) {
return;
}
root.walkComments((comment) => {
// To ignore non-standard comments
if (!isStandardSyntaxComment(comment)) {
return;
}
// To ignore comments that are not empty
if (comment.text && comment.text.length !== 0) {
return;
}
report({
message: messages.rejected,
messageArgs: [],
node: comment,
result,
ruleName,
});
});
};
};
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;
module.exports = rule;