[Enterprise Search] eslint rule update: react/jsx-boolean-value (#90345)

* [Setup] Split rule that explicitly allows `any` in test/mock files into its own section

- so that the rules we're about to add apply correctly to all files

* Add react/jsx-boolean-value rule

* Run --fix

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Constance 2021-02-05 09:01:01 -08:00 committed by GitHub
parent 6ccb716c9c
commit 3166ff3761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 76 additions and 74 deletions

View file

@ -1114,10 +1114,18 @@ module.exports = {
* Enterprise Search overrides
*/
{
// All files
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'react/jsx-boolean-value': ['error', 'never'],
},
},
{
// Source files only - allow `any` in test/mock files
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
excludedFiles: ['x-pack/plugins/enterprise_search/**/*.{test,mock}.{ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'@typescript-eslint/no-explicit-any': 'error',
},
},

View file

@ -106,7 +106,7 @@ export const Credentials: React.FC = () => {
<EuiButton
color="primary"
data-test-subj="CreateAPIKeyButton"
fill={true}
fill
onClick={() => showCredentialsForm()}
>
{i18n.translate('xpack.enterpriseSearch.appSearch.credentials.createKey', {

View file

@ -35,7 +35,7 @@ export const CredentialsFlyoutFooter: React.FC = () => {
<EuiFlexItem grow={false}>
<EuiButton
onClick={onApiTokenChange}
fill={true}
fill
color="secondary"
iconType="check"
data-test-subj="APIKeyActionButton"

View file

@ -17,7 +17,7 @@ export const CredentialsFlyoutHeader: React.FC = () => {
const { activeApiToken } = useValues(CredentialsLogic);
return (
<EuiFlyoutHeader hasBorder={true}>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2 id={FLYOUT_ARIA_LABEL_ID}>
{activeApiToken.id

View file

@ -22,8 +22,8 @@ export const CredentialsFlyout: React.FC = () => {
<EuiPortal>
<EuiFlyout
onClose={hideCredentialsForm}
hideCloseButton={true}
ownFocus={true}
hideCloseButton
ownFocus
aria-labelledby={FLYOUT_ARIA_LABEL_ID}
size="s"
>

View file

@ -207,7 +207,7 @@ describe('Credentials', () => {
isHidden: expect.any(Boolean),
text: (
<span aria-label="Hidden text">
<span aria-hidden={true}></span>
<span aria-hidden></span>
</span>
),
});

View file

@ -19,7 +19,7 @@ export const DocumentCreationButton: React.FC = () => {
return (
<>
<EuiButton
fill={true}
fill
color="primary"
data-test-subj="IndexDocumentsButton"
onClick={showCreationModes}

View file

@ -82,7 +82,7 @@ export const CustomizationModal: React.FC<Props> = ({
defaultMessage: 'Filter fields',
}
)}
fullWidth={true}
fullWidth
helpText={i18n.translate(
'xpack.enterpriseSearch.appSearch.documents.search.customizationModal.filterFields',
{
@ -93,7 +93,7 @@ export const CustomizationModal: React.FC<Props> = ({
>
<EuiComboBox
data-test-subj="filterFieldsDropdown"
fullWidth={true}
fullWidth
options={selectableFilterFields}
selectedOptions={selectedFilterFields}
onChange={setSelectedFilterFields}
@ -106,7 +106,7 @@ export const CustomizationModal: React.FC<Props> = ({
defaultMessage: 'Sort fields',
}
)}
fullWidth={true}
fullWidth
helpText={i18n.translate(
'xpack.enterpriseSearch.appSearch.documents.search.customizationModal.sortFields',
{
@ -117,7 +117,7 @@ export const CustomizationModal: React.FC<Props> = ({
>
<EuiComboBox
data-test-subj="sortFieldsDropdown"
fullWidth={true}
fullWidth
options={selectableSortFields}
selectedOptions={selectedSortFields}
onChange={setSelectedSortFields}

View file

@ -80,7 +80,7 @@ export const SearchExperience: React.FC = () => {
<div className="documentsSearchExperience">
<SearchProvider config={searchProviderConfig}>
<SearchBox
searchAsYouType={true}
searchAsYouType
inputProps={{
placeholder: i18n.translate(
'xpack.enterpriseSearch.appSearch.documents.search.placeholder',

View file

@ -87,7 +87,7 @@ export const MultiCheckboxFacetsView: React.FC<Props> = ({
options={checkboxGroupOptions}
idToSelectedMap={idToSelectedMap}
onChange={onChange}
compressed={true}
compressed
/>
{showMore && (
<>

View file

@ -34,7 +34,7 @@ describe('ResultView', () => {
it('renders', () => {
const wrapper = shallow(
<ResultView result={result} schemaForTypeHighlights={schema} isMetaEngine={true} />
<ResultView result={result} schemaForTypeHighlights={schema} isMetaEngine />
);
expect(wrapper.find(Result).props()).toEqual({
result,

View file

@ -22,7 +22,7 @@ export const ResultView: React.FC<Props> = ({ result, schemaForTypeHighlights, i
<li>
<Result
result={result}
shouldLinkToDetailPage={true}
shouldLinkToDetailPage
schemaForTypeHighlights={schemaForTypeHighlights}
isMetaEngine={isMetaEngine}
/>

View file

@ -105,7 +105,7 @@ export const EngineNav: React.FC = () => {
{canViewEngineAnalytics && (
<SideNavLink
to={generateEnginePath(ENGINE_ANALYTICS_PATH)}
shouldShowActiveForSubroutes={true}
shouldShowActiveForSubroutes
data-test-subj="EngineAnalyticsLink"
>
{ANALYTICS_TITLE}
@ -114,7 +114,7 @@ export const EngineNav: React.FC = () => {
{canViewEngineDocuments && (
<SideNavLink
to={generateEnginePath(ENGINE_DOCUMENTS_PATH)}
shouldShowActiveForSubroutes={true}
shouldShowActiveForSubroutes
data-test-subj="EngineDocumentsLink"
>
{DOCUMENTS_TITLE}

View file

@ -198,7 +198,7 @@ export const Library: React.FC = () => {
<h3>With a link</h3>
</EuiTitle>
<EuiSpacer />
<Result {...props} shouldLinkToDetailPage={true} />
<Result {...props} shouldLinkToDetailPage />
<EuiSpacer />
<EuiSpacer />

View file

@ -62,7 +62,7 @@ describe('Result', () => {
});
it('passes showScore, resultMeta, and isMetaEngine to ResultHeader', () => {
const wrapper = shallow(<Result {...props} showScore={true} isMetaEngine={true} />);
const wrapper = shallow(<Result {...props} showScore isMetaEngine />);
expect(wrapper.find(ResultHeader).props()).toEqual({
isMetaEngine: true,
showScore: true,
@ -76,7 +76,7 @@ describe('Result', () => {
describe('document detail link', () => {
it('will render a link if shouldLinkToDetailPage is true', () => {
const wrapper = shallow(<Result {...props} shouldLinkToDetailPage={true} />);
const wrapper = shallow(<Result {...props} shouldLinkToDetailPage />);
wrapper.find(ReactRouterHelper).forEach((link) => {
expect(link.prop('to')).toEqual('/engines/my-engine/documents/1');
});
@ -96,7 +96,7 @@ describe('Result', () => {
it('will render field details with type highlights if schemaForTypeHighlights has been provided', () => {
const wrapper = shallow(
<Result {...props} shouldLinkToDetailPage={true} schemaForTypeHighlights={schema} />
<Result {...props} shouldLinkToDetailPage schemaForTypeHighlights={schema} />
);
expect(wrapper.find(ResultField).map((rf) => rf.prop('type'))).toEqual([
'text',

View file

@ -34,7 +34,7 @@ describe('ResultHeader', () => {
describe('score', () => {
it('renders score if showScore is true ', () => {
const wrapper = shallow(
<ResultHeader showScore={true} resultMeta={resultMeta} isMetaEngine={false} />
<ResultHeader showScore resultMeta={resultMeta} isMetaEngine={false} />
);
expect(wrapper.find('[data-test-subj="ResultScore"]').prop('value')).toEqual(100);
});
@ -51,12 +51,12 @@ describe('ResultHeader', () => {
it('renders engine name if this is a meta engine', () => {
const wrapper = shallow(
<ResultHeader
showScore={true}
showScore
resultMeta={{
...resultMeta,
id: '1',
}}
isMetaEngine={true}
isMetaEngine
/>
);
expect(wrapper.find('[data-test-subj="ResultEngine"]').prop('value')).toBe('my-engine');
@ -65,7 +65,7 @@ describe('ResultHeader', () => {
it('does not render an engine if this is not a meta engine', () => {
const wrapper = shallow(
<ResultHeader
showScore={true}
showScore
resultMeta={{
...resultMeta,
id: '1',

View file

@ -65,7 +65,7 @@ describe('AppSearchConfigured', () => {
const initializeAppData = jest.fn();
setMockActions({ initializeAppData });
shallow(<AppSearchConfigured ilmEnabled={true} />);
shallow(<AppSearchConfigured ilmEnabled />);
expect(initializeAppData).toHaveBeenCalledWith({ ilmEnabled: true });
});

View file

@ -67,7 +67,7 @@ export const ProductCard: React.FC<ProductCardProps> = ({ product, image }) => {
<EuiButtonTo
fill
to={product.URL}
shouldNotCreateHref={true}
shouldNotCreateHref
onClick={() =>
sendEnterpriseSearchTelemetry({
action: 'clicked',

View file

@ -27,7 +27,7 @@ export const HiddenText: React.FC<Props> = ({ text, children }) => {
});
const hiddenText = isHidden ? (
<span aria-label={hiddenLabel}>
<span aria-hidden={true}>{text.replace(/./g, '•')}</span>
<span aria-hidden>{text.replace(/./g, '•')}</span>
</span>
) : (
text

View file

@ -41,7 +41,7 @@ export const IndexingStatus: React.FC<IIndexingStatusProps> = ({
return (
<>
{percentageComplete < 100 && (
<EuiPanel paddingSize="l" hasShadow={true}>
<EuiPanel paddingSize="l" hasShadow>
<IndexingStatusContent percentageComplete={percentageComplete} />
</EuiPanel>
)}

View file

@ -57,7 +57,7 @@ describe('Layout', () => {
});
it('renders a read-only mode callout', () => {
const wrapper = shallow(<Layout navigation={null} readOnlyMode={true} />);
const wrapper = shallow(<Layout navigation={null} readOnlyMode />);
expect(wrapper.find(EuiCallOut)).toHaveLength(1);
});

View file

@ -53,7 +53,7 @@ describe('EUI & React Router Component Helpers', () => {
});
it('passes down all ...rest props', () => {
const wrapper = shallow(<EuiLinkTo to="/" data-test-subj="foo" external={true} />);
const wrapper = shallow(<EuiLinkTo to="/" data-test-subj="foo" external />);
const link = wrapper.find(EuiLink);
expect(link.prop('external')).toEqual(true);

View file

@ -94,7 +94,7 @@ export const SchemaAddFieldModal: React.FC<ISchemaAddFieldModalProps> = ({
<EuiFormRow
label="Field name"
helpText={fieldNameNote}
fullWidth={true}
fullWidth
data-test-subj="SchemaAddFieldNameRow"
error={addFieldFormErrors}
isInvalid={!!addFieldFormErrors}
@ -103,10 +103,10 @@ export const SchemaAddFieldModal: React.FC<ISchemaAddFieldModalProps> = ({
placeholder="name"
type="text"
onChange={handleChange}
required={true}
required
value={rawFieldName}
fullWidth={true}
autoFocus={true}
fullWidth
autoFocus
isLoading={loading}
data-test-subj="SchemaAddFieldNameField"
/>
@ -132,7 +132,7 @@ export const SchemaAddFieldModal: React.FC<ISchemaAddFieldModalProps> = ({
<EuiButtonEmpty onClick={closeAddFieldModal}>{FIELD_NAME_MODAL_CANCEL}</EuiButtonEmpty>
<EuiButton
color="primary"
fill={true}
fill
disabled={disableForm}
type="submit"
isLoading={loading}

View file

@ -78,20 +78,14 @@ export const CredentialItem: React.FC<CredentialItemProps> = ({
</EuiFlexItem>
<EuiFlexItem>
{!isVisible ? (
<EuiFieldPassword
placeholder={label}
value={value}
readOnly
compressed={true}
disabled
/>
<EuiFieldPassword placeholder={label} value={value} readOnly compressed disabled />
) : (
<EuiFieldText
readOnly={true}
readOnly
placeholder="Compressed"
data-test-subj={`${testSubj}Input`}
value={value}
compressed={true}
compressed
onClick={inputSelectAll}
/>
)}

View file

@ -63,7 +63,7 @@ describe('WorkplaceSearchConfigured', () => {
});
it('initializes app data with passed props', () => {
shallow(<WorkplaceSearchConfigured isFederatedAuth={true} />);
shallow(<WorkplaceSearchConfigured isFederatedAuth />);
expect(initializeAppData).toHaveBeenCalledWith({ isFederatedAuth: true });
});

View file

@ -36,7 +36,7 @@ export const AddSourceHeader: React.FC<AddSourceHeaderProps> = ({
<EuiFlexItem grow={false}>
<SourceIcon
serviceType={serviceType}
fullBleed={true}
fullBleed
name={name}
className="adding-a-source__icon"
/>

View file

@ -109,7 +109,7 @@ export const AddSourceList: React.FC = () => {
data-test-subj="FilterSourcesInput"
value={filterValue}
onChange={handleFilterChange}
fullWidth={true}
fullWidth
placeholder={ADD_SOURCE_PLACEHOLDER}
/>
</EuiFormRow>

View file

@ -118,7 +118,7 @@ export const DisplaySettings: React.FC<DisplaySettingsProps> = ({ tabId }) => {
description={DISPLAY_SETTINGS_DESCRIPTION}
action={
hasDocuments ? (
<EuiButton type="submit" disabled={!unsavedChanges} fill={true}>
<EuiButton type="submit" disabled={!unsavedChanges} fill>
{SAVE_BUTTON}
</EuiButton>
) : null

View file

@ -73,9 +73,9 @@ export const FieldEditorModal: React.FC = () => {
<EuiSelect
options={isEditing ? fieldOptions : availableFieldOptions}
name="field"
required={true}
required
className="field-selector"
hasNoInitialSelection={true}
hasNoInitialSelection
data-test-subj="AvailableFieldOptions"
value={fieldName}
disabled={!!isEditing}
@ -85,7 +85,7 @@ export const FieldEditorModal: React.FC = () => {
<EuiFormRow label="Label">
<EuiFieldText
name="label"
required={true}
required
data-test-subj="VisibleFieldName"
value={label}
onChange={(e) => setLabel(e.target.value)}
@ -95,7 +95,7 @@ export const FieldEditorModal: React.FC = () => {
</EuiModalBody>
<EuiModalFooter>
<EuiButtonEmpty onClick={toggleFieldEditorModal}>{CANCEL_BUTTON}</EuiButtonEmpty>
<EuiButton data-test-subj="FieldSubmitButton" color="primary" fill={true} type="submit">
<EuiButton data-test-subj="FieldSubmitButton" color="primary" fill type="submit">
{ACTION_LABEL} {FIELD_LABEL}
</EuiButton>
</EuiModalFooter>

View file

@ -79,7 +79,7 @@ export const ResultDetail: React.FC = () => {
<EuiDroppable
droppableId="visible_fields"
className="visible-fields-container"
withPanel={true}
withPanel
>
<>
{detailFields.map(({ fieldName, label }, index) => (
@ -87,7 +87,7 @@ export const ResultDetail: React.FC = () => {
key={`${fieldName}-${index}`}
index={index}
draggableId={`${fieldName}-${index}`}
customDragHandle={true}
customDragHandle
spacing="m"
>
{(provided) => (

View file

@ -76,10 +76,10 @@ export const SearchResults: React.FC = () => {
>
<EuiSelect
options={fieldOptions}
required={true}
required
name="titleField"
className="field-selector"
hasNoInitialSelection={true}
hasNoInitialSelection
data-test-subj="TitleFieldSelect"
value={titleField || ''}
onChange={(e) => setTitleField(e.target.value)}
@ -88,9 +88,9 @@ export const SearchResults: React.FC = () => {
<EuiFormRow label="URL">
<EuiSelect
options={fieldOptions}
required={true}
required
className="field-selector"
hasNoInitialSelection={true}
hasNoInitialSelection
data-test-subj="UrlFieldSelect"
value={urlField || ''}
onChange={(e) => setUrlField(e.target.value)}
@ -110,7 +110,7 @@ export const SearchResults: React.FC = () => {
<EuiSelect
options={optionalFieldOptions}
className="field-selector"
hasNoInitialSelection={true}
hasNoInitialSelection
data-test-subj="SubtitleFieldSelect"
value={subtitleField || LEAVE_UNASSIGNED_FIELD}
onChange={({ target: { value } }) =>
@ -129,7 +129,7 @@ export const SearchResults: React.FC = () => {
<EuiSelect
options={optionalFieldOptions}
className="field-selector"
hasNoInitialSelection={true}
hasNoInitialSelection
data-test-subj="DescriptionFieldSelect"
value={descriptionField || LEAVE_UNASSIGNED_FIELD}
onChange={({ target: { value } }) =>

View file

@ -122,7 +122,7 @@ export const Schema: React.FC = () => {
<EuiFlexItem>{addFieldButton}</EuiFlexItem>
<EuiFlexItem grow={false}>
{percentageComplete < 100 ? (
<EuiButton isLoading={true} fill={true}>
<EuiButton isLoading fill>
{SCHEMA_UPDATING}
</EuiButton>
) : (
@ -130,7 +130,7 @@ export const Schema: React.FC = () => {
disabled={formUnchanged}
data-test-subj="UpdateTypesButton"
onClick={updateFields}
fill={true}
fill
>
{SCHEMA_SAVE_BUTTON}
</EuiButton>

View file

@ -57,7 +57,7 @@ export const SchemaFieldsTable: React.FC = () => {
disabled={fieldName === 'id'}
key={fieldName}
fieldName={fieldName}
hideName={true}
hideName
fieldType={filteredSchemaFields[fieldName]}
updateExistingFieldType={updateExistingFieldType}
/>

View file

@ -109,7 +109,7 @@ export const PrivateSources: React.FC = () => {
const privateSourcesTable = (
<ContentSection>
<SourcesTable
showDetails={true}
showDetails
onSearchableToggle={setSourceSearchability}
sources={privateContentSources}
/>

View file

@ -73,7 +73,7 @@ export const AddGroupModal: React.FC<{}> = () => {
<EuiButton
disabled={!newGroupName}
onClick={saveNewGroup}
fill={true}
fill
data-test-subj="AddGroupSubmit"
>
{ADD_GROUP_SUBMIT}

View file

@ -41,7 +41,7 @@ export const FilterableUsersPopover: React.FC<FilterableUsersPopoverProps> = ({
return (
<EuiFilterGroup className={className}>
<EuiPopover
ownFocus={true}
ownFocus
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}
@ -54,7 +54,7 @@ export const FilterableUsersPopover: React.FC<FilterableUsersPopoverProps> = ({
addFilteredUser={addFilteredUser}
allGroupUsersLoading={allGroupUsersLoading}
removeFilteredUser={removeFilteredUser}
isPopover={true}
isPopover
/>
</EuiPopover>
</EuiFilterGroup>

View file

@ -96,7 +96,7 @@ export const GroupSourcePrioritization: React.FC = () => {
<EuiButton
disabled={groupPrioritiesUnchanged}
color="primary"
fill={true}
fill
onClick={saveGroupSourcePrioritization}
>
{HEADER_ACTION_TEXT}

View file

@ -91,7 +91,7 @@ export const GroupsTable: React.FC<{}> = () => {
</EuiTableBody>
</EuiTable>
<EuiSpacer size="m" />
{showPagination && <TablePaginationBar {...paginationOptions} hideLabelCount={true} />}
{showPagination && <TablePaginationBar {...paginationOptions} hideLabelCount />}
</>
);
};

View file

@ -44,7 +44,7 @@ export const TableFilterUsersDropdown: React.FC<{}> = () => {
<FilterableUsersPopover
users={users}
selectedOptions={filteredUsers}
itemsClickable={true}
itemsClickable
isPopoverOpen={filterUsersDropdownOpen}
button={filterButton}
closePopover={closeFilterUsersDropdown}

View file

@ -41,7 +41,7 @@ export const TableFilters: React.FC = () => {
<EuiFieldSearch
value={filterValue}
onChange={handleSearchChange}
fullWidth={true}
fullWidth
placeholder={FILTER_GROUPS_PLACEHOLDER}
/>
</EuiFlexItem>

View file

@ -86,7 +86,7 @@ export const Groups: React.FC = () => {
const headerAction = (
<EuiFlexGroup responsive={false} gutterSize="m">
<EuiFlexItem grow={false}>
<EuiButton data-test-subj="AddGroupButton" fill={true} onClick={openNewGroupModal}>
<EuiButton data-test-subj="AddGroupButton" fill onClick={openNewGroupModal}>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.groups.addGroupForm.action', {
defaultMessage: 'Create a group',
})}