-
Notifications
You must be signed in to change notification settings - Fork 657
📎 Lint cases similar to no-dupe-keys
#3731
Comments
Can someone label and if necessary add to #3358 or another appropriate umbrella please :) |
That's done
You can use Overall, I agree with your idea to where we should draw the line. Actually, now that I think about it, why don't split the rule in three? As far I can see, there are some niche cases that ... yes, they eventually do the same, but their use cases can differ. For example, cases where we check for number literals or computed properties. The check of number literals seems to me a niche case (personally , I never encountered such cases) for libraries that work with graphs, animations or rendering engines, and we could not recommend and people opt-in only if they want. For computed properties, it's mostly for us to help our mental sanity, because the logic can be quite messy and complex. |
@ematipico three rules would make sense to me. I think they should be something like
Is this what you envisioned too? |
no-dupe-keys
lint casesno-dupe-keys
That's it! I am going to update the umbrella issue :) |
Closing in favour of #3739 , where the new rules are tracked there |
Description
#3562 provided the initial implementation of
no-dupe-keys
for #3364However, ESLint's
no-dupe-keys
covers cases that the initial implementation does not cover yet.Namely, keys that are differently formatted numbers (e.g.
1
vs0x1
).These cases are documented in the test:
tools/crates/rome_js_analyze/tests/specs/nursery/noDupeKeys.js
Lines 17 to 29 in 8c38054
We can additionally think about whether we want to fail lint on
a
vs['a']
too. However, my stance on this is that stopping short of computed property names is a good place to draw the line. Analyzing computed properties and lintinga
vs['a']
specifically because there is a single literal in the computed property, but not lintinga
vs['' + 'a']
or vs[a /* const a = 'a' */]
because it's there seems like a much weirder place to draw the line 😅I think we should not do it just because ESLint does it. Instead, I think we should have another rule that autofixes
['a']
toa
.@xunilrj @ematipico do you agree? (always a gamble if I figured out the right people to tag :P)
The text was updated successfully, but these errors were encountered: