简体   繁体   English

我可以控制哪些规则'tslint --fix'自动修复?

[英]Can I control which rules 'tslint --fix' auto fixes?

Is it possible to control which rules are auto-fixed when running tslint --fix ? 是否可以控制在运行tslint --fix时自动修复哪些规则tslint --fix Ideally, I only want to autofix the whitespace and quotation rules, and I'll evaluate the rest manually. 理想情况下,我只想自动修复空白和引用规则,我会手动评估其余部分。 I can't seem to find anything in the documentation telling me which rules auto fix, or how to control which rules to apply though, and I'm a bit apprehensive about blindly fixing everything. 我似乎无法在文档中找到任何告诉我哪些规则自动修复,或者如何控制应用哪些规则,而且我有点担心盲目修复所有问题。

I'm currently using the tslint file that's autogenerated by Angular CLI. 我目前正在使用由Angular CLI自动生成的tslint文件。

You could always run tslint --fix using a separate tslint.json file that contains only the rules you want to fix. 您始终可以使用单独的tslint.json文件运行tslint --fix ,该文件仅包含您要修复的规则。 I believe the rules that auto-fix are the ones marked "Has Fixer" in the list . 我相信自动修复的规则是列表中标记为“Has Fixer”的规则。

As already said, you can use you own tslint.json, with your custom rules. 如前所述,您可以使用自己的tslint.json和自定义规则。

For the "evaluation" part of your problem, I suggest simply using your source-control. 对于问题的“评估”部分,我建议只使用源代码控制。 For instance, it's easy with Git to validate / discard changes by files, or even by lines / chunk. 例如,Git很容易通过文件甚至行/块来验证/放弃更改。

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

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