eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

Add `no-duplicate-literal-elements` rule

Open SidStraw opened this issue 2 years ago • 13 comments

add no-duplicate-literal-elements rule to fixes #1559

SidStraw avatar Dec 14 '21 15:12 SidStraw

Thanks for working on this.

sindresorhus avatar Dec 14 '21 17:12 sindresorhus

It should handle array too: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1559#issuecomment-951072358

sindresorhus avatar Dec 14 '21 17:12 sindresorhus

It should handle array too: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1559#issuecomment-951072358

OK, thx.

I will make up.

SidStraw avatar Dec 14 '21 17:12 SidStraw

Hello @sindresorhus, We have some question about CI / lint-test and CI / integration which includes some failing test. But not sure how to fix. Could you provide some suggestion for that, Thank you every much!!!

kayac-chang avatar Dec 15 '21 04:12 kayac-chang

@kayac-chang Please write your comments in English. It's fine to use Google Translate, but you should not force everyone else to have to do that.

sindresorhus avatar Dec 15 '21 11:12 sindresorhus

@sindresorhus Thank you for your review. I have made corrections and added Array checks, doc updates, and new tests.

~But I have the same problem as @kayac-chang~ ~It's about CI / lint-test and CI / integration which includes some failing tests.~ ~But not sure how to fix it.~ ~Could you provide some suggestions for that, Thank you very much.~ The latest CI fail message is easier to understand, I will try to fix it. Thank you very much.

By the way, my English is not good. So if there is something wrong with the text, please let me know or provide suggestions, thank you very much.

SidStraw avatar Dec 15 '21 16:12 SidStraw

This rule just reported the first duplicate index now.

And I have tried to fix the CI fail.

SidStraw avatar Dec 16 '21 17:12 SidStraw

I don't think this rule should limited to Literals,

const set = new Set([
	undefined,
	undefined,
	foo,
	foo,
	foo.bar,
	foo.bar,
])

This is obviously duplicated, I think we can try analyze the value, instead of only checking literals.

fisker avatar Dec 17 '21 06:12 fisker

I don't think this rule should limited to Literals,

const set = new Set([
	undefined,
	undefined,
	foo,
	foo,
	foo.bar,
	foo.bar,
])

This is obviously duplicated, I think we can try analyze the value, instead of only checking literals.

This is an interesting suggestion, we need to confirm with @sindresorhus and @futpib .

And do I need to update the rule name?

SidStraw avatar Dec 17 '21 07:12 SidStraw

This is an interesting suggestion, we need to confirm with @sindresorhus and @futpib .

Yeah, makes sense.

And do I need to update the rule name?

Maybe no-duplicate-elements.

sindresorhus avatar Dec 19 '21 23:12 sindresorhus

Bump :)

sindresorhus avatar Feb 16 '22 15:02 sindresorhus

Sorry, I didn't ignore this PR. It's just that I don't have a way forward.

SidStraw avatar Feb 20 '22 07:02 SidStraw

It's just that I don't have a way forward.

What are you stuck on?

sindresorhus avatar Mar 16 '22 09:03 sindresorhus

Closing for lack of activity.

sindresorhus avatar Sep 20 '22 08:09 sindresorhus