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

Check if the shorthand fragment syntax requires a key prop (react/jsx-key) #1575

Closed
feross opened this issue Oct 28, 2020 · 0 comments
Closed

Comments

@feross
Copy link
Member

feross commented Oct 28, 2020

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md


Let's enable the new option checkFragmentShorthand in standard:

    "react/jsx-key": ["error", {
      "checkFragmentShorthand": true,
    }],

Warn if an element that likely requires a key prop--namely, one present in an
array literal or an arrow function expression.

Rule Options

...
"react/jsx-key": [<enabled>, { "checkFragmentShorthand": <boolean> }]
...

checkFragmentShorthand (default: false)

When true the rule will check if usage of the [shorthand fragment syntax][short_syntax] requires a key. This option was added to avoid a breaking change and will be the default in the next major version.

Examples of incorrect code for this rule:

[<></>, <></>, <></>];

data.map(x => <>{x}</>);
@feross feross added this to the standard 16 milestone Oct 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

1 participant