Skip to content
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

Possible new rule-disallow naming a variable in a function the same as a function parameter #891

Open
capaj opened this issue May 19, 2017 · 2 comments

Comments

@capaj
Copy link
Contributor

commented May 19, 2017

I'd like to have a rule against naming variables in a function the same as a function parameter.
It makes code unreadable, because it requires the reader to resolve the scope of current variable based on scoping rules and that's not always easy, especially with let.
I don't think there is an eslint rule for this, but if there would be a a positive stance toward this rule by standard maintainers I'd love to write such a rule.

example of invalid code:

function (a) {
  let a
}
@dcousens

This comment has been minimized.

Copy link
Member

commented May 19, 2017

http://eslint.org/docs/rules/no-redeclare

It is enabled... your example doesn't work.

@capaj

This comment has been minimized.

Copy link
Contributor Author

commented May 19, 2017

@dcousens sorry, what I meant was:

function (a) {
  if (a) {
    let a = 1
    console.log(a)
  }
}

this one is valid currently.

@dcousens dcousens reopened this May 19, 2017

@Flet Flet added enhancement and removed need more info labels Nov 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.