util-flow-indent-check.js 494 B

123456789101112131415
  1. import { containsNewline } from './util-contains-newline.js';
  2. function flowIndentCheck(indent, fc, onError) {
  3. if (fc?.type === 'flow-collection') {
  4. const end = fc.end[0];
  5. if (end.indent === indent &&
  6. (end.source === ']' || end.source === '}') &&
  7. containsNewline(fc)) {
  8. const msg = 'Flow end indicator should be more indented than parent';
  9. onError(end, 'BAD_INDENT', msg, true);
  10. }
  11. }
  12. }
  13. export { flowIndentCheck };