liuliangsir / codemirror-lint-eslint

CodeMirror Lint addon to use ESLint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


codemirror-lint-eslint provides the lint.js, which is a CodeMirror addon to use CodeMirror Lint with ESLint. In addition, You can play with the demo index.html, which validate JavaScript content of a CodeMirror editor with ESLint

How to use it

To use lint.js, you must declare your CodeMirror instance with javascript mode, and activate lint (gutters & lint to true) like this :

var editor = CodeMirror.fromTextArea(document.getElementById("code-js"), {
    lineNumbers: true,
    mode: "javascript",
    gutters: ["CodeMirror-lint-markers"],
    lint: true

and include several scripts (see index.html to see the full scripts and CSS to include).

  • Codemirror :
<link rel=stylesheet href="./lib/codemirror/doc/docs.css">
<link rel="stylesheet" href="./lib/codemirror/lib/codemirror.css">
<script src="./lib/codemirror/lib/codemirror.js"></script>
  • JavaScript mode
<script src="./lib/codemirror/mode/javascript/javascript.js"></script>
  • Lint interface
<link rel="stylesheet" href="./lib/codemirror/addon/lint/lint.css">
<script src="./lib/codemirror/addon/lint/lint.js"></script>
  • Lint implementation with ESLint
<script src="./src/lint.js"></script>


The basic structure of the project is given in the following way:

  • src/app.js the entry point for whole application
  • src/lint.js the CodeMirror Lint addon which uses ESLint.
  • index.html the demo which uses ESLint with CodeMirror editor.
  • lib folder which contains CodeMirror.


CodeMirror Lint addon to use ESLint

License:MIT License


Language:CSS 62.1%Language:HTML 20.2%Language:JavaScript 17.7%