isStandardSyntaxAtRule.cjs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. /**
  5. * Check whether a at-rule is standard
  6. *
  7. * @param {import('postcss').AtRule | import('postcss-less').AtRule} atRule postcss at-rule node
  8. * @returns {boolean} If `true`, the declaration is standard
  9. */
  10. function isStandardSyntaxAtRule(atRule) {
  11. // Ignore `@charset` css rule (is parsed as at-rule)
  12. if (atRule.name.toLowerCase() === 'charset') {
  13. return false;
  14. }
  15. // Ignore scss `@content` inside mixins
  16. if (!atRule.nodes && atRule.params === '') {
  17. return false;
  18. }
  19. // Ignore Less mixins
  20. if ('mixin' in atRule && atRule.mixin) {
  21. return false;
  22. }
  23. // Ignore Less detached ruleset `@detached-ruleset: { background: red; }; .top { @detached-ruleset(); }`
  24. if (
  25. ('variable' in atRule && atRule.variable) ||
  26. (!atRule.nodes && atRule.raws.afterName === '' && atRule.params[0] === '(')
  27. ) {
  28. return false;
  29. }
  30. return true;
  31. }
  32. module.exports = isStandardSyntaxAtRule;