jsx-eslint / jsx-eslint/eslint-plugin-react

[jsx-key]: report on `yield`

Open
#352 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted rule
Dominant language
JavaScript
Stars
9.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

Seems like yield <Component x={y}/> should be reported by jsx-key if there is no key prop.

This is valid:

for (let [idx, datum] of data.entries()) {
  yield (<MyComponent datum={datum} key={idx} />)
}

This is reported:

for (let [idx, datum] of data.entries()) {
  yield (<MyComponent datum={datum} />) // msg: need `key` prop
}

I can knock this out, if it makes sense.

(cc #332 as it will likely conflict with this if completed concurrently.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the jsx-key rule and use the issue's two yield examples as the behavioral cases. Confirm that a yielded component without a key is reported while the keyed example is accepted, and add or update the rule's tests to preserve both outcomes.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript, react
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.