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
Compare computed keys by tokens in no-dupe-keys #12070
Comments
What should happen in this situation, where the keys have side effects? /* eslint no-dupe-keys:error */
var foo = {
[a++]: 1,
[a++]: 2,
[b()]: 3,
[b()]: 4
} |
That would be bad. Maybe to compare just identifiers, I guess that's the most common use case. Albeit, in theory there could be something like this: var foo = {
[a]: a++,
[a]: 2,
} |
I know my comment kicked off this discussion, but given the discussion above, I agree that this doesn't seem like a case we can enforce reliably and safely. I think the current behavior probably makes the most sense. @mdjermanovic Thanks for exploring this! |
IMO this is a useful feature to implement, even if for the simple case of: var foo = {
[a]: 1,
[a]: 2,
} where the key isn't an expression (as @platinumazure noted) other than a simple variable reference. In our team, we've already had at least one painful debugging experience due to this. If the worry is that doing e.g. Or is there something else I'm not seeing here? |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
What rule do you want to change?
no-dupe-keys
Does this change cause the rule to produce more or fewer warnings?
More
How will the change be implemented? (New option, new default behavior, etc.)?
I'm not sure, it could be new default behavior.
Please provide some example code that this change will affect:
What does the rule currently do for this code?
No warnings.
What will the rule do after it's changed?
Warn about the duplicate key.
Are you willing to submit a pull request to implement this change?
Yes, I'll be glad to do it.
The text was updated successfully, but these errors were encountered: