isBlocklessAtRuleAfterSameNameBlocklessAtRule.js 666 B

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