Skip to content

Commit

Permalink
Fix "React keys must be passed directly to JSX without using spread" (#…
Browse files Browse the repository at this point in the history
…92075)

* Fix "React keys must be passed directly to JSX without spread"

* Add "react/jsx-key" rule as a warning for now
  • Loading branch information
manzoorwanijk committed Jun 25, 2024
1 parent 4742267 commit 3219e70
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/notifications/src/panel/templates/note-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class NoteList extends Component {
let [ notes ] = Object.entries( noteGroups ).reduce(
( [ list, isFirst ], [ timeGroupKey, timeGroupNotes ] ) => {
const title = groupTitles[ timeGroupKey ];
const header = <ListHeader { ...{ key: title, title, isFirst } } />;
const header = <ListHeader key={ title } title={ title } isFirst={ isFirst } />;

return [ [ ...list, header, ...timeGroupNotes.map( createNoteComponent ) ], false ];
},
Expand Down
2 changes: 1 addition & 1 deletion client/blocks/post-share/connections-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class ConnectionsList extends PureComponent {
<div className="post-share__connections">
{ connections.map( ( connection ) => (
<Connection
key={ connection.keyring_connection_ID }
{ ...{
connection,
onToggle,
isActive: connection.isActive,
key: connection.keyring_connection_ID,
} }
/>
) ) }
Expand Down
2 changes: 1 addition & 1 deletion client/blocks/sharing-preview-pane/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class SharingPreviewPane extends PureComponent {
</div>
<VerticalMenu onClick={ this.selectPreview } initialItemIndex={ initialMenuItemIndex }>
{ services.map( ( service ) => (
<SocialItem { ...{ key: service, service } } />
<SocialItem key={ service } service={ service } />
) ) }
</VerticalMenu>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/components/seo-preview-pane/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class SeoPreviewPane extends PureComponent {
</div>
<VerticalMenu onClick={ this.selectPreview }>
{ services.map( ( service ) => (
<SocialItem { ...{ key: service, service } } />
<SocialItem key={ service } service={ service } />
) ) }
</VerticalMenu>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin-wpcalypso/lib/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
plugins: [ 'react', 'react-hooks' ],
rules: {
'react/jsx-curly-spacing': [ 2, 'always' ],
'react/jsx-key': 1,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-target-blank': 2,
'react/jsx-no-undef': 2,
Expand Down

0 comments on commit 3219e70

Please sign in to comment.