当我使用npm start运行我的create react应用程序时,eslint错误显示在我网站顶部的浏览器中。我希望在终端中看到这些警告和错误,但在实际网站中看不到,如何删除这些警告和错误?
package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-router-dom": "^5.1.2",
"react-scripts": "^5.0.0",
"react-transition-group": "^4.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint ."
},
"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": {
"eslint": "^8.12.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.4",
"eslint-plugin-react-hooks": "^4.4.0"
}
}
3条答案
按热度按时间vvppvyoh1#
您可以通过添加环境变量
ESLINT_NO_DEV_ERRORS
来禁用浏览器中的错误,因为它是提到here。如果您的项目中有**.env**文件,只需将这一行添加到其中,然后重新构建应用程序:
tpxzln5u2#
在eslint.rc中,你可以在modul.exports中为你的env设置一个节,你可以在浏览器参数中添加false,这也可以解决这个问题
quhf5bfb3#
如果您使用自定义webpack。(非CRA)然后您需要在webpack devServer中禁用“overlay”。
How can I disable the overlay for warnings in a React app?