LogoLogo
  • About Thunderbird
  • Contributing to Thunderbird
    • Getting Started Contributing
    • Setting Up A Build Environment
    • Building Thunderbird
      • Windows Build Prerequisites
      • Linux Build Prerequisites
      • macOS Build Prerequisites
      • Artifact Builds
    • Codebase Overview
      • Account Configuration
      • Address Book
      • Chat Core
        • Notifications
        • Message Styles
        • Keyboard shortcuts
        • Chat Core Protocols
        • Contacts
      • Mail Front-End
    • Tutorials and Examples
      • Hello World Example
      • Thunderbird Live Development Videos
    • Fixing a Bug
      • Bug Triaging 101
        • Bug Status Classicification
        • Bug Types
        • Garbage Collection
        • Narrow the Scope
      • Using Mercurial Bookmarks
      • Using Mercurial Queues
      • Lint and Format Code
      • Using ESLint to Format Javascript Code
      • Try Server
      • Landing a Patch
      • Care and Feeding of the Tree
    • Testing
      • Running Tests
      • Adding Tests
      • Writing Mochitest Tests
  • Planning
    • Roadmap
    • Android Roadmap
    • Supported Standards
  • Add-on Development
    • Introduction
    • What's new?
      • Manifest Version 3
    • A "Hello World" Extension Tutorial
      • Using WebExtension APIs
      • Using a Background Page
      • Using Content Scripts
    • A Guide to Extensions
      • Supported Manifest Keys
      • Supported UI Elements
      • Supported WebExtension APIs
      • Thunderbird's WebExtension API Documentation
      • Thunderbird WebExtension Examples
      • Introducing Experiments
    • A Guide to Themes
    • Developer Community
    • Documentation & Resources
      • Tips and Tricks
    • Add-on Update Guides
      • Update for Thunderbird 128
      • Update for Thunderbird 115
        • Adapt to Changes in Thunderbird 103-115
      • Update for Thunderbird 102
        • Adapt to Changes in Thunderbird 92-102
      • Update for Thunderbird 91
        • Adapt to Changes in Thunderbird 79-91
      • Update for Thunderbird 78
        • Adapt to Changes in Thunderbird 69-78
      • Update for Thunderbird 68
        • Adapt to Changes in Thunderbird 61-68
      • How to convert legacy extensions?
        • Convert wrapped WebExtensions to modern WebExtensions
        • Convert legacy WebExtensions to modern WebExtensions
        • Convert legacy overlay extension to legacy WebExtension
        • Convert legacy bootstrapped extension to legacy WebExtension
  • Releases
    • Thunderbird Channels
    • Release Cadence
    • Uplifting Fixes
    • Feature Flags
    • Tracking Fixes for Releases
    • Contributing to Release Notes
Powered by GitBook
On this page
  • Via the Command Line
  • In a Code Editor
  • More Details

Was this helpful?

Edit on GitHub
Export as PDF
  1. Contributing to Thunderbird
  2. Fixing a Bug

Using ESLint to Format Javascript Code

Using ESLint to Format Javascript Code

PreviousLint and Format CodeNextTry Server

Last updated 4 years ago

Was this helpful?

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.

Via the Command Line

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:

$ ../mach lint path/to/a/file.js --fix

Or for all the files in a given directory:

$ ../mach lint path/to/a/directory/ --fix

To simply report any problems but not attempt to automatically fix them, just omit the --fix flag:

$ ../mach lint path/to/a/file.js

In a Code Editor

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

More Details

eslint
Prettier
Prettier issue 4081
eslint plugins
Prettier plugins
Prettier - Code formatter
ESLint
'Linting' on firefox-source-docs
'Formatting JS Code With Prettier and eslint' on MDN