reactjs - 如何解决:“找不到规则'@typescript-eslint/consistent-type-assertions'的定义”
问题描述
我的 React 应用程序没有因为错误而无法编译:未找到规则“@typescript-eslint/consistent-type-assertions”的定义
我有点不知所措。我无法在项目中找到任何当前规则定义。该项目最初正在编译。在我重组应用程序后开始出现错误。
该应用程序无法编译并出现错误:未找到规则“@typescript-eslint/consistent-type-assertions”的定义
包.json -
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/react-dom": "16.9.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.1",
"styled-components": "^4.3.2",
"typescript": "^3.5.3"
},
"scripts": {
"start": "PORT=3005 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --transformIgnorePatterns",
"e2e": "./node_modules/.bin/cypress open"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/dom": "^6.1.0",
"@testing-library/jest-dom": "^4.0.1",
"@testing-library/react": "^9.1.3",
"@types/jest": "^24.0.18",
"@types/lodash": "^4.14.137",
"@types/node": "^12.7.2",
"@types/react": "^16.9.2",
"@types/react-router-dom": "^4.3.4",
"@types/styled-components": "^4.1.18",
"babel-jest": "^24.9.0",
"cypress": "^3.4.1"
}
}
解决方案
刚刚更新react-scripts
。我通过卸载并再次安装解决了它。在命令行中:
卸载:
npm uninstall react-scripts --save
并再次安装:
npm i react-scripts
推荐阅读
- symfony - Twig 文件不显示任何内容(SYMFONY 4.4)
- javascript - 使用 Context API 和 useContext (React js) 传递值
- django - LineString 类型的对象不是 JSON 可序列化的
- java - 覆盖范围不工作的 Intelij junit 测试
- javascript - 嵌套承诺 Javascript
- javascript - 如何根据其他值类型从 API 获取数据
- javascript - 让我的表格创建新行而不是单元格
- php - Symfony - 通过调用方法更改实体字段
- vb.net - 如何修复“vbc.exe 以代码 -2146232797 退出”Visual Studio?
- python - 在 Django 视图中为不同事件加载多个评论