Browse Source

fix(react-eslint): Enable the recommended react eslint rules

Previously was included but not enabled. The errors fixed are:

app/routes.js:9:16
  ✖    9:16  Component definition is missing display name  react/display-name

  app/routes/contacts/components/Contacts.js:151:49
  ✖  151:49  Missing "key" prop for element in iterator    react/jsx-key
  ✖  167:22  Missing "key" prop for element in iterator    react/jsx-key
renovate/lint-staged-8.x
Ben Woosley 7 years ago
parent
commit
b3a4a3683c
  1. 5
      .eslintrc
  2. 4
      app/routes.js
  3. 8
      app/routes/contacts/components/Contacts.js

5
.eslintrc

@ -4,7 +4,10 @@
"sourceType": "module", "sourceType": "module",
"allowImportExportEverywhere": true "allowImportExportEverywhere": true
}, },
"extends": "airbnb", "extends": [
"airbnb",
"plugin:react/recommended"
],
"env": { "env": {
"browser": true, "browser": true,
"node": true "node": true

4
app/routes.js

@ -6,7 +6,7 @@ import Activity from './routes/activity'
import Contacts from './routes/contacts' import Contacts from './routes/contacts'
import Network from './routes/network' import Network from './routes/network'
export default () => ( const routes = () => (
<App> <App>
<Switch> <Switch>
<Route path='/contacts' component={Contacts} /> <Route path='/contacts' component={Contacts} />
@ -15,3 +15,5 @@ export default () => (
</Switch> </Switch>
</App> </App>
) )
export default routes

8
app/routes/contacts/components/Contacts.js

@ -148,23 +148,21 @@ class Contacts extends Component {
<ul className={`${styles.friends} ${filterPulldown && styles.fade}`}> <ul className={`${styles.friends} ${filterPulldown && styles.fade}`}>
{ {
loadingChannelPubkeys.map(pubkey => <LoadingContact pubkey={pubkey} isClosing={false} />) loadingChannelPubkeys.map(pubkey => <LoadingContact pubkey={pubkey} isClosing={false} key={pubkey} />)
} }
{ {
currentChannels.length > 0 && currentChannels.map((channel, index) => { currentChannels.length > 0 && currentChannels.map((channel, index) => {
if (closingChannelIds.includes(channel.chan_id)) { if (closingChannelIds.includes(channel.chan_id)) {
return <LoadingContact pubkey={channel.remote_pubkey} isClosing /> return <LoadingContact pubkey={channel.remote_pubkey} isClosing key={index} />
} else if (Object.prototype.hasOwnProperty.call(channel, 'blocks_till_open')) { } else if (Object.prototype.hasOwnProperty.call(channel, 'blocks_till_open')) {
return <PendingContact channel={channel} key={index} /> return <PendingContact channel={channel} key={index} />
} else if (Object.prototype.hasOwnProperty.call(channel, 'closing_txid')) { } else if (Object.prototype.hasOwnProperty.call(channel, 'closing_txid')) {
return <ClosingContact channel={channel} key={index} /> return <ClosingContact channel={channel} key={index} />
} else if (channel.active) {
return <OnlineContact channel={channel} key={index} openContactModal={openContactModal} />
} else if (!channel.active) { } else if (!channel.active) {
return <OfflineContact channel={channel} key={index} openContactModal={openContactModal} /> return <OfflineContact channel={channel} key={index} openContactModal={openContactModal} />
} }
return <span /> return <OnlineContact channel={channel} key={index} openContactModal={openContactModal} />
}) })
} }
</ul> </ul>

Loading…
Cancel
Save