As explained in the Getting Started guide:

  • parser: '@typescript-eslint/parser' tells ESLint to use the @typescript-eslint/parser package you installed to parse your source files.

    • This is required, or else ESLint will throw errors as it tries to parse TypeScript code as if it were regular JavaScript.
  • plugins: ['@typescript-eslint'] tells ESLint to load the @typescript-eslint/eslint-plugin package as a plugin.

    • This allows you to use typescript-eslint's rules within your codebase.

In short: the eslint-plugin package contains the actual lint rules, and the parser plugin adds support for parsing TypeScript files (ESLint on its own does not support TypeScript — it used to, but that project evolved into typescript-eslint).

Answer from jtbandes on Stack Overflow
🌐
TypeScript ESlint
typescript-eslint.io › packages › eslint-plugin
@typescript-eslint/eslint-plugin | typescript-eslint
@typescript-eslint/eslint-plugin is an ESLint plugin used to load in custom rules and rule configurations lists from typescript-eslint.
🌐
GitHub
github.com › typescript-eslint › typescript-eslint
GitHub - typescript-eslint/typescript-eslint: :sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript · GitHub
:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript - typescript-eslint/typescript-eslint
Starred by 16.1K users
Forked by 2.9K users
Languages   TypeScript 90.9% | MDX 7.8%
🌐
TypeScript ESlint
typescript-eslint.io › packages › typescript-eslint
typescript-eslint | typescript-eslint
We strongly recommend declaring our plugin with the namespace @typescript-eslint as shown above. If you use our shared configs this is the namespace that they use.
🌐
npm
npmjs.com › package › typescript-eslint
typescript-eslint - npm
Tooling which enables you to use TypeScript with ESLint. Latest version: 8.57.0, last published: 2 days ago. Start using typescript-eslint in your project by running `npm i typescript-eslint`. There are 2852 other projects in the npm registry ...
      » npm install typescript-eslint
    
🌐
TypeScript ESlint
typescript-eslint.io › packages
Packages | typescript-eslint
@typescript-eslint/eslint-plugin: An ESLint plugin which provides lint rules for TypeScript codebases.
🌐
TypeScript ESlint
typescript-eslint.io › rules
Overview | typescript-eslint
@typescript-eslint/eslint-plugin includes over 100 rules that detect best practice violations, bugs, and/or stylistic issues specifically for TypeScript code. All of our rules are listed below.
Find elsewhere
🌐
GitHub
github.com › typescript-eslint › typescript-eslint › releases
Releases · typescript-eslint/typescript-eslint
eslint-plugin: [no-useless-default-assignment] fix false positive for parameters corresponding to a rest parameter (#11916) typescript-estree: forbid type-only import with both default and named specifiers (#11930)
Author   typescript-eslint
Top answer
1 of 3
7

Explanation

If you create a new project with npm init -y and then npm install @typescript-eslint/eslint-plugin, you would see in your package-lock.json:

"node_modules/@typescript-eslint/eslint-plugin": {
  "version": "6.2.1",
  ...
  "peerDependencies": {
    "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha",
    ...
  }
  ...
}

This means @typescript-eslint/eslint-plugin version 6.2.1 needs @typescript-eslint/parser version ^6.0.0 to be in your project.

Meanwhile, here is what you have in your current package-lock.json:

"node_modules/eslint-config-next": {
  "version": "13.4.8",
  ...
  "dependencies": {
    ...
    "@typescript-eslint/parser": "^5.42.0",
    ...
  },
  ...
},

Meaning eslint-config-next needs version 5.42.0, so while installing @typescript-eslint/eslint-plugin, npm founds a versions conflict.

Solution

You can install @typescript-eslint/eslint-plugin version 5.9.0, which expects the version ^5.0.0 of @typescript-eslint/parser :

npm i @typescript-eslint/[email protected]
2 of 3
4

I got a similar issue working with a create-react-app which I was converting to use typescript. As Youssouf suggested, the issue is the conflict of versions between @typescript-eslint and some other sub-modules, such as @typescript-eslint/parser. This was evident by my package-lock.json listing several @typescript-eslint sub-modules as at version 5.6.2.

I fixed this by first running npm i @typescript-eslint/parser@latest to upgrade the sub-modules in my package-lock. I was then able to run npm i @typescript-eslint/eslint-plugin successfully.

🌐
Eslint
eslint.style › packages › ts
@stylistic/eslint-plugin | ESLint Stylistic
Stylistic rules for ESLint, works for both JavaScript, TypeScript and JSX. This plugin provides some built-in configurations that you can use out of the box.
🌐
GitHub
github.com › typescript-eslint › eslint-plugin-tslint
GitHub - typescript-eslint/eslint-plugin-tslint: ESLint plugin that wraps a TSLint configuration and lints the whole source using TSLint · GitHub
{ "plugins": [ "@typescript-eslint/tslint" ], "parserOptions": { "project": "tsconfig.json", }, "rules": { "@typescript-eslint/tslint/config": ["warn", { "lintFile": "", // path to tslint.json of your project "rules": { // tslint rules (will be used if `lintFile` is not specified) }, "rulesDirectory": [ // array of paths to directories with rules, e.g.
Author   typescript-eslint
🌐
TypeScript ESlint
typescript-eslint.io › developers › eslint-plugins
ESLint Plugins | typescript-eslint
This page describes how to write your own custom ESLint plugins using typescript-eslint.
🌐
TypeScript ESlint
typescript-eslint.io › getting-started
Getting Started | typescript-eslint
ESLint will lint all TypeScript compatible files within the current folder, and will output the results to your terminal.
Top answer
1 of 3
10

Credit to Brad Zacher's answer for drawing my attention to How do I check to see what versions are installed?

If you have multiple versions of our tooling, it can cause various bugs for you. This is because ESLint may load a different version each run depending on how you run it - leading to inconsistent lint results.

Installing our tooling in the root of your project does not mean that only one version is installed. One or more of your dependencies may have its own dependency on our tooling, meaning npm/yarn will additionally install that version for use by that package. For example, react-scripts (part of create-react-app) has a dependency on our tooling.

You can check what versions are installed in your project using the following commands:

npm npm list @typescript-eslint/eslint-plugin @typescript-eslint/parser

Yarn yarn list --pattern "@typescript-eslint/eslint-plugin|@typescript-eslint/parser"

pnpm pnpm list @typescript-eslint/eslint-plugin @typescript-eslint/parser

If you see more than one version installed, then you will have to either use yarn resolutions to force a single version, or you will have to downgrade your root versions to match the dependency versions.

The best course of action in this case is to wait until your dependency releases a new version with support for our latest versions.

I used the yarn command, which gave the following output

yarn list v1.22.19
├─ @typescript-eslint/[email protected]
├─ @typescript-eslint/[email protected]
└─ [email protected]
   ├─ @typescript-eslint/[email protected]
   └─ @typescript-eslint/[email protected]

So the solution was to downgrade @typescript-eslint/eslint-plugin and @typescript-eslint/parser to version 5.62.0 in my package.json, to match the version used by eslint-config-react-app.

I then hit a different error:

There was a problem loading formatter: ...\node_modules\eslint\lib\cli-engine\formatters\stylish Error: require() of ES Module ...\node_modules\strip-ansi\index.js from ...\assertion-lib\node_modules\eslint\lib\cli-engine\formatters\stylish.js not supported. Instead change the require of index.js in ...\node_modules\eslint\lib\cli-engine\formatters\stylish.js to a dynamic import() which is available in all CommonJS modules.

Manually editing something in the node_modules folder didn't sound right, however it seems that this is a bug in yarn. So I deleted the yarn.lock file from my project and deleted the node_modules folder (which may have been overkill) and ran a npm install and now eslint is linting my typescript code successfully.

2 of 3
1

ESLint is warning you that there are multiple versions of the plugin installed in your workspace, and that your configuration is setup so that you've asked ESLint to import these multiple versions.

So either you'll need to change your config to avoid this, or (more likely) you'll need to use your package manager's resolutions feature to ensure there's only one version of the plugin installed.

This FAQ article might help as it lists some commands and provides some more context: https://typescript-eslint.io/linting/troubleshooting/#how-do-i-check-to-see-what-versions-are-installed

🌐
GitHub
github.com › eslint › eslint › discussions › 15785
Bug: ESLint doesn't find @typescript-eslint/eslint-plugin right after installing it · eslint/eslint · Discussion #15785
Try reinstalling by running the following: npm install @typescript-eslint/eslint-plugin@latest --save-dev The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "PersonalConfig".
Author   eslint
🌐
TypeScript ESlint
typescript-eslint.io
typescript-eslint
The parser and services for linting TypeScript code with ESLint, as well as how tools such as Prettier read TypeScript code.
🌐
Netlify
v6--typescript-eslint.netlify.app › getting-started
Getting Started | typescript-eslint
This is required, or else ESLint will throw errors as it tries to parse TypeScript code as if it were regular JavaScript. plugins: ['@typescript-eslint'] tells ESLint to load the @typescript-eslint/eslint-plugin package as a plugin.