Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint "Definition for rule 'no-explicit-any' was not found" always shown

Started a react/typescript project with react-scripts, added a .eslintrc.json file with the following content:

{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended",
        "plugin:@typescript-eslint/recommended",
        "react-app",
        "react-app/jest"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "@typescript-eslint"
    ],
    "rules": {
        "import/no-anonymous-default-export": "off",
        "no-explicit-any": "error",
        "@typescript-eslint/no-extra-semi": "off",
        "@typescript-eslint/no-explicit-any": "error",
        "@typescript-eslint/no-unused-vars": "off",
        "@typescript-eslint/explicit-module-boundary-types": "error",
        "@typescript-eslint/no-non-null-assertion": "off",
        "@typescript-eslint/no-inferrable-types": "off",
        "@typescript-eslint/no-empty-interface": "off"
    }
}

Now, for some reason unknown to me, every file starts with the warning/error: Line 1:1: Definition for rule 'no-explicit-any' was not found no-explicit-any, even if the file doesn't even have the any type, and even if the file is empty!

It's an important rule, and I don't want to just ignore it.

Is it a bug? Am I doing something wrong?

Example of an almost-empty-file with this error: Example of an empty file

like image 253
A-S Avatar asked Feb 01 '26 03:02

A-S


1 Answers

Try removing "no-explicit-any": "error" as this is not a valid eslint rule and this is where the error is thrown.

You have the rule enabled via "@typescript-eslint/no-explicit-any": "error",

like image 74
Alexei Darmin Avatar answered Feb 03 '26 23:02

Alexei Darmin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!