Search code examples
typescript-eslint

Definition for rule '@typescript-eslint/no-shadow' was not found


Not sure what's going on here.

I am working on migrating from tslint to eslint. The basic migration seems to have gone smoothly (well, "smoothly" -- got some kinds in the rules that need to get worked out apparently), but I've run across this and I have no idea how to get past it:

1:1 error Definition for rule '@typescript-eslint/no-shadow' was not found @typescript-eslint/no-shadow

I've modified the .eslintrc.js file like so (parts snipped for brevity):

module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "node": true
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": "tsconfig.json",
        "sourceType": "module"
    },
    "plugins": [
        "eslint-plugin-import",
        "@angular-eslint/eslint-plugin",
        "@typescript-eslint",
        "@typescript-eslint/tslint"
    ],
    "rules": {
        // Many unrelated plugins, all rules, none mentioning no-shadow

        "no-shadow": "off",
        "@typescript-eslint/no-shadow": ["error", { "hoist": "all" }],

        // Many other unrelated plugins, all rules, none mentioning no-shadow.  But I thought
        // This next one may be helpful.

        "@typescript-eslint/tslint/config": [
            "error",
            {
                "rules": {
                    "import-spacing": true,
                    "whitespace": [
                        true,
                        "check-branch",
                        "check-decl",
                        "check-operator",
                        "check-separator",
                        "check-type"
                    ]
                }
            }
        ]
    }
};

The versions of the plugins I'm working with are (copied from package.json):

"eslint-plugin-import": "^2.19.1",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",

I'm at a loss as to what's going on, and my google searches have turned up nothing aside from "use "no-shadow": "off", which I do.


Solution

  • v2.34.0 of the typescript-eslint packages is 9 months old.

    Upgrade to a more recent version of typescript-eslint.

    @typescript-eslint/no-shadow was added in v4.0.0