Lint and Format Code
How to lint and format code.
Thunderbird's source code is linted and formatted using automated tools, which provides several benefits that include:
- ensuring a consistent formatting style across the code base
- preventing formatting issues from taking up developer time in code review
- catching problems that might otherwise go unnoticed
- making it easier for developers to write well-formatted code
Mozlint is a library that standardizes linter configuration and provides an interface for running all linters at once. It is run via mach and is run automatically by Taskcluster.
You can run all the various linters in the tree using the
mach commlintcommand. Simply pass in the directory or file you wish to lint (defaults to current working directory):
../mach commlint path/to/files
It works the same as regular
mach lint, however it has Thunderbird configs pre-applied. If you're not familiar with using
mach linton Firefox code, see the Firefox Linting documentation to get started.
The Mozlint configuration files in
comm/tools/lintare written so that they can be shared with the Seamonkey project. Thunderbird developers may want to set
MOZLINT_NO_SUITE=1in their environment so
mach commlintwill not check
comm/suite/. Taskcluster will also set
MOZLINT_NO_SUITEwhen running lint checks.
Several mozlint-based checks run automatically on Taskcluster, and more are being added. The Firefox Linting documentation is a valuable resource if you're seeing errors on your try builds. If you are not sure how to run a check locally, the mach commands run by Taskcluster are in