Giter Club home page Giter Club logo

monaco-js-linter's Introduction

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-linter

Usage

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.IStandaloneCodeEditor The object returned when you create an editor.
  • monaco: typeof monaco The monaco variable.
  • options?: LintOptions ESHINT options.

Methods

  • lint () => void: Lint one time the editor.
  • watch () => void: Lint the editor each time the onChange event is triggered.

Class: JSMonacoMarks(js: string, options?: LintOptions)

Attributes

  • html: string The codoe to verify.
  • options: LintOptions JSHINT options.
  • linterResponse: LintData Value returned by JSHINT.

Methods

  • getEditorMarks(monaco: Monaco): IMarkerData[] Return the monaco markers.
  • getLinterResponse(): LintData
  • lint(): LintData

License

MIT, see the LICENSE file for detail.

monaco-js-linter's People

Contributors

arnaudpfu avatar

Stargazers

sbin avatar  avatar Cristian Adán avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.