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
December 12, 2019 - Learn how to set up ESLint in Visual Studio Code to lint and format JavaScript and TypeScript code with auto-fix and best practices.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
ESLint - Visual Studio Marketplace
Extension for Visual Studio Code - Integrates ESLint JavaScript into VS Code.
🌐
Dave Ceddia
daveceddia.com › vscode-use-eslintrc
ESLint + VSCode: How to Format Your Code Using .eslintrc
Open up VSCode’s settings. On a Mac, press Cmd+, or get there through the menus: Code > Preferences > Settings. It’ll open the fancy settings editor, but we need the raw JSON settings file instead. Click that tiny icon in the top-right that looks like a piece of paper with a little arrow. Add these 4 new lines inside the top-level settings object: { // ... "eslint.format.enable": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } }
🌐
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. You may check this link to view all the rules that can be automatically fixed. ... I then reviewed all of the remaining errors I found after running the command. ... I heavily used JQuery and other plugins (i.e.
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 :).

🌐
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 ...
🌐
Robin Wieruch
robinwieruch.de › vscode-eslint
How to use ESLint in VSCode
How to install ESLint for VS Code (Visual Studio Code). Install ESLint, configure it per project, and use a local .prettierrc file ...
Find elsewhere
🌐
DEV Community
dev.to › devdammak › setting-up-eslint-in-your-javascript-project-with-vs-code-2amf
Eslint Vscode: Setting up ESLINT in your JavaScript Project with VS Code - DEV Community
March 4, 2019 - Use a popular style guide => This allows you to choose from set of popular style such as Airbnb,Standard and Google style guide, it is advisable to choose this option in order for you to follow popular and most used style guide and i will be choosen this option in this post. Answer questions about your style: This is for custom style guide · Inspect your JavaScript file(s).: custom style guide · What format do you want your config file to be in? Javascript => whether you want your eslint config file to be in .js file
🌐
Thesoreon
thesoreon.com › blog › how-to-set-up-eslint-with-typescript-in-vs-code
How to set up Eslint with Typescript in VS Code | Pavel Sušický
Learn how to make astonishing eslint configuration with typescript support in Visual Studio Code and CLI!
🌐
YouTube
youtube.com › watch
How to Use ESLint in VSCode for JavaScript Projects | Set Up ESLint in Visual Studio Code - YouTube
In this tutorial, learn how to set up and use **ESLint** in Visual Studio Code (VSCode) for JavaScript projects. ESLint is a popular tool for identifying and...
Published   October 21, 2024
🌐
LaunchCode
education.launchcode.org › gis-devops › configurations › 06-vscode-eslint › index.html
Configuration: Visual Studio Code - ESLint — LaunchCode: GIS DevOps documentation
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 · Click on extensions (the squareish icon in the left menu)
🌐
YouTube
youtube.com › microsoft visual studio
Using ESLint and Prettier in Visual Studio Code - YouTube
Josh shows how you can use ESLint to set rules for your JavaScript/TypeScript code and how you can easily format it. He uses VS Code here, but you can do the...
Published   May 9, 2024
Views   5K
🌐
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…
🌐
Carl de Souza
carldesouza.com › home › posts › use eslint to validate your javascript in visual studio code
Use ESLint to Validate Your JavaScript in Visual Studio Code - Carl de Souza
September 15, 2020 - ESLint is a linter that runs in Visual Studio Code to analyze code for possible errors. In this post, we will look at how to set up ESLint in Visual Studio Code, in order to check JavaScript files for errors. You will need node and npm installed. First, let’s create a new directory and open ...
🌐
Stanley Ulili
stanleyulili.com › javascript › how-to-set-up-eslint-globally-with-vscode
How to Set Up ESLint Globally with VSCode
September 16, 2019 - 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. Let us now open VSCode.
🌐
Stack Exchange
salesforce.stackexchange.com › questions › 265536 › how-to-setup-eslint-in-vscode-to-work-with-every-project
salesforcedx - How to setup ESLint in VSCode to work with every project? - Salesforce Stack Exchange
Below is the process I am doing in VSCode to setup for every project I create: run command npm init from project folder and this is creating package.json file. Run the command eslint --init and it ...
🌐
Qirolab
qirolab.com › posts › eslint-prettier-and-vscode-setup-for-linting-and-formatting-1705606544
Set up ESLint, Prettier, and VSCode for linting, formatting, and optimizing JavaScript code quality | Qirolab
January 18, 2024 - 3. Once the configuration is set up, you can start linting your JavaScript files. Open a JavaScript file in VSCode, and you will see ESLint highlighting any errors or warnings in the code.
🌐
Medium
medium.com › how-to-react › config-eslint-and-prettier-in-visual-studio-code-for-react-js-development-97bb2236b31a
Config Eslint and Prettier in Visual Studio Code for React js development | by Manish Mandal | How To React | Medium
November 9, 2020 - So visit the extensions section of VSCode (ctrl + shift + x) and search for Eslint and Prettier — Code formatter and install it. npm install eslint --save-dev oryarn add eslint --dev · 2. After that we will generate our .eslintrc.json file ...