is-empty-node.js 357 B

1234567891011121314151617181920
  1. 'use strict';
  2. function isEmptyNode(node, additionalEmpty) {
  3. const {type} = node;
  4. if (type === 'BlockStatement') {
  5. return node.body.every(currentNode => isEmptyNode(currentNode, additionalEmpty));
  6. }
  7. if (type === 'EmptyStatement') {
  8. return true;
  9. }
  10. if (additionalEmpty?.(node)) {
  11. return true;
  12. }
  13. return false;
  14. }
  15. module.exports = isEmptyNode;