Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-shadowed-variable should ignore shadowed _-params #4201

Closed
ozra opened this issue Oct 3, 2018 · 3 comments · Fixed by #4546
Closed

no-shadowed-variable should ignore shadowed _-params #4201

ozra opened this issue Oct 3, 2018 · 3 comments · Fixed by #4546

Comments

@ozra
Copy link

ozra commented Oct 3, 2018

Having a few nested arrow functions that throw away the argument shouldn't be considered shadowing. Bad taste perhaps. But not shadowing.

@lukyth
Copy link

lukyth commented Oct 7, 2018

What about a case when _ was used for lodash; i.e. import _ from 'lodash'? _ in function argument would probably be considered as shadowed in that case.

An option to allow some variable name to be shadowed like what ESLint does with its no-shadow rule might be better. Then shadowed _ can be allowed if lodash is not being used.

@tao-cumplido
Copy link

Just came across this myself when I noticed that typescripts lets me use _ as argument name with compiler flag noUnusedParameters enabled.

I then stumbled upon this issue which states that any name starting with _ is allowed and suggests using names like _1, _2, etc. for multiple unused parameters. The same approach can be used to prevent the linting rule from triggering.

@JoshuaKGoldberg
Copy link
Contributor

Seems reasonable to add an opt-in option for the rule to enable this kind of shadowing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants