1.0.4 • Published 3 years ago
monaco-html-linter v1.0.4
Monaco HTML Linter
Monaco HTML Linter is a simple HTML Linter plugin for the Monaco Editor. It uses HTMLHint under the hood to verify HTML Code.
Installation
npm i monaco-html-linterUsage
import monaco, { editor } from 'monaco-editor';
import HTMLMonacoLinter from 'monaco-html-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: 'html code here ...',
language: 'html'
});
const linter = new HTMLMonacoLinter(editor, monaco);
linter.watch();You can get the linter response in this way :
import { HTMLMonacoMarks } from 'monaco-html-linter';
//...
const htmlCode = editor.getValue();
const report = new HTMLMonacoMarks(htmlCode);
const response = report.getLinterResponse();API
Class: HTMLMonacoLinter(editor: editor.IStandaloneCodeEditor, monaco: Monaco, ruleset?: Ruleset)
Attributes
editor: editor.IStandaloneCodeEditorThe object returned when you create an editor.monaco: typeof monacoThe monaco variable.ruleset?: RulesetHTMLHint ruleset options.
Methods
lint() => void: Lint one time theeditor.watch() => void: Lint theeditoreach time theonChangeevent is triggered.
Class: HTMLMonacoMarks(html: string, ruleset: Ruleset = defaultRuleset, model?: editor.ITextModel)
Attributes
html: stringThe codoe to verify.ruleset: RulesetHTMLHint ruleset options.linterResponse: Hint[]Value returned by HTMLHint.model?: editor.ITextModel
Methods
getEditorMarks(monaco: Monaco): IMarkerData[]Return the monaco markers.getLinterResponse(): Hint[]lint(): Hint[]
License
MIT, see the LICENSE file for detail.