Home > Software design >  eslint - Failed to load plugin '@typescript-eslint'
eslint - Failed to load plugin '@typescript-eslint'

Time:03-10

When i try to run the application by npm start

Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Class extends value undefined is not a constructor or null

Why does it happen and how can I fix it?

eslintrc.json

{
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": ["plugin:react/recommended", "airbnb"],
  "parser": "@typescript-eslint/parser",
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [".ts", ".tsx"],
        "moduleDirectory": ["src", "node_modules"]
      }
    }
  },
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": "latest",
    "sourceType": "module"
  },
  "plugins": ["react", "@typescript-eslint"],
  "rules": {
    "no-console": "off"
  }
}

package.json

  "devDependencies": {
    "@babel/core": "^7.16.5",
    "@babel/preset-env": "^7.16.5",
    "@types/react-dom": "^17.0.11",
    "@types/react-router-dom": "^5.3.2",
    "@types/react-table": "^7.7.9",
    "@types/scrollmagic": "^2.0.2",
    "@types/styled-components": "^5.1.21",
    "@typescript-eslint/eslint-plugin": "^5.14.0",
    "@typescript-eslint/parser": "^5.14.0",
    "awesome-typescript-loader": "^5.2.1",
    "babel-loader": "^8.2.3",
    "eslint": "^8.10.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-react": "^7.29.3",
    "eslint-plugin-react-hooks": "^4.3.0",
    "react-app-rewired": "^2.2.1"
  },

CodePudding user response:

This seems to be a known typescript-eslint issue that may appear upon upgrading to eslint version 8.0.0, which has some breaking changes. Some comments on that page indicate resolution by downgrading to eslint version 7.32.0.

If I understand correctly, `typescript-eslint v4 does not support ESLint v8, while typescript-eslint v5 does appear to support ESLint V8. So you might try either downgrading your eslint to version 7.32.0 or upgrading your typescript-eslint to v5.

But with that said, it appears you do already have eslint version v8 and typescript-eslint v5 . So based on the versions you're showing it's possible this advice may not apply to you.

CodePudding user response:

Finally solve it by downgrade eslint.

 "devDependencies": {
    ...
    "eslint": "^7.32.0"
  }
  • Related