Skip to content
Angelo edited this page Sep 9, 2015 · 4 revisions

Tern & Validation

tern-lint provides the lint.js Tern plugin which is enable to validate your JS files. Please note, that this lint.js is experimetal.

Please read Validation Rules to know what this tern lint is able to validate.

After installing and converting your project as Tern Project, go at Tern project property, you can check the lint plugin.

Check Lint Plugin

Validation sample with browser

In the following sample, we have checked browser tern definition :

Check browser Def

Here sample validation with document#getElementById. If you use known property :

var elt = document.getElementById('myId');

you will see no warnings :

Lint no warnings

If you use unknown property :

var elt = document.getElementByIdXXX('myId');

you will see the Unknown property 'getElementByIdXXX' warning :

Lint warnings

Validation sample with YUI

Validation works too with Tern plugin. In the following sample, we have checked YUI tern plugin :

Check YUI plugin

Here sample validation with YUI()#use. If you use known property :

YUI().use('node', function(Y) {
	Y.
});

you will see no warnings :

Lint no warnings with YUI

You can notice, that completion is available for the Y instance.

If you use unknown property :

YUI().useXXX('node', function(Y) {
	Y.
});

you will see the Unknown property 'useXXX' warning :

Lint warnings with YUI

You can notice, that completion is not available for the Y instance.

Validate with JSDoc

Please read here

Clone this wiki locally