New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add no-shadow
#370
Comments
// @zanona |
I find the ability to shadow variables quite convenient in some cases. For example with const array = [];
const someResult = array.reduce((someResult, value) => {
// ...
}, {}); It's convenient because I never know how to name the accumalator^^. And it makes sense (at least to me) to name the variables that way as It's also convenient when using const params = [];
const param = params.find(param => param === 'something'); Maybe it's a lack of imagination for naming callback parameters, but it's a pattern I see being used relatively frequently. Overall I don't really see the problem with shadowing variables with a function parameter. const love = get();
for (const loopLove of feelings) {
// It's really easy here to use love instead of loopLove by mistake
} Naming variables with meaningful names is more important than shadowing considerations. What is important though is |
If you do that, loopLove will be marked as unused. On the other hand with the current situation you can use I agree with the first part for |
I thought xo had this one at some point: https://eslint.org/docs/rules/no-shadow
The text was updated successfully, but these errors were encountered: