简体   繁体   中英

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.

We are using VSCode and my team's developpers trend to disable rules for to many line:

在此输入图像描述

After clicking on "Disable rule 'typeof-compare' for this line", TSLint add a comments above the line that disables the rule for this line.

在此输入图像描述

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. 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.

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.

Try to use TypeScript, tsLint, and any other tools as a TOOL. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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