feat: linting for raw key value lang editors

This commit is contained in:
Andrew Bastin
2022-02-16 01:37:15 +05:30
parent c3759a400d
commit 4d5a90f14f
4 changed files with 30 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
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 + 1)
return Promise.resolve([
<LinterResult>{
from: pos,
to: pos,
message: result.left.message,
severity: "error",
},
])
} else {
return Promise.resolve([])
}
}
export default linter