Last updated
Last updated
For JavaScript code we use both:
- linting tool
- formatting tool
These tools can be used via the command line or right in your code editor.
After editing some JavaScript code, navigate to the comm/
directory. (The following commands need to be run from the comm/
directory so that Prettier will use the comm/.prettierignore
file, and not the .prettierignore
file in the directory just above comm/
. See .)
For a single file, run this command, which will attempt to automatically fix any linting or formatting problems:
Or for all the files in a given directory:
To simply report any problems but not attempt to automatically fix them, just omit the --fix
flag:
Most popular code editors offer plugins for eslint and Prettier. We highly recommend installing a plugin for eslint and a plugin for Prettier so you can lint and format your code as you are editing it. Issues will be highlighted as you type and you can have Prettier format your code with a few key strokes.
Here are links to plugins for various editors:
for various editors
for various editors
Some of us on the Thunderbird team use the VS Code editor with these plugins:
VS Code plugin by Esben Petersen
VS Code plugin by Dirk Baeumer
Using ESLint to Format Javascript Code