util-flow-indent-check.js 547 B

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