Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forbid 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:

enter image description here

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

enter image description here

like image 971
Faly Avatar asked Jan 08 '18 08:01

Faly


1 Answers

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)

like image 189
unional Avatar answered Sep 24 '22 15:09

unional