Hi, my company is having an hard time deciding which rules should be strictly followed, so I wanted to askif these specific rules are meant to apport actual benefit or is just code-style.
Remember this is for Angular/React/Typescript project, strictly following documentation code
Remove parentheses around the parameter of this arrow function. → in Typescript, I’m used to always have parentheses even in the rarest case where i cannot type a variable, for consistency. Wouldn’t it be more consistent not to remove them?
Ternary operator user → I just don’t get this. Totally forbidding ternary operator is not a good option in my opinion. Does this apport actual benefit? Of course other rules like “no nested ternary operator” are good
Unexpected any. Specify a different type. → Even though I totally understand this rule, there are some times where you can’t use generics but still need to accept any type of data. Should this just be a warning?
Interactive elements should not be assigned non-interactive roles and other accessibility rules → This is a correct guideline, but because accessibility is most human test, shouldn’t this just be a warning? I often get these kind of errors even on totally accessible pages (other tools and human tests confirm that)
Use either a literal or “Array.from()” instead of the “Array” constructor. → there are some times when this does not give the same result. So it might result in a false positive
Explicitly export the specific member needed → this is not what the barrel development pattern wants, also it is often referred to files with only one export (like components), so why is this rule so important (marked as high)
Type string trivially inferred from a string literal, remove type annotation → Since when having “too much types” is a problem? Wouldn’t this rule create less readable code?
Forbidden non-null assertion → Shouldn’t this be a unit test concern? Not always this error should be blocking (some times we delegate these checks to functions on top of the function’s body, so that would never happen
Add a “default” clause to this “switch” statement → What if the default shouldn’t to nothing?
Unexpected console statement. → not always a good idea, am i wrong?
These are some rules that I do not understand quite well. My company is trying to decide if either remove them or not from our sonar scans, so what’s your opinion on that? Should they be just warnings, or are there some of these rules that should remain mandatory?