no-shadowed-variable: please add scope options #3000
Comments
Makes sense. I'd rather ignore specific declarations instead of enabling the desired checks. My idea is to ignore names of ignored declarations completely.
|
Currently the following declarations are checked:
For which of them do we need an option to ignore it? Do we want to add an option for each of them (except variables and parameters) or an option to ignore all types (enum through type alias)? |
My main breakages are
db.transaction((transaction) => { // Shadowed name: 'transaction'
return model.doSomething({ transaction });
});
class SomeClass {
@memoize({ normalizer: ([arg1, arg2]) => `...` })
someMethod(arg1, arg2) { ... } // Shadowed name: 'arg1', 'arg2'
}
export class GenericClass<T = any> {
data: T;
static genericFunction<T>(args: T) { ... } // Shadowed name: 'T'
} It seems like (1) can be achieved via ignoring function type, but (2) So I want to suggest specifying a scope to be checked.. e.g. block scope, function scope, class scope, namespace scope, and file scope. |
(1) I cannot reproduce this with the code provided. There has to be a a function or variable named The following would be expected: transaction((transaction) => { // Shadowed name: 'transaction'
// do stuff
}); (2) Cannot reproduce with the provided code snippet. This code should not result in an error. (3) Yeah, that could be suppressed by ignoring type parameters. Seems like it's better to add an option for each kind of declaration. |
[new-rule-option] `no-shadowed-variable` let's you optionally ignore certain kinds of declarations [bugfix] `no-shadowed-variable` fixed false positive with parameter inside function decorator Fixes: #3000 [bugfix] `no-shadowed-variable` don't warn for shadowed type parameter on static class members Fixes: #3019
[new-rule-option] `no-shadowed-variable` let's you optionally ignore certain kinds of declarations [bugfix] `no-shadowed-variable` fixed false positive with parameter inside function decorator Fixes: palantir#3000 [bugfix] `no-shadowed-variable` don't warn for shadowed type parameter on static class members Fixes: palantir#3019
Description
There is an update for
no-shadowed-variable
today #2598 .Enhancement is really good, however, It breaks lots of our code.
It should be options for check interfaces, classes, type parameters, imports, etc so that we can granularly adapt to the rule with specific scopes.
The text was updated successfully, but these errors were encountered: