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

Rule suggestion : Arguments name should be unique #1880

Closed
ptitgraig opened this Issue Feb 26, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@ptitgraig

ptitgraig commented Feb 26, 2015

Hello.

I'd like to get yout input about this rule from SonarQube. Would that be interesting to get this rule in ESLint ?

Arguments name should be unique.
Function arguments should all have different names to prevent any ambiguity. Indeed, if arguments have the same name, the last duplicated argument hides all previous arguments with the same name (those previous arguments remain available through arguments[i], so they're not completely inaccessible. This hiding makes no sense, clearly reduces understandability and maintanability, and obviously can be error prone. Furthermore, in JavaScript strict mode, declaring arguments with the same name produces an error.

Thanks.

@nzakas

This comment has been minimized.

Show comment
Hide comment
@nzakas

nzakas Feb 26, 2015

Member

Sure, I'd call it no-dupe-args to go along with some of the other rules we have.

Member

nzakas commented Feb 26, 2015

Sure, I'd call it no-dupe-args to go along with some of the other rules we have.

@nzakas nzakas added enhancement accepted and removed triage labels Feb 26, 2015

@michaelficarra

This comment has been minimized.

Show comment
Hide comment
@michaelficarra

michaelficarra Feb 26, 2015

Member

If you enable strict node, this will be an early syntax error. The code would never even run. Is that not good enough?

Member

michaelficarra commented Feb 26, 2015

If you enable strict node, this will be an early syntax error. The code would never even run. Is that not good enough?

@nzakas

This comment has been minimized.

Show comment
Hide comment
@nzakas

nzakas Feb 26, 2015

Member

We already have rules for other strict mode things like duplicate keys (ES5) and no-with, so I think it makes sense to add this.

Member

nzakas commented Feb 26, 2015

We already have rules for other strict mode things like duplicate keys (ES5) and no-with, so I think it makes sense to add this.

@xjamundx

This comment has been minimized.

Show comment
Hide comment
@xjamundx

xjamundx Feb 26, 2015

Contributor

Should be super easy to add. I'll do it in a few days...

Contributor

xjamundx commented Feb 26, 2015

Should be super easy to add. I'll do it in a few days...

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Feb 27, 2015

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Feb 27, 2015

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Mar 2, 2015

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Mar 2, 2015

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Mar 3, 2015

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Mar 3, 2015

xjamundx pushed a commit to xjamundx/eslint that referenced this issue Mar 3, 2015

@nzakas nzakas closed this in 1d13729 Mar 3, 2015

nzakas added a commit that referenced this issue Mar 3, 2015

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

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