Search code examples
typescripteslinttypescript-eslint

ESLint typed linting rules/plugin cannot be found


I'm using ESLint and Prettier to lint my TypeScript project. Everything was working fine until I attempted to use typed linting from typescript-eslint. I just can't get it to find the rules for typed linting.

Here's the error when I run ESLint:

ESLint: 8.55.0

ESLint couldn't find the config "plugin:@typescript-eslint/recommended-type-checked" to extend from. Please check that the name of the config is correct.

The config "plugin:@typescript-eslint/recommended-type-checked" was referenced from the config file in "/home/geopro/bench/captcha4/.eslintrc.cjs".

I'm following this doc and here's my .eslintrc.cjs:

module.exports = {
    env: {
        browser: true,
        es2022: true,
        node: true,
    },
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended-type-checked',
        'plugin:yaml/recommended',
        'plugin:json/recommended',
        'plugin:toml/standard',
        'plugin:regexp/recommended',
        'prettier', // must be last! disables rules which conflict with prettier
    ],
    parser: '@typescript-eslint/parser',
    parserOptions: {
        sourceType: 'module',
        project: true,
        tsconfigRootDir: __dirname,
    },
    plugins: [
        '@typescript-eslint',
        'workspaces',
        'unused-imports',
        'sort-imports-es6-autofix',
        // do not add prettier to plugins otherwise rule conflicts will occur between prettier and eslint! run prettier as a separate command
    ],
    root: true,
};

Crucially, plugin:@typescript-eslint/recommended-type-checked cannot be found. Any ideas? The non-typed version (plugin:@typescript-eslint/recommended) works fine, but as I'm using TypeScript it would be nice to have typed linting also


Solution

  • Credit to @JSONDerulo for his comment which is the answer:

    The recommended-type-checked config was introduced with TypeScript ESLint v6. It looks like you have an older version installed, where this config is not available

    Version 5 (which I was on) and below do not contain the typed rules. Bump to version 6 or above and it works