why do we need to separately install eslint as npm package and vscode extension?

Short answer: you don't.

Long answer:

Installing ESLint/Prettier as extension, allows you to format/check your code inside the VSCode.

However, installing them also as dependencies brings extra benefits:

  • VSCode will use exact same package as installed. So you will not spot the situation when VSCode says OK, but your CI server says: NOT OK
  • You will get control over the versions, and can update whenever you want
  • You will be able to use different versions for different projects. This is especially important, when you can't migrate old project, but want to use the latest possibilities for the new one
  • You will be able to access Prettier/ESlint through the script block of the package.json, and be able to write custom commands with parameters exactly as you need
  • You will be able to pair them with Husky or NPM hooks to automatically verify/format the code

From my experience, if you can install something locally - install it as package dependency (except CLI like create-react-app or angular-cli that helps you start the app). This will make your life a bit predictable.

Answer from Drag13 on Stack Overflow
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
ESLint - Visual Studio Marketplace
Extension for Visual Studio Code - Integrates ESLint JavaScript into VS Code.
🌐
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 - Choose the Yes option to install the dependencies with npm. If you are asked to install extra packages, choose yes. After completing all the prompts, you’ll notice that a file named .eslintrc.json has been added to your vscode-eslint-example directory. ESLint is now installed.
🌐
GitHub
github.com › microsoft › vscode-eslint
GitHub - microsoft/vscode-eslint: VSCode extension to integrate eslint into VSCode · GitHub
If the folder doesn't provide one, the extension looks for a global install version. If you haven't installed ESLint either locally or globally, do so by running: ... # npm npm install --save-dev eslint # yarn yarn add --dev eslint # pnpm pnpm add --save-dev eslint # bun bun add --dev eslint
Author   microsoft
Top answer
1 of 3
18

why do we need to separately install eslint as npm package and vscode extension?

Short answer: you don't.

Long answer:

Installing ESLint/Prettier as extension, allows you to format/check your code inside the VSCode.

However, installing them also as dependencies brings extra benefits:

  • VSCode will use exact same package as installed. So you will not spot the situation when VSCode says OK, but your CI server says: NOT OK
  • You will get control over the versions, and can update whenever you want
  • You will be able to use different versions for different projects. This is especially important, when you can't migrate old project, but want to use the latest possibilities for the new one
  • You will be able to access Prettier/ESlint through the script block of the package.json, and be able to write custom commands with parameters exactly as you need
  • You will be able to pair them with Husky or NPM hooks to automatically verify/format the code

From my experience, if you can install something locally - install it as package dependency (except CLI like create-react-app or angular-cli that helps you start the app). This will make your life a bit predictable.

2 of 3
9

These programs can format your code (ESLint and Prettier) and detect specific syntax (ESLint).

When installed as an extension in your IDE (vscode for example), you can get:

  • squiggly lines in real time;
  • and format-on-save.

But someone who starts up your project on their own environment might not have these extensions installed (might not even have the same IDE) and thus might not get these.

When installed as npm packages (and included somewhere in the pipeline, either in the npm start, or in your continuous deployment, or...)

  • you won't get real time squiggly lines,
  • but you can still get auto-formatting (though not necessarily on save, depending on the configuration),
  • you can get blocking rules (meaning instead of just seeing errors / warnings, you can actually block the pipelines until the dev fixes said errors / warnings)
  • you can insure anyone who starts the project, from any IDE, gets the packages included
🌐
GitHub
gist.github.com › mckeeh3 › 4b6a4ab008329b182fc80fbe85cc9aff
VS Code, ESLint, Prettier Setup NodeJS projects · GitHub
In VS Code, install the ESLint and Prettier extensions. Set Prettier global settings. Open the command pallet. Search for 'format on save' and enable it. Search for 'prettier'. Enable Single Quote.
🌐
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 - Then run npm install eslint --save-dev in the terminal. Now you have npm_modules and a package.lock.json file too. Anyway, now you need to initiate ESLint in your folder. Write npx eslint --init in the terminal.
🌐
GitHub
github.com › microsoft › vscode-eslint › issues › 36
ESlint extension should be used without npm modules · Issue #36 · microsoft/vscode-eslint
December 31, 2015 - As vscode is gonna deprecate its internal validator, it's inconvenient to implement eslint-extension with downloading eslint(npm modules) every time and in every project folder. I'd recommend vscode-eslint to be more easier to use by emb...
Published   Feb 27, 2016
🌐
Raddy
raddy.dev › home › how to configure eslint for a node.js project + vs code extension
How to configure ESLint for a Node.Js Project + VS Code Extension - Raddy
February 8, 2023 - When you work in a team or a slightly larger project it’s important to have a consistent style across all files. With this guide, you’ll be able to set up auto linting focused on Node.Js projects using the AirBnB style guide and the Visual Studio Code extension by Dirk Baeumer – ESLint.
Find elsewhere
🌐
npm
npmjs.com › package › eslint
eslint - npm
An AST-based pattern checker for JavaScript.. Latest version: 10.0.3, last published: 4 days ago. Start using eslint in your project by running `npm i eslint`. There are 24636 other projects in the npm registry using eslint.
      » npm install eslint
    
Published   Mar 06, 2026
Version   10.0.3
Author   Nicholas C. Zakas
Homepage   https://eslint.org
🌐
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ý
# Go to the root of the project (where package.json lives) cd my-project # using npm npm install -D eslint # using yarn yarn add -D eslint
🌐
Visual Studio Code
code.visualstudio.com › api › advanced-topics › tslint-eslint-migration
Migrate from TSLint to ESLint | Visual Studio Code Extension API
November 3, 2021 - You need to install ESLint. ESLint doesn't natively support TypeScript, so you will also need to install eslint-typescript-support: npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
🌐
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 - once we have installed eslint extension on our vs code editor then let install eslint as a global package via npm using the below code
🌐
Stack Overflow
stackoverflow.com › questions › 48196791 › eslint-for-vscode-without-using-node-or-alternative
ESlint for VSCode without using node or alternative?
FWIW, I found that by googling "ESLint vscode". ;) Given that the MS supported version still wants you to install eslint via npm, this is probably the only way to go.
🌐
Medium
cloudonhire.medium.com › how-to-lint-with-eslint-in-visual-studio-code-ec996cf3b572
How to Lint with ESLint in Visual Studio Code | by CloudOnHire | Medium
October 23, 2025 - Choose the Yes option to install the dependencies with npm. You will also be asked to install extra packages. Choose yes. After completing all the prompts, you’ll notice that a file named .eslintrc.json has been added to your vscode-eslint-example directory.
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 :).

🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › javascript › linting-javascript
Linting JavaScript in Visual Studio - Visual Studio (Windows) | Microsoft Learn
Dependencies include the ESLint npm package and other plugins applicable to your project. This package can be installed locally in each project where you want to enable linting, or you can install it globally using npm install -g eslint.
🌐
Nuxt ESLint
eslint.nuxt.com › packages › module
ESLint Module - Nuxt ESLint
To enable support for the new configuration files, edit your .vscode/settings.json file and add the following: ... Run the npm run lint command to check if the code style is correct or run npm run lint:fix to automatically fix issues.