[英]How to disable eslint check on development mode in reactjs
I have configured eslint successfully to run for every commit (pre-commit hook) in reactjs project.我已成功配置 eslint 以在 reactjs 项目中为每个提交(预提交钩子)运行。 It runs properly after sending git commit command to terminal.
将 git commit 命令发送到终端后,它运行正常。
here's my package.json
这是我的
package.json
"scripts": {
......
"lint": "eslint src --ext .tsx .",
"lint:fix": "eslint src --ext .tsx --fix",
"precommit": "lint-staged",
"prepare": "husky install",
"format": "prettier --write \"src/**/*.tsx\"",
......
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.(ts|tsx)": [
"prettier --write .",
"eslint src --ext .tsx --fix .",
"git add ."
]
},
But I don't want eslint to check for rules when in development mode (by running npm run start
).但是我不希望 eslint 在开发模式下检查规则(通过运行
npm run start
)。
For example, I set no-console
rule to error
to prevent user to commit the code using console.log
in it, but when I try to use console.log
in development mode to show the log in console, it throw an error by lint check例如,我将
no-console
规则设置为error
以防止用户在其中使用console.log
提交代码,但是当我尝试在开发模式下使用console.log
在console.log
中显示日志时,它会通过 lint 抛出错误查看
How can I config it?我该如何配置它?
Thanks all谢谢大家
I myself found the solution from here Edit .env:我自己从这里找到了解决方案 Edit .env:
DISABLE_ESLINT_PLUGIN=true
Or in package.json:或者在 package.json 中:
{
"scripts": {
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
"test": "DISABLE_ESLINT_PLUGIN=true react-scripts test"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.