@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
36 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.jsLinter = void 0;
const lint_1 = require("@codemirror/lint");
const jshint_1 = require("jshint");
const lintOptions = {
esversion: 11,
browser: true,
};
/**
* Sets up the javascript linter. Documentation: https://codemirror.net/examples/lint/
*/
const jsLinter = () => {
return (0, lint_1.linter)((view) => {
var _a;
const diagnostics = [];
const codeText = view.state.doc.toJSON();
(0, jshint_1.JSHINT)(codeText, lintOptions);
const errors = (_a = jshint_1.JSHINT === null || jshint_1.JSHINT === void 0 ? void 0 : jshint_1.JSHINT.data()) === null || _a === void 0 ? void 0 : _a.errors;
if (errors && errors.length > 0) {
errors.forEach((error) => {
const selectedLine = view.state.doc.line(error.line);
const diagnostic = {
from: selectedLine.from,
to: selectedLine.to,
severity: "error",
message: error.reason,
};
diagnostics.push(diagnostic);
});
}
return diagnostics;
});
};
exports.jsLinter = jsLinter;
//# sourceMappingURL=jsLinter.js.map