-
Notifications
You must be signed in to change notification settings - Fork 889
Document the deprecation of no-unused-variable #1851
Comments
Just want to point out that there is one important limitation when using the compiler options, versus TSLint: The compiler options are all-or-nothing: I cannot turn off the check for specific use cases. For example, we have a folder of generated files with an |
@schmuli As I mentioned in another place:
So these are two use cases in favor of using the |
The third argument would be that during a development phase you are very likely to have unused-imports. I would like to run tslint in CI in order to detect problems in a pull-request before the branch is merged. The compiler option doesn't allow you to have an intermediate "broken" state when you try things. |
Note that the compiler checks don't break your build or dev environment unless you set them up to do so either. |
The compiler checks for unused params are unusable for me right now due to how the tsc treats unneeded parameters, please see #1861 (comment) Where can I find reasoning behind depreciation of this rule, other than that TSC ca also do this? |
@jsynowiec from that thread:
There is a rule option exactly for this scenario called There is more discussion / explanation in #1481 and the linked issues. The rule implementation is buggy and the compiler does a better job with these checks, so the maintenance burden in the core ruleset doesn't feel worth it. |
Can const _varName = 1;
// ~~~~~~~~ <-- this still needs to be a lint error
function foo(_: string, __: number, bar: boolean) {
console.log('only interested in', bar);
} |
I think that skipping just parameters with leading underscore is trivial fix(with new option) [works for case shown earlier]. However checking if it has leading underscore, but actually used (which should violate rule) - not so trivial and may be error prone. |
#1481 no longer being deprecated |
https://palantir.github.io/tslint/rules/no-unused-variable/
We end up explaining how this rule is deprecated in favor of the compiler options in a lot of GH threads. We should use the
deprecationMessage
in the rule metadata:tslint/src/rules/noUnusedVariableRule.ts
Line 34 in 6364432
UPDATE (feb 27, 2017): the rule is no longer deprecated. see #2256
The text was updated successfully, but these errors were encountered: