isStandardSyntaxAtRule.js 752 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. /**
  3. * Check whether a at-rule is standard
  4. *
  5. * @param {import('postcss').AtRule | import('postcss-less').AtRule} atRule postcss at-rule node
  6. * @return {boolean} If `true`, the declaration is standard
  7. */
  8. module.exports = function isStandardSyntaxAtRule(atRule) {
  9. // Ignore scss `@content` inside mixins
  10. if (!atRule.nodes && atRule.params === '') {
  11. return false;
  12. }
  13. // Ignore Less mixins
  14. if ('mixin' in atRule && atRule.mixin) {
  15. return false;
  16. }
  17. // Ignore Less detached ruleset `@detached-ruleset: { background: red; }; .top { @detached-ruleset(); }`
  18. if (
  19. ('variable' in atRule && atRule.variable) ||
  20. (!atRule.nodes && atRule.raws.afterName === '' && atRule.params[0] === '(')
  21. ) {
  22. return false;
  23. }
  24. return true;
  25. };