Monaco JS Linter is a simple JavaScript Linter plugin for the Monaco Editor. It uses jsHint under the hood to verify JavaScript Code.
npm i monaco-js-linter
import monaco, { editor } from 'monaco-editor';
import JSMonacoLinter from 'monaco-js-linter';
// The Monaco Editor can be easily created, given an
// empty container and an options literal.
// Two members of the literal are "value" and "language".
// The editor takes the full size of its container.
const editor = monaco.editor.create(document.getElementById('container'), {
value: 'js code here ...',
language: 'javascript',
});
const linter = new JSMonacoLinter(editor, monaco);
linter.watch();
You can get the linter response in this way :
import { JSMonacoMarks } from 'monaco-js-linter';
//...
const jsCode = editor.getValue();
const report = new JSMonacoMarks(jsCode);
const response = report.getLinterResponse();
editor: editor.IStandaloneCodeEditor
The object returned when you create an editor.monaco: typeof monaco
The monaco variable.options?: LintOptions
ESHINT options.
lint
() => void: Lint one time theeditor
.watch
() => void: Lint theeditor
each time theonChange
event is triggered.
html: string
The codoe to verify.options: LintOptions
JSHINT options.linterResponse: LintData
Value returned by JSHINT.
getEditorMarks(monaco: Monaco): IMarkerData[]
Return the monaco markers.getLinterResponse(): LintData
lint(): LintData
MIT, see the LICENSE file for detail.