1.0.2 • Published 3 years ago
monaco-js-linter v1.0.2
Monaco JS Linter
Monaco JS Linter is a simple JavaScript Linter plugin for the Monaco Editor. It uses jsHint under the hood to verify JavaScript Code.
Installation
npm i monaco-js-linterUsage
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();API
Class: JSMonacoLinter(editor: editor.IStandaloneCodeEditor, monaco: Monaco, options?: LintOptions)
Attributes
editor: editor.IStandaloneCodeEditorThe object returned when you create an editor.monaco: typeof monacoThe monaco variable.options?: LintOptionsESHINT options.
Methods
lint() => void: Lint one time theeditor.watch() => void: Lint theeditoreach time theonChangeevent is triggered.
Class: JSMonacoMarks(js: string, options?: LintOptions)
Attributes
html: stringThe codoe to verify.options: LintOptionsJSHINT options.linterResponse: LintDataValue returned by JSHINT.
Methods
getEditorMarks(monaco: Monaco): IMarkerData[]Return the monaco markers.getLinterResponse(): LintDatalint(): LintData
License
MIT, see the LICENSE file for detail.