function getHeader()

in packages/flow-dev-tools/src/flowResult.js [176:203]


function getHeader(
  mainLoc: ?FlowLoc,
  kind: string,
  level: string,
): Array<FlowMessage> {
  let line = -1;
  let filename = '[No file]';
  if (mainLoc != null) {
    const {source, start} = mainLoc;
    line = start.line;
    if (source != null) {
      filename = source;
    }
  }

  let prefix = '';
  if (kind == 'internal' && level == 'error') {
    prefix = 'Internal error (see logs):\n';
  } else if (mainLoc != null && mainLoc.type == 'LibFile') {
    if (kind == 'parse' && level == 'error') {
      prefix = 'Library parse error:\n';
    } else if (kind == 'infer') {
      prefix = 'Library type error:\n';
    }
  }

  return [mkComment(format('%s%s:%d', prefix, filename, line))];
}