当我尝试通过npm start
运行应用程序时
Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Class extends value undefined is not a constructor or null
为什么会发生这种情况,我该如何解决?
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"
},
2条答案
按热度按时间deyfvvtc1#
这似乎是一个已知的
typescript-eslint
issue,可能会在升级到eslint
版本8.0.0时出现,它有一些破坏changes。第一个链接上的一些评论指出,通过降级到eslint版本7.32.0可以解决问题。如果我没理解错的话,
typescript-eslint
v4不支持eslint
v8,但是typescript-eslint
v5支持,所以你可以试着把你的eslint降级到7.32.0或者升级到v5。fhity93d2#
最后通过降级eslint解决了这个问题。