You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

There are two tools that will greatly improve the quality of the code in the JS framework, if used consistently. They are: gjslint and JSHint.

gjslint

gjslint is the linter that comes with the Google Closure Tools. You can download it from here and get instructions on how to install and use it.

gjslint is a command line tool. The proper use for FlexJS is:

gjslint --strict --disable 0100 -r ./

FlexJS uses the --disable command because it's interface handling relies on a variable on the prototype that is initialised with a 'non primitive' value. You might want to check occasionally with this argument removed, to make sure no actual errors are hidden behind it.

JSHint

JSHint is a fork of the original JavaScript linter, JSLint. JSHint is still under active development and has gathered an amazing feature set over the years. Read all about it here.

In order to check a class against JSHint, copy the code below to the top of the file and then either copy-paste the entire contents (with the new 'header') to the online linter, or run the linter from the editor or command line tool.

/*jshint
    globalstrict: true,
    indent: 2,
    maxlen: 120,
    strict: true,
    white: false */
/*global goog, org */

'use strict';

FlexJS uses 'maxlen 120' to avoid a warning for long lines caused by long 'goog.require' statements. 'gjslint' takes care of the 80 char enforcement.

  • No labels