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

💅 lint/suspicious/noArrayIndexKey false negative in template literals #1575

Closed
1 task done
bc-m opened this issue Jan 16, 2024 · 1 comment · Fixed by #1586
Closed
1 task done

💅 lint/suspicious/noArrayIndexKey false negative in template literals #1575

bc-m opened this issue Jan 16, 2024 · 1 comment · Fixed by #1586
Assignees
Labels
A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@bc-m
Copy link

bc-m commented Jan 16, 2024

Environment information

@biomejs/biome 1.5.2

Rule name

lint/suspicious/noArrayIndexKey

Playground link

https://biomejs.dev/playground/?code=YwBvAG4AcwB0ACAAUgBlAG4AZABlAHIAQQByAHIAYQB5ACAAPQAgACgAKQAgAD0APgAgAHsACgAgACAAYwBvAG4AcwB0ACAAYQByAHIAIAA9ACAAWwAxACwAMgAsADMAXQA7AAoAIAAgAHIAZQB0AHUAcgBuACAAYQByAHIALgBmAG8AcgBFAGEAYwBoACgAKABpAHQAZQBtACwAIABpAG4AZABlAHgAKQAgAD0APgAgAHsACgAgACAAIAAgAC8ALwAgAHQAaAByAG8AdwBzACAAZQByAHIAbwByACAAYQBzACAAZQB4AHAAZQBjAHQAZQBkAAoAIAAgACAAIAByAGUAdAB1AHIAbgAgADwAZABpAHYAIABrAGUAeQA9AHsAaQBuAGQAZQB4AH0APgB7AGkAdABlAG0AfQA8AC8AZABpAHYAPgA7AAoAIAAgAH0AKQAKAH0ACgAKAGMAbwBuAHMAdAAgAFIAZQBuAGQAZQByAEEAcgByAGEAeQAyACAAPQAgACgAKQAgAD0APgAgAHsACgAgACAAYwBvAG4AcwB0ACAAYQByAHIAIAA9ACAAWwAxACwAMgAsADMAXQA7AAoAIAAgAHIAZQB0AHUAcgBuACAAYQByAHIALgBmAG8AcgBFAGEAYwBoACgAKABpAHQAZQBtACwAIABpAG4AZABlAHgAKQAgAD0APgAgAHsACgAgACAAIAAgAC8ALwAgAG4AbwAgAGUAcgByAG8AcgAgAHQAaAByAG8AdwBuACwAIABiAHUAdAAgAGUAeABwAGUAYwB0AGUAZAAgAGEAbgAgAGUAcgByAG8AcgAKACAAIAAgACAAcgBlAHQAdQByAG4AIAA8AGQAaQB2ACAAawBlAHkAPQB7AGAAdABlAHMAdAAtAGsAZQB5AC0AJAB7AGkAbgBkAGUAeAB9AGAAfQA%2BAHsAaQB0AGUAbQB9ADwALwBkAGkAdgA%2BADsACgAgACAAfQApAAoAfQA%3D

Expected result

Using an array index in a template literal key should cause an error as the ESLint rule "react/no-array-index-key": https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md

Throw a lint-error on usage array-index as key with a template literal.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@bc-m bc-m changed the title 💅 lint/suspicious/noArrayIndexKey 💅 lint/suspicious/noArrayIndexKey false negative in template literals Jan 16, 2024
@ematipico ematipico added S-Help-wanted Status: you're familiar with the code base and want to help the project A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug labels Jan 16, 2024
@ematipico
Copy link
Member

For whoever is going to work on this bug, the issue also affects strings, not only string literals:

arr.forEach((_, index) => {
	return <div key={"test" + index} />
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants