Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

619 B
Raw Blame
import * as E from "fp-ts/Either"
import { strictParseRawKeyValueEntriesE } from "@hoppscotch/data"
import { convertIndexToLineCh } from "../utils"
import { LinterDefinition, LinterResult } from "./linter"

const linter: LinterDefinition = (text) => {
  const result = strictParseRawKeyValueEntriesE(text)
  if (E.isLeft(result)) {
    const pos = convertIndexToLineCh(text, result.left.pos)

    return Promise.resolve([
      <LinterResult>{
        from: pos,
        to: pos,
        message: result.left.message,
        severity: "error",
      },
    ])
  }
  return Promise.resolve([])
}

export default linter