Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat: json linter support for codemirror
Andrew Bastin12cd7940c6c8
diff --git a/helpers/editor/linting/json.ts b/helpers/editor/linting/json.tsnew file mode 100644index 000000000..46a690197--- /dev/null+++ b/helpers/editor/linting/json.ts@@ -0,0 +1,21 @@+import { convertIndexToLineCh } from "../utils"+import { LinterDefinition, LinterResult } from "./linter"+import jsonParse from "~/helpers/jsonParse"++const linter: LinterDefinition = (text) => {+ try {+ jsonParse(text)+ return Promise.resolve([])+ } catch (e: any) {+ return Promise.resolve([+ <LinterResult>{+ from: convertIndexToLineCh(text, e.start),+ to: convertIndexToLineCh(text, e.end),+ message: e.message,+ severity: "error",+ },+ ])+ }+}++export default linter