Allow `no-shadow` rule to not check arguments
See original GitHub issueIt often seems better to allow no-shadow
rule to not check argument variables.
Arguments are often need only inside function’s own context, not deeper, e.g. users can use nesting .map(function(v, k){})
with “common” argument names v, k
if result of parent function is not used inside of child.
no-shadow
can give unneccessary error if user wants to make scope with .bind
.
for (var i = 0; i <= 10; i++) {
funcs.push(function(i){ // err here
}.bind(null, i));
};
It slightly conflicts with handle-callback-err
and no-unused-vars
with {args: 'after-used'}
// eslint handle-callback-err:0
doSomething(function(err, res) {
doAnother(res, function(err, res2) { // wish not have error here, but should add no-shadow: 0 and probably suppress real bugs
));
});
I suggest to add option to no-shadow
rule to not check arguments. It should work something like this.
/*eslint no-shadow:[1, "skip-args"]*/
function some(foo, baz) {
var bar = 1;
return function(foo, bar) { // no err here
var baz = 42; // err here
};
}
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:9 (7 by maintainers)
Top Results From Across the Web
no-shadow | typescript-eslint
When set to true , the rule will ignore the case when you name a type the same as a variable. TypeScript allows...
Read more >no-shadow - ESLint - Pluggable JavaScript Linter
Rule Details. This rule aims to eliminate shadowed variable declarations. Examples of incorrect code for this rule: /*eslint no-shadow ...
Read more >Avoid no-shadow eslint error with mapDispatchToProps
There are four options here: 1. Disable the rule. Why? It's the easiest way to avoid the ESLint error. Why Not? The no-shadow...
Read more >no-shadowed-variable - Rule
When set to false parameters, classes, enums and variables declared with let or const are not considered shadowed if the shadowing occurs within...
Read more >JS.TS.NO.SHADOW - Klocwork Static Code Analysis
When set to true , the rule will ignore the case when you name a type the same as a variable. TypeScript allows...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it’s the same issue as #2645 at all. That one is talking about making an exception for function names, this one is talking about function arguments. I definitely agree with the need for #2645 I’m not sold on this one though.
Closing due to lack of activity