简体   繁体   English

Disalow developper禁用任何TSLint规则

[英]Disalow developper to disable any TSLint rule

I'm leading a team working on Angular2+/Typescript project and I just want to know if there is a way to disallow disabling any TSLint rules. 我正在领导一个研究Angular2 + / Typescript项目的团队,我只是想知道是否有办法禁止禁用任何TSLint规则。

We are using VSCode and my team's developpers trend to disable rules for to many line: 我们正在使用VSCode和我的团队的开发人员趋势来禁用许多行的规则:

在此输入图像描述

After clicking on "Disable rule 'typeof-compare' for this line", TSLint add a comments above the line that disables the rule for this line. 单击“禁用规则'typeof-compare'后此行”,TSLint会在禁用该行规则的行上方添加注释。

在此输入图像描述

You cannot force or prevent people from disabling any rules in their environment. 您不能强制或阻止人们在其环境中禁用任何规则。 At the end, it's their environment and they should have sufficient freedom to do things. 最后,这是他们的环境,他们应该有足够的自由去做事。

What you can do is to enforce your tsLint rules at CI level or commit level. 您可以做的是在CI级别或提交级别强制执行tsLint规则。 Make sure your source code pass any coding style you specified. 确保源代码通过您指定的任何编码样式。

UPDATE: Regarding your need, code review or pair programming would be the only way to prevent this. 更新:关于您的需求,代码审查或结对编程将是防止这种情况的唯一方法。

You may be tempted to ask tsLint to provide an option to ignore these disable commits, but they are there for a reason. 您可能想要让tsLint提供一个忽略这些禁用提交的选项,但它们是有原因的。

There are cases you do want to use these comments as the TypeScript compiler or tsLint are just tools, they cannot fully understand the context of your code, so there are legit cases that these comments make sense. 在某些情况下,您确实希望使用这些注释,因为TypeScript编译器或tsLint只是工具,它们无法完全理解代码的上下文,因此存在这些注释有意义的合法情况。

Try to use TypeScript, tsLint, and any other tools as a TOOL. 尝试使用TypeScript,tsLint和任何其他工具作为工具。 They are meant to help you and your team in developing quality software, not trying to restrict, prohibit, or punish people. 它们旨在帮助您和您的团队开发高质量的软件,而不是试图限制,禁止或惩罚他人。 :) :)

(Note that I include TypeScript as a tool, that is the best approach IMO towards using TypeScript) (请注意,我将TypeScript作为工具包含在内,这是IMO使用TypeScript的最佳方法)

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

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