isStandardSyntaxAtRule.js 768 B

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