question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow `no-shadow` rule to not check arguments

See original GitHub issue

It 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:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ilyavolodincommented, Aug 28, 2015

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.

0reactions
albertocommented, Aug 26, 2016

Closing due to lack of activity

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found