Skip to content

Commit

Permalink
Enable eslint rule for missing jsx keys
Browse files Browse the repository at this point in the history
  • Loading branch information
muffinresearch committed May 18, 2017
1 parent 4d79108 commit a1c3fc9
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@
"react/prefer-stateless-function": "off",
"react/jsx-indent-props": "off",
"react/jsx-closing-bracket-location": "off",
// FIXME: Switch using .jsx for jsx files https://github.com/mozilla/addons-frontend/issues/969.
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/jsx-first-prop-new-line": "off",
"react/jsx-key": "error",
"react/no-string-refs": "error",
// FIXME: Deprecate use of findDOMNode https://github.com/mozilla/addons-frontend/issues/968
"react/no-find-dom-node": "off",
// FIXME: Switch using .jsx for jsx files https://github.com/mozilla/addons-frontend/issues/969.
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
},
"settings": {
"import/ignore": [
Expand Down
4 changes: 4 additions & 0 deletions src/admin/containers/AddonPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ class AddonPage extends React.Component {
];
if (addon.homepage) {
items.push([
// eslint-disable-next-line react/jsx-key
<a href={addon.homepage}
rel="external noopener noreferrer" target="_blank">{_('View homepage')}</a>,
'homepage',
]);
}
if (addon.support_email) {
items.push([
// eslint-disable-next-line react/jsx-key
<a href={`mailto:${addon.support_email}`}>{_('Email support')}</a>,
'support_email',
]);
}
if (addon.support_url) {
items.push([
// eslint-disable-next-line react/jsx-key
<a href={addon.support_url}
rel="external noopener noreferrer" target="_blank">{_('View support site')}</a>,
'support_url',
Expand Down Expand Up @@ -85,6 +88,7 @@ class AddonPage extends React.Component {
[file.status, 'status'],
[`${file.size} bytes`, 'size'],
[file.created, 'created'],
// eslint-disable-next-line react/jsx-key
[<a href={file.url}>{_('Download')}</a>, 'download'],
], 'file-info')}
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/amo/components/Categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CategoriesBase extends React.Component {
<ul className="Categories-list"
ref={(ref) => { this.categories = ref; }}>
{Object.values(categories).map((category) => (
<li className="Categories-list-item">
<li key={category.slug} className="Categories-list-item">
<Link className="Categories-link"
to={`/${visibleAddonType(addonType)}/${category.slug}/`}>
{category.name}
Expand Down
4 changes: 2 additions & 2 deletions src/amo/components/SearchSort/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class SearchSortBase extends React.Component {
{i18n.gettext('Sort')}
</a>
<ul id="SearchSortOptions" className="SearchSort-list">
{this.sortOptions().map((option) => (
<li className="SearchSort-list-item">
{this.sortOptions().map((option, index) => (
<li key={`sort-${index}`} className="SearchSort-list-item">
<SearchSortLink currentSort={currentSort} filters={filters}
pathname={pathname} sort={option.sort}>
{option.text}
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/Paginate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ export class PaginateBase extends React.Component {
page={currentPage - 1}
text={i18n.gettext('Previous')}
/>
{this.visiblePages({ pageCount }).map((page) =>
{this.visiblePages({ pageCount }).map((page, index) =>
<PaginatorLink
{...linkParams}
key={`page-${index}`}
page={page}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/ErrorList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ErrorList extends React.Component {

return (
<ul className={classNames('ErrorList', className)}>
{items.map((item) => <li className="ErrorList-item">{item}</li>)}
{items.map((item, index) => <li className="ErrorList-item" key={`erroritem-${index}`}>{item}</li>)}
</ul>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/components/Rating/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class RatingBase extends React.Component {
}

return (
// eslint-disable-next-line react/jsx-key
<button
onClick={this.onSelectRating}
value={thisRating}
Expand Down
1 change: 1 addition & 0 deletions tests/client/amo/containers/TestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('App', () => {
return <p>The component</p>;
}
}
// eslint-disable-next-line react/jsx-key
const root = render({ children: [<MyComponent />] });
const rootNode = findDOMNode(root);
assert.equal(rootNode.tagName.toLowerCase(), 'div');
Expand Down

0 comments on commit a1c3fc9

Please sign in to comment.