We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESLint
.eslintrc.json
"no-console": "warn"
console
console.log
git commit
.git/hooks
pre-commit.sample
pre-commit
git commit -m 'xxx' --no-verify
VSCODE
remove-console
Webpack
terser-webpack-plugin
create-react-app
drop_console: true
参考文档:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
ESLint
配置规则软性禁止:通过配置.eslintrc.json
文件,添加"no-console": "warn"
规则,使代码中使用console
的地方会划上黄色波浪线警示,能一定程度削减console.log
数量,但无法真正阻止其使用。git commit
编写规则限制提交:找到项目中的.git/hooks
文件夹下的pre-commit.sample
文件,将其内容修改为若提交代码中包含console.log
则报错提交失败,并将文件重命名为pre-commit
。但该规则可被git commit -m 'xxx' --no-verify
指令绕过。VSCODE
插件:可在插件商店搜索remove-console
并安装,找到有console.log
的文件使用插件删除,但效果可能不太理想。Webpack
插件terser-webpack-plugin
,在项目基于create-react-app
脚手架时可直接搜到,在使用处配置drop_console: true
,能在打包后去除全部console.log
。参考文档:
The text was updated successfully, but these errors were encountered: