gecko-dev/tools/lint/docs/usage.rst
Andrew Halberstadt 3c8be23f37 Bug 1281899 - [mozlint] Add ability to lint files touched by revisions and/or the working directory, r=smacleod
This adds two parameters, --rev and --workdir. Each works both with mercurial and git (though the syntax for
specifying revisions is different between them). The value is simply forwarded to either |hg log| or |git diff|
so syntax like |mach lint -r .~4::.| or |mach lint -r "HEAD~4 HEAD"| will work as expected.

MozReview-Commit-ID: aOGp2Yrncs

--HG--
extra : rebase_source : d2cb834d4cc1a083171a3551af4e72c8a7d14021
2016-06-24 14:09:58 -04:00

41 lines
1.3 KiB
ReStructuredText

Running Linters Locally
=======================
You can run all the various linters in the tree using the ``mach lint`` command. Simply pass in the
directory or file you wish to lint (defaults to current working directory):
.. parsed-literal::
./mach lint path/to/files
Multiple paths are allowed:
.. parsed-literal::
./mach lint path/to/foo.js path/to/bar.py path/to/dir
``Mozlint`` will automatically determine which types of files exist, and which linters need to be run
against them. For example, if the directory contains both JavaScript and Python files then mozlint
will automatically run both ESLint and Flake8 against those files respectively.
To restrict which linters are invoked manually, pass in ``-l/--linter``:
.. parsed-literal::
./mach lint -l eslint path/to/files
Finally, ``mozlint`` can lint the files touched by a set of revisions or the working directory using
the ``-r/--rev`` and ``-w/--workdir`` arguments respectively. These work both with mercurial and
git. In the case of ``--rev`` the value is passed directly to the underlying vcs, so normal revision
specifiers will work. For example, say we want to lint all files touched by the last three commits.
In mercurial, this would be:
.. parsed-literal::
./mach lint -r ".~2::."
In git, this would be:
.. parsed-literal::
./mach lint -r "HEAD~2 HEAD"