-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix eslint errors #86
base: 3.x
Are you sure you want to change the base?
Conversation
FacetType.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
onClick: PropTypes.string.isRequired, | ||
children: PropTypes.node.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could probably remove isRequired
and provide a default of []
instead. I think I did that in at least one other place.
return (searchField.value.map((val) => ( | ||
<FacetType | ||
key={searchField.field} | ||
id={searchField.field} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this to resolve a "don't use an index in the id" linting error. I don't think it changed/broke any behavior, but it's worth a look.
const MyFacetType = facetTypes[searchField.type]; | ||
return ( | ||
<MyFacetType | ||
key={searchField.field} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's another instance of changing the key, so we don't use a loop index value.
const pagination = query.pageStrategy === 'paginate' ? | ||
<PaginateComponent {...this.props} bootstrapCss={bootstrapCss} onChange={onPageChange} /> : | ||
null; | ||
/* eslint-disable react/jsx-props-no-spreading */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props
contains a lot of properties, and I wasn't clear what they all are. I believe this is a valid case to disable the rule instead of explicitly listing all of them every time. We can revisit this later, though, if needed.
@@ -124,7 +133,7 @@ class FederatedSolrFacetedSearch extends React.Component { | |||
|
|||
return ( | |||
<SearchComponent | |||
key={i} | |||
key={searchField.field} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the key here (like the others) and didn't notice any issues. Flagging this in case it is incorrect.
facetValues.forEach((v, i) => { | ||
const key = facetValues[i]; | ||
facetInputs[key] = facetCounts[i]; | ||
}); | ||
} | ||
|
||
const expanded = !(collapse || false); | ||
const expanded = !collapse; | ||
const height = expanded ? 'auto' : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example of a default value I moved to defaultProps
.
terms[type].items.forEach((termObj, j) => termObj.facetCount | ||
&& listFacetHierarchyTermsLis[type].push( | ||
<li className="fs-search-accordion__content-item" key={`${termObj.term}_${termObj.facetValue}_${j}`}> | ||
{/* eslint jsx-a11y/label-has-associated-control: ["error", { assert: "either" } ] */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, the linting rule requires both nesting and id
plus for
attributes. However, it seemed like generating IDs at this level was discouraged, so I used an override to allow nesting the control under the label to be sufficient.
@@ -178,31 +187,41 @@ class FederatedListFacet extends React.Component { | |||
const listFacetHierarchyLis = []; | |||
// Define array of checkbox Lis which we'll populate with react fragments, per type. | |||
const listFacetHierarchyTermsLis = []; | |||
|
|||
/* eslint-disable react/no-array-index-key */ | |||
|
|||
// Iterate through types (accordion lis). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure how to refactor this section to not use loop indexes in keys, so I temporarily disabled the rule. We may want to revisit this section later, so a TODO
might be in order here.
@@ -233,6 +257,7 @@ class FederatedListFacet extends React.Component { | |||
return ( | |||
<li className="fs-search-accordion__group-item" id={`solr-list-facet-${field}`}> | |||
<div | |||
role="button" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default in most browsers.
<li className={cx("fs-search-pager__item fs-search-pager__item--first", {"fs-element-invisible": firstPageHidden})} key="start"> | ||
<button className={cx("fs-search-pager__item-button fs-search-pager__item-button--first")} tabIndex={firstPageHidden ? "-1" : "0"} onClick={this.onPageChange.bind(this, 0)} onKeyPress={ this.buildHandleEnterKeyPress(this.onPageChange.bind(this, 0)) } title="Go to first page"> | ||
<li className={cx('fs-search-pager__item fs-search-pager__item--first', { 'fs-element-invisible': firstPageHidden })} key="start"> | ||
<button type="submit" className={cx('fs-search-pager__item-button fs-search-pager__item-button--first')} tabIndex={firstPageHidden ? '-1' : '0'} onClick={this.onPageChange.bind(this, 0)} onKeyPress={this.buildHandleEnterKeyPress(this.onPageChange.bind(this, 0))} title="Go to first page"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submit is the default type in most browsers.
FederatedSearchFieldContainer.propTypes = { | ||
children: PropTypes.array, | ||
onNewSearch: PropTypes.func, | ||
children: PropTypes.arrayOf(PropTypes.object), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used PropTypes.node
above, so I may need to change this. Also, I've used a default value here instead of isRequired
. Whichever is correct, I'll make these consistent.
I started looking at this and still see a lot of console errors: e.g.
|
The remaining errors all seem to be PropType mismatches, where we are mixing booleans and objects. That needs to be cleaned up. |
This reverts commit 78a6421.
No description provided.