tern-lint provides :
- the tern lint plugin
lint.js
to validate JS files. - the CodeMirror lint addon
tern-lint.js
which uses tern lint pluginlint.js
See Integration for more information to integrate the tern lint plugin in your editor.
Here a screenshot with tern lint and CodeMirror :
If you are Eclipse user, you can use the tern lint.js too. See Tern IDE & Validation
See tern-lint.el for more information.
If you wish to integrate the tern lint with an editor (vim, etc), here the JSON request to post to the tern server :
{
"query": {
"type": "lint",
"file": "test.js",
"files": [
{
"name": "test.js",
"text": "var elt = document.getElementByIdXXX('myId');",
"type": "full"
}
]
}
}
and the JSON response of the tern server :
{
"messages": [
{
"message": "Unknow property 'getElementByIdXXX'",
"from": 19,
"to": 36,
"severity": "warning"
}
]
}
tern lint validate JS files but not syntax errors, it manages those validation rules :
- unknown property. (ex : document.getElementByIdXXX where getElementByIdXXX is an unknown property of document)
- unknown identifier. (ex : a = '' where a is an unknown identifier)
- not a function (ex : var a = []; a.length() is not valid because length of array is not a function)
- invalid argument (ex : document.getElementById(1000) is not valid because 1000 is a number and not a string)
See Validation rules for more informations.
The basic structure of the project is given in the following way:
demos/
demos with tern lint plugin which use CodeMirror.codemirror/
contains the CodeMirror lint addontern-lint.js
, which is an implementation of CodeMirror lint addon with tern.lint.lint.js/
the tern lint plugin.test/
contains test of tern lint plugin.