-
Notifications
You must be signed in to change notification settings - Fork 888
A few rules are mostly redundant in newer TypeScripts with specific compiler options #1861
Comments
If you deprecate options like |
There is also an issue with For e.g. function foo(a: any, b: T): T { return b; } See microsoft/TypeScript#9458 for reference. The approved fix is to prefix uninteresting parameters with an underscore, see microsoft/TypeScript#9464 which breaks the |
@jsynowiec If you need fine grained control for variable name formats, I would recommend one of my custom rules https://github.com/ajafff/tslint-consistent-codestyle#naming-convention Btw. sorry for shamelessly advertising my own package here. |
I don’t want to relax the naming rules except in this case. It seems we need a new rule which checks that function parameters start with an underscore if and only if they are (a) unused and (b) followed by a parameter that is used. Slightly annoying. :-) |
So, now that I see, I'm thinking:
Although, here's a highly relevant TS issue: microsoft/TypeScript#11051 |
Heya, I just wanted to pitch in in favor of keeping My argument is similar to the value of prototyping one. I think it's a different 'level' of checking. You might want a compilation error... or you might want a lint check before commiting. You might also want to treat different parts of your app with different linting rules, without having a different tsconfig.json. So I think there's value in having both a linting rule and a compilation setting. |
As I understand - there rules won't be used in Maybe it worth to move them to separate repository/package, provide "migration guide" on how to include and enable them in users configuration for those (I expect it to happen on major release)? |
Could we deprecate (except |
@andy-hanson yeah let's do it |
keeping these rules for now. See #2422 (comment) |
Should this be revisited now that microsoft/TypeScript#9448 was fixed, or wait for microsoft/TypeScript#19139? I suppose since they require a specific version of TypeScript, the rules should remain until TSLint stops supporting older versions of TypeScript (where they would still be useful). |
If this helps make that judgement, the version Edit: Also, the last time the baseline changed was back in March 2017, where it was updated from 2.0 to 2.1, and the last time before that was in November 2016, where it was updated from 1.7 to 2.0. |
Here's the relevant rules of varying redundancy unaddressed in the docs:
no-invalid-this
→--noImplicitThis
(not a precise equivalent, but it makes all usages explicit)no-switch-case-fallthrough
→--noFallthroughCasesInSwitch
(exact equivalent)no-unused-variable
→--noUnusedLocals
and--noUnusedParameters
(exact equivalent between the two)switch-default
is partially redundant with--noImplicitReturns
, which requires that all code paths are reachable and return a value. (It only checks the end, but a final switch-case is rather common.)The text was updated successfully, but these errors were encountered: