Hello people of Gaia,
Bug 937431 [1] is waiting a review+ to land, so now is a good time to
explain you the (hopefully good) changes this bug will give.
The README at [2] gives all information but here is an abstract.
Goals
====
The first goal of this work is to absolutely not disturb you from what
you're currently doing. That means that for existing files that don't
pass jshint, nothing changes.
The second goal of this work is to slowly move to jshint to lint our files.
Gjslint or jshint ?
==========
So we took the list of the existing files that don't pass jshint, and
we've put it in a file. When you commit some file, or when you run "make
lint", or when travis is running the "linters" job, we look into this
list and if your file is part of this list, we use gjslint to lint it.
Otherwise, we use jshint.
This also means that all new files will by default use jshint as linter.
Obviously, the goal is to make this list shrink until it's empty. So
here's the deal: if you remove a line from this list (which means this
file either was deleted or is passing jshint), you can commit. But if
you add a line to this list (which means a new file does not pass
jshint), then I'd like that you take 10 minutes to fix whatever is wrong
in this file.
jshint configuration
============
Intentionally, the main .jshintrc (the jshint configuration file) has
stricter rules than what you're used to with gjslint. Especially:
* you need 'use strict'; in all files
* it triggers an error when you're using a variable that is not defined
in this scope (eg: globals). You can define globally (ah ah) for your
app or subdirectories the globals that you can use.
* it requires braces even for one-line loops and if-blocks
See the README file [2] to fix these.
Overriding rules for some directories
====================
There is a Really Good Thing in the current version of jshint: you can
put a .jshintrc file in a directory and it will be used instead of the
main configuration file when jshint will lint files in this directory.
And you can also extend (inherit) from another .jshintrc file. So that
makes it very easy to use the main .jshintrc file and relax or stricten
some of the rules, or add predefined globals.
I already added those overriding rules for unit and marionette tests, in
all existing directories.
If you have other questions or suggestions, please ask! This is your
tool, use it to improve the quality of Gaia!
[1]
https://bugzilla.mozilla.org/show_bug.cgi?id=937431
[2]
https://github.com/julienw/gaia/blob/937431-jshint-hook/build/jshint/README.md
(will be in
https://github.com/mozilla-b2g/gaia/blob/master/build/jshint/README.md
after landing)
--
Julien