This is a cache of https://developer.ibm.com/articles/auto-fix-and-format-your-javascript-with-eslint/. It is a snapshot of the page as it appeared on 2025-11-15T03:51:55.359+0000.
Auto-fix and format your JavaScript with ESLint - IBM Developer
When it comes to analyzing JavaScript program errors, ESLint is one of the best linting tools available. ESLint provides checks for a large set of potential errors and style violations. Its pluggable architecture also enables anyone to write their own rules and custom configurations.
One of my favorite features is the ability to auto-fix using the --fix flag. Integrating auto-fix provides constant feedback by cleaning up mistakes and keeping code clean before you check it in to a repository. This saves time for you and your team when reviewing code by ensuring that the code contributed doesn't require little clean ups.
I like to do this cleanup right away whenever I save a file in my editor. It provides a quick feedback loop and persists the fixed changes to disk. In this article, I am going to show you how to do that as well for some popular editors.
Note: This is not a tutorial on how to use ESLint, I assume you already are familiar with the tool. If you need help getting started with ESLint, check out the Getting Started guide first before continuing.
Installing ESLint
You can install ESLint locally for a given project (inside node_modules) or globally for all projects. We will use a local ESLint install for this tutorial, but most of these will work for a global install as well.
npm install eslint --dev
copy codecopied!
VS code
For VS code, install the ESLint package. Then, to format on save, go to global settings and search for ESLint and turn on the ESLint: Auto Fix On Save option.
Atom
For Atom, install the linter-eslint package and any dependencies. Then, go to the plug-in settings and check Fix errors on save.
Sublime Text
For Sublime, using Package control, install the ESLint-Formatter package. Then, to format on save, add the following to the Preferences -> Package Settings -> ESLint-Formatter -> Settings -- User file:
{"format_on_save":true}
copy codecopied!
Vim/NeoVim
For Vim users, add the ale package using your preferred packaging tool like vim-plug or Vundle to your $MYVIMRc:
" vim-plug
Plug w0rp/ale
" Vundle
Plugin w0rp/ale
copy codecopied!
Then, enable auto-fix on save by setting the following configuration:
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review yourcookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.