isBlocklessAtRuleAfterBlocklessAtRule.js 603 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const getPreviousNonSharedLineCommentNode = require('./getPreviousNonSharedLineCommentNode');
  3. const hasBlock = require('./hasBlock');
  4. const { isAtRule } = require('./typeGuards');
  5. /**
  6. * @param {import('postcss').AtRule} atRule
  7. * @returns {boolean}
  8. */
  9. module.exports = function isBlocklessAtRuleAfterBlocklessAtRule(atRule) {
  10. if (atRule.type !== 'atrule') {
  11. return false;
  12. }
  13. const previousNode = getPreviousNonSharedLineCommentNode(atRule);
  14. if (previousNode === undefined) {
  15. return false;
  16. }
  17. return isAtRule(previousNode) && !hasBlock(previousNode) && !hasBlock(atRule);
  18. };