Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enforce developers to use square over than curly brackets?

Tags:

angular

I want to enforce developers in my application to use [] instead of {{}} in element attributes.

for example this code should cause an error (in the build/serve/lint time ):

<mycomponent id="{{i}}"> 

the current code is

<mycomponent [id]="i">

How I do that?

like image 542
Jon Sud Avatar asked Nov 11 '19 10:11

Jon Sud


2 Answers

As commented, one of the possibilities would be to create a custom TSLint rule and add severity to force developers when compiling throwing the proper errors. You will have a tslint.json in your project for all the core rules and custom ones.

Please, check here how to write a custom rule: https://palantir.github.io/tslint/develop/custom-rules/

In other matters be aware that TSLint is being deprecated and ESLint would be its substitute.

like image 147
ZetaPR Avatar answered Nov 22 '22 07:11

ZetaPR


Teach them, be nice and set good examples.

like image 31
JWP Avatar answered Nov 22 '22 06:11

JWP