简体   繁体   English

ESlint 抛出错误而不是警告

[英]ESlint throw errors instead of warnings

Is it possible to throw errors instead of warnings using Eslint?是否可以使用 Eslint 抛出错误而不是警告? I am working with a create-react-app and want to have a really strict lint policy in my team, and thought that this might be a good start.我正在使用create-react-app并希望在我的团队中有一个非常严格的 lint 政策,并认为这可能是一个好的开始。

Is that possible?那可能吗?

--max-warnings can serve this purpose: --max-warnings=0 means that any warnings cause eslint to report an error. --max-warnings可以达到这个目的: --max-warnings=0意味着任何警告都会导致 eslint 报告错误。

https://github.com/eslint/eslint/issues/2309#issuecomment-219828044 https://github.com/eslint/eslint/issues/2309#issuecomment-219828044

Yes It is possible to edit the ESlint Configuration in create-react-app setup.是 可以在 create-react-app 设置中编辑 ESlint 配置。 All you need to do is run npm run eject in your project setup.您需要做的就是在您的项目设置中运行npm run eject This will allow you to edit the default project configurations according to your needs.这将允许您根据需要编辑默认项目配置。

After ejecting you will find a eslintConfig key in your project root's package.json file.弹出后,您会在项目根目录的package.json文件中找到一个eslintConfig键。 Just delete this option from the package.json.只需从 package.json 中删除此选项即可。 You can add your own custom configuration for the Eslint by adding a .eslintrc file in your project root directory.您可以通过在项目根目录中添加.eslintrc文件来为 Eslint 添加您自己的自定义配置。 You can read about different rules and configurations here您可以在此处阅读不同的规则和配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM