VSCode doesn't support chaining multiple formatters. More at this related question.

But chaining formatters isn't the answer to your problem. If you're using Prettier and ESLint properly then they do not overlap in their ruleset. You can use eslint-plugin-prettier to format the document with only ESLint and it will run Prettier as an ESLint rule. Adding eslint-config-prettier disables any ESLint rules that would conflict with Prettier.

Afterwards, running eslint --fix would apply both your ESLint and Prettier rules in a single format.

If you would like to use ESLint with other filetypes then you need to find ESLint plugins that work for those filetypes. They require installation and configuration unique to each plugin. An example is eslint-plugin-jsonc to add support for JSONC.

In package.json:

{
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^6.10.0",
    "@typescript-eslint/parser": "^6.10.0",
    "eslint": "^8.53.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.1",
    "prettier": "^3.0.3",
    "typescript": "^5.2.2"
  }
}

In .eslintrc.json:

{
  "extends": [
    "plugin:prettier/recommended" // must be last element in "extends"
  ],
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint"
  ],
  "settings": {
    "import/parsers": {
      "@typescript-eslint/parser": [
        ".ts"
      ]
    },
  }
}

Set your Prettier rules in .prettierrc.json, for example:

{
  "printWidth": 100
}

Now eslint --fix will format the document in a single pass.

For VSCode, install both the dbaeumer.vscode-eslint and the esbenp.prettier-vscode extensions. These each require you to have the corresponding npm package installed, whether locally in your app or globally on your device. You may also need to configure VSCode so that it can find the packages, depending on how they were installed.

Then when you run Format Document With and select ESLint it will apply both your ESLint and Prettier rules with the equivalent of eslint --fix. For example, leaving a trailing space will trigger this INFO alert:

Delete `·` eslint (prettier/prettier)

Formatting the document with ESLint resolves the issue.

Answer from anothermh on Stack Overflow
🌐
DigitalOcean
digitalocean.com › community › tutorials › linting-and-formatting-with-eslint-in-vs-code
How To Lint and Format Code with ESLint in Visual Studio Code | DigitalOcean
October 17, 2024 - ESLint is a linter that you can integrate into your Visual Studio Code setup in order to ensure code integrity. In this tutorial, you will set up ESLint on V…
🌐
GitHub
github.com › eslint › eslint › discussions › 18362
Linting in VSCode doesn't work, but CLI is fine · eslint/eslint · Discussion #18362
you can install the version, or using eslint.experimental.useFlatConfig: true as of now. Beta Was this translation helpful? Give feedback. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... Beta Was this translation helpful? Give feedback. ... Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Author   eslint
Discussions

How to Install ESLint in VS Code
I’m learning. I know very little. My questions might sound stupid. I’m taking a javascript tutorial. I’ve created an HTML file using VS Code which has js code in it. There is a problem with the js. I think it’s a syntax problem. I don’t know how to use VS Code to check syntax. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
January 1, 2025
Does ESLint come pre-installed with Vscode or do you need to download node in order to run npm to set it up?
You can run ESLint as a Vscode extension or via the command line (Node). Your choice. More on reddit.com
🌐 r/vscode
4
3
August 14, 2019
Run eslint every time page hot refreshes
I’d like the linter to warn me of issues as i code / preferably break the build and show a warning on chrome. (i.e. not have to periodically run ‘npm run lint’) i’ve achieved this in other projects using something like vite how can i do this for Meteor? struggling to find straightforward ... More on forums.meteor.com
🌐 forums.meteor.com
0
September 10, 2024
Help me understand why installing a plugin is not enough (ESLint)...
I proceed to install ESLinter OK, so you've chosen to use ESLint to lint your codebase. Have you followed the Getting Started page from ESLint's documentation? This gets you started with ESLint itself. You can use ESLint in many code editors. To use ESLint in VS Code you need to installed the extension for ESLint. Between the Getting Started and the instructions in the extension itself are you running into any further blockers or issues? More on reddit.com
🌐 r/vscode
5
3
October 21, 2021
Top answer
1 of 2
10

VSCode doesn't support chaining multiple formatters. More at this related question.

But chaining formatters isn't the answer to your problem. If you're using Prettier and ESLint properly then they do not overlap in their ruleset. You can use eslint-plugin-prettier to format the document with only ESLint and it will run Prettier as an ESLint rule. Adding eslint-config-prettier disables any ESLint rules that would conflict with Prettier.

Afterwards, running eslint --fix would apply both your ESLint and Prettier rules in a single format.

If you would like to use ESLint with other filetypes then you need to find ESLint plugins that work for those filetypes. They require installation and configuration unique to each plugin. An example is eslint-plugin-jsonc to add support for JSONC.

In package.json:

{
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^6.10.0",
    "@typescript-eslint/parser": "^6.10.0",
    "eslint": "^8.53.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.1",
    "prettier": "^3.0.3",
    "typescript": "^5.2.2"
  }
}

In .eslintrc.json:

{
  "extends": [
    "plugin:prettier/recommended" // must be last element in "extends"
  ],
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint"
  ],
  "settings": {
    "import/parsers": {
      "@typescript-eslint/parser": [
        ".ts"
      ]
    },
  }
}

Set your Prettier rules in .prettierrc.json, for example:

{
  "printWidth": 100
}

Now eslint --fix will format the document in a single pass.

For VSCode, install both the dbaeumer.vscode-eslint and the esbenp.prettier-vscode extensions. These each require you to have the corresponding npm package installed, whether locally in your app or globally on your device. You may also need to configure VSCode so that it can find the packages, depending on how they were installed.

Then when you run Format Document With and select ESLint it will apply both your ESLint and Prettier rules with the equivalent of eslint --fix. For example, leaving a trailing space will trigger this INFO alert:

Delete `·` eslint (prettier/prettier)

Formatting the document with ESLint resolves the issue.

2 of 2
1

This bugged me ALOT as well. There are a lot of resources online about different ways. The problem is most of them are outdated, don't work, require some config adjustments, and have their own set of trade-offs.

Here was the solution I ended up going with:

I just added this to my users keybindings.json:

{
    "key": "cmd+alt+f",
    "command": "workbench.action.terminal.sendSequence",
    "args": {
        "text": "npx prettier --write '${file}' > /dev/null 2>&1 && npx eslint_d --fix '${file}' > /dev/null 2>&1 & \u000D" // The CLI command to run "\u000D" is just the return key.
    },
    "when": "editorTextFocus"
},

That command uses eslint_d but thats just a performance enhancement. You could just as easily use eslint instead.

If you want to get it to run on save. You can try vscode-run-on-save

The benefit of this was it just works across any flavor of vscode like cursor, windsurf, etc. I don't have to muck with configs or any other setup.

Hope this helps someone else :).

🌐
freeCodeCamp
forum.freecodecamp.org › javascript
How to Install ESLint in VS Code
January 1, 2025 - I’m learning. I know very little. My questions might sound stupid. I’m taking a javascript tutorial. I’ve created an HTML file using VS Code which has js code in it. There is a problem with the js. I think it’s a s…
🌐
DEV Community
dev.to › muratcanyuksel › quick-eslint-guide-vscode-eslint-on-save-3ik0
Quick ESLint guide + VsCode ESLint on save - DEV Community
July 11, 2021 - On VsCode, go to preferences-settings-extensions-eslint ( you can search for ESLint once in the settings and do not forget to click on Workspace because that's where we're gonna change the settings) and there, on the right top of the page, you'll ...
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
ESLint - Visual Studio Marketplace
Extension for Visual Studio Code - Integrates ESLint JavaScript into VS Code.
Find elsewhere
🌐
Dave Ceddia
daveceddia.com › vscode-use-eslintrc
ESLint + VSCode: How to Format Your Code Using .eslintrc
April 7, 2021 - In VSCode, open the extension browser with the button on the left. On the Mac, the keyboard shortcut Cmd+Shift+X should do the same. ... Install the top result, called “ESLint”. (It’s this one with over 10 million downloads)
🌐
hypno_scripts
hypno.hashnode.dev › typescript-made-easy-setting-up-eslint-in-vscode
TypeScript Made Easy: Setting Up ESLint in VSCode
April 8, 2023 - 2. Open VSCode and go to the Extensions view by pressing Ctrl + Shift + X (Windows/Linux) or Cmd + Shift + X (macOS). 3. Search for "ESLint" and click on the "Install" button to install the extension.
🌐
Medium
medium.com › @jeryldev › a-beginners-story-how-to-setup-eslint-in-a-visual-studio-code-project-28b379a33cdb
How to set up ESLint in a Visual Studio Code project — my 5 minute story | by Jeryl Donato Estopace | Medium
December 31, 2018 - Since I have installed the ESLint extension, I went to VS Code’s Command Palette by pressing Ctrl + Shift + P, and then ran ‘ESLint: Fix all auto-fixable Problems’. This command applies ESLint auto-fix resolutions to all fixable problems.
🌐
Stanley Ulili
stanleyulili.com › javascript › how-to-set-up-eslint-globally-with-vscode
How to Set Up ESLint Globally with VSCode
September 16, 2019 - Now that we have our .eslintrc file created, let's setup ESLint with VSCode. Tip: Even without a code editor, you can be able to lint a javascript file anywhere in a project by typing eslint filename.js. It will display the errors in the terminal, it can come in handy sometimes.
🌐
ESLint
eslint.org › docs › latest › use › getting-started
Getting Started with ESLint
Before you begin, you must already have a package.json file. If you don’t, make sure to run npm init or yarn init to create the file beforehand.
🌐
LaunchCode
education.launchcode.org › gis-devops › configurations › 06-vscode-eslint › index.html
Configuration: Visual Studio Code - ESLint — LaunchCode: GIS DevOps documentation
After we set this up, we won’t have to save and re-run $ npm test. Open Visual Studio Code (if you don’t have it, you should use $npm test to lint your code) ... You only have to open the /airwaze-project/src/main/resources folder, because that is where the js and eslint files are
🌐
Expo Documentation
docs.expo.dev › integrations › tools › using eslint and prettier
Using ESLint and Prettier - Expo Documentation
2 weeks ago - If you're using VS Code, install the ESLint extension to lint your code as you type. You can try restarting the ESLint server by running the command ESLint: Restart ESLint Server from the command palette.
🌐
Meteor
forums.meteor.com › help
Run eslint every time page hot refreshes - help - Meteor Forum
September 10, 2024 - I’d like the linter to warn me of issues as i code / preferably break the build and show a warning on chrome. (i.e. not have to periodically run ‘npm run lint’) i’ve achieved this in other projects using something like …
🌐
Robin Wieruch
robinwieruch.de › vscode-eslint
How to use ESLint in VSCode
February 14, 2022 - How to install ESLint for VS Code (Visual Studio Code). Install ESLint, configure it per project, and use a local .prettierrc file ...
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
EsLint on VS code
April 12, 2021 - I’ve installed for the first time ESLint, I tried it, and I’m a bit surprised about the error message I get in this picture, for instance: I was expecting an error kind of “b is not defined”. Instead I’m getting what’…
🌐
LinkedIn
linkedin.com › pulse › config-eslint-prettier-vs-code-react-js-anurag-kumar
Config Eslint and Prettier in VS Code for React js
June 19, 2023 - ... Additionally, it is necessary ... editor. To do this, access the extensions section of VSCode by pressing "Ctrl + Shift + X" and search for "Eslint" and "Prettier — Code formatter" extensions....