index.cjs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const isStandardSyntaxComment = require('../../utils/isStandardSyntaxComment.cjs');
  5. const report = require('../../utils/report.cjs');
  6. const ruleMessages = require('../../utils/ruleMessages.cjs');
  7. const validateOptions = require('../../utils/validateOptions.cjs');
  8. const ruleName = 'comment-no-empty';
  9. const messages = ruleMessages(ruleName, {
  10. rejected: 'Unexpected empty comment',
  11. });
  12. const meta = {
  13. url: 'https://stylelint.io/user-guide/rules/comment-no-empty',
  14. };
  15. /** @type {import('stylelint').CoreRules[ruleName]} */
  16. const rule = (primary) => {
  17. return (root, result) => {
  18. const validOptions = validateOptions(result, ruleName, { actual: primary });
  19. if (!validOptions) {
  20. return;
  21. }
  22. root.walkComments((comment) => {
  23. // To ignore non-standard comments
  24. if (!isStandardSyntaxComment(comment)) {
  25. return;
  26. }
  27. // To ignore comments that are not empty
  28. if (comment.text && comment.text.length !== 0) {
  29. return;
  30. }
  31. report({
  32. message: messages.rejected,
  33. messageArgs: [],
  34. node: comment,
  35. result,
  36. ruleName,
  37. });
  38. });
  39. };
  40. };
  41. rule.ruleName = ruleName;
  42. rule.messages = messages;
  43. rule.meta = meta;
  44. module.exports = rule;