UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

32 lines 1.11 kB
import { linter } from "@codemirror/lint"; import { JSHINT as jshint } from "jshint"; var lintOptions = { esversion: 11, browser: true, }; /** * Sets up the javascript linter. Documentation: https://codemirror.net/examples/lint/ */ export var jsLinter = function () { return linter(function (view) { var _a; var diagnostics = []; var codeText = view.state.doc.toJSON(); jshint(codeText, lintOptions); var errors = (_a = jshint === null || jshint === void 0 ? void 0 : jshint.data()) === null || _a === void 0 ? void 0 : _a.errors; if (errors && errors.length > 0) { errors.forEach(function (error) { var selectedLine = view.state.doc.line(error.line); var diagnostic = { from: selectedLine.from, to: selectedLine.to, severity: "error", message: error.reason, }; diagnostics.push(diagnostic); }); } return diagnostics; }); }; //# sourceMappingURL=jsLinter.js.map