index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. const atRuleNameSpaceChecker = require('../atRuleNameSpaceChecker');
  3. const ruleMessages = require('../../utils/ruleMessages');
  4. const validateOptions = require('../../utils/validateOptions');
  5. const whitespaceChecker = require('../../utils/whitespaceChecker');
  6. const ruleName = 'at-rule-name-newline-after';
  7. const messages = ruleMessages(ruleName, {
  8. expectedAfter: (name) => `Expected newline after at-rule name "${name}"`,
  9. });
  10. const meta = {
  11. url: 'https://stylelint.io/user-guide/rules/list/at-rule-name-newline-after',
  12. };
  13. /** @type {import('stylelint').Rule} */
  14. const rule = (primary) => {
  15. const checker = whitespaceChecker('newline', primary, messages);
  16. return (root, result) => {
  17. const validOptions = validateOptions(result, ruleName, {
  18. actual: primary,
  19. possible: ['always', 'always-multi-line'],
  20. });
  21. if (!validOptions) {
  22. return;
  23. }
  24. atRuleNameSpaceChecker({
  25. root,
  26. result,
  27. locationChecker: checker.afterOneOnly,
  28. checkedRuleName: ruleName,
  29. });
  30. };
  31. };
  32. rule.ruleName = ruleName;
  33. rule.messages = messages;
  34. rule.meta = meta;
  35. module.exports = rule;