export function parseResult()

in common/output.ts [106:130]


export function parseResult(
  result: Result,
  rules: Map<string, Rule>
): ProblemDescriptor | null {
  if (
    !result.locations ||
    result.locations.length === 0 ||
    !result.locations[0].physicalLocation
  ) {
    return null
  }
  return {
    title: rules.get(result.ruleId!)?.shortDescription,
    level: (() => {
      switch (result.level) {
        case 'error':
          return FAILURE_LEVEL
        case 'warning':
          return WARNING_LEVEL
        default:
          return NOTICE_LEVEL
      }
    })()
  }
}