Skip to content
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

ESLint: Enable react/jsx-boolean-value for the Gutenberg codebase and fix #59557

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module.exports = {
},
rules: {
'jest/expect-expect': 'off',
'react/jsx-boolean-value': 'error',
'@wordpress/dependency-group': 'error',
'@wordpress/is-gutenberg-plugin': 'error',
'@wordpress/react-no-unsafe-timeout': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function InstalledBlocksPrePublishPanel() {
),
newBlockTypes.length
) }
initialOpen={ true }
initialOpen
>
<p className="installed-blocks-pre-publish-panel__copy">
{ _n(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function BlockInvalidWarning( { clientId } ) {
return (
<TouchableWithoutFeedback
onPress={ attemptBlockRecovery }
accessible={ true }
accessible
accessibilityRole={ 'button' }
>
<Warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ const BlockSelectionButton = ( {
onPress={ () => {
/* Open BottomSheet with markup. */
} }
disabled={
true
} /* Disable temporarily since onPress function is empty. */
disabled /* Disable temporarily since onPress function is empty. */
>
{ rootClientId &&
rootBlockIcon && [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const BlockMover = ( {
options={ blockPageMoverOptions }
onChange={ onPickerSelect }
title={ __( 'Change block position' ) }
leftAlign={ true }
leftAlign
hideCancelButton={ Platform.OS !== 'ios' }
/>
</ToolbarGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function BlockRenameModal( {
__next40pxDefaultSize
value={ editedBlockName }
label={ __( 'Block name' ) }
hideLabelFromVision={ true }
hideLabelFromVision
placeholder={ originalBlockName }
onChange={ setEditedBlockName }
onFocus={ autoSelectInputText }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const BlockTransformationsMenu = ( {
options={ pickerOptions() }
onChange={ onPickerSelect }
hideCancelButton={ Platform.OS !== 'ios' }
leftAlign={ true }
leftAlign
getAnchor={ getAnchor }
// translators: %s: block title e.g: "Paragraph".
title={ sprintf( __( 'Transform %s to' ), blockTitle ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const BlockActionsMenu = ( {
<ToolbarButton
title={ __( 'Open Block Actions Menu' ) }
icon={ moreHorizontalMobile }
disabled={ true }
disabled
/>
</ToolbarGroup>
);
Expand Down Expand Up @@ -311,7 +311,7 @@ const BlockActionsMenu = ( {
destructiveButtonIndex={ options.length }
disabledButtonIndices={ disabledButtonIndices }
hideCancelButton={ Platform.OS !== 'ios' }
leftAlign={ true }
leftAlign
getAnchor={ getAnchor }
// translators: %s: block title e.g: "Paragraph".
title={ sprintf( __( '%s block options' ), blockTitle ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Caption = ( {
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
}
deleteEnter={ true }
deleteEnter
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function ChildLayoutControl( {
flexSize: newFlexSize,
} );
} }
isBlock={ true }
isBlock
>
<ToggleGroupControlOption
key={ 'fit' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function ColorPaletteControl( {
onColorChange={ onChange }
colorValue={ value }
gradients={ [] }
disableCustomGradients={ true }
disableCustomGradients
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe( 'ColorPaletteControl', () => {
] }
gradients={ [] }
disableCustomColors={ false }
disableCustomGradients={ true }
disableCustomGradients
onColorChange={ noop }
onGradientChange={ noop }
/>
Expand Down Expand Up @@ -102,7 +102,7 @@ describe( 'ColorPaletteControl', () => {
slug: 'light-green-cyan-to-vivid-green-cyan',
},
] }
disableCustomColors={ true }
disableCustomColors
disableCustomGradients={ false }
onColorChange={ noop }
onGradientChange={ noop }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe( 'ContrastChecker', () => {
<ContrastChecker
backgroundColor="#C44B4B"
textColor="#000000"
isLargeText={ true }
isLargeText
/>
);

Expand Down Expand Up @@ -263,7 +263,7 @@ describe( 'ContrastChecker', () => {
backgroundColor="#C44B4B"
textColor="#000000"
fontSize={ 23 }
isLargeText={ true }
isLargeText
/>
);

Expand Down Expand Up @@ -363,7 +363,7 @@ describe( 'ContrastChecker', () => {
backgroundColor={ backgroundColor }
textColor={ textColor }
isLargeText={ isLargeText }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -378,7 +378,7 @@ describe( 'ContrastChecker', () => {
textColor={ 'rgba(0,0,0,0.9)' }
linkColor={ linkColor }
isLargeText={ isLargeText }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -399,7 +399,7 @@ describe( 'ContrastChecker', () => {
linkColor={ 'rgba(0,0,0,0.9)' }
textColor={ textColor }
isLargeText={ isLargeText }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -420,7 +420,7 @@ describe( 'ContrastChecker', () => {
textColor={ textColor }
linkColor={ linkColor }
isLargeText={ isLargeText }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -437,7 +437,7 @@ describe( 'ContrastChecker', () => {
isLargeText={ isLargeText }
fallbackBackgroundColor={ fallbackBackgroundColor }
fallbackTextColor={ fallbackTextColor }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -454,7 +454,7 @@ describe( 'ContrastChecker', () => {
isLargeText={ isLargeText }
fallbackBackgroundColor={ fallbackBackgroundColor }
fallbackTextColor={ fallbackTextColor }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -477,7 +477,7 @@ describe( 'ContrastChecker', () => {
isLargeText={ isLargeText }
fallbackBackgroundColor={ fallbackBackgroundColor }
fallbackTextColor={ fallbackTextColor }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand All @@ -498,7 +498,7 @@ describe( 'ContrastChecker', () => {
linkColor={ 'rgba(0,0,0,0.7)' }
textColor={ 'rgba(0,0,0,0.7)' }
isLargeText={ isLargeText }
enableAlphaChecker={ true }
enableAlphaChecker
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ export default function BorderPanel( {
>
<BorderBoxControl
colors={ colors }
enableAlpha={ true }
enableAlpha
enableStyle={ showBorderStyle }
onChange={ onBorderChange }
popoverOffset={ 40 }
popoverPlacement="left-start"
value={ border }
__experimentalIsRenderedInSidebar={ true }
__experimentalIsRenderedInSidebar
size={ '__unstable-large' }
hideLabelFromVision={ ! hasShadowControl }
label={ __( 'Border' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function ImageSettingsPanel( {
hasValue={ () => !! value?.lightbox }
label={ __( 'Expand on click' ) }
onDeselect={ resetLightbox }
isShownByDefault={ true }
isShownByDefault
panelId={ panelId }
>
<ToggleControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export function MediaPreview( { media, onClick, category } ) {
const onMouseLeave = useCallback( () => setIsHovered( false ), [] );
return (
<>
<InserterDraggableBlocks isEnabled={ true } blocks={ [ block ] }>
<InserterDraggableBlocks isEnabled blocks={ [ block ] }>
{ ( { draggable, onDragStart, onDragEnd } ) => (
<div
className={ classnames(
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/inserter/menu.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function InserterMenu( {

return (
<BottomSheet
isVisible={ true }
isVisible
onClose={ onClose }
onKeyboardShow={ onKeyboardShow }
onKeyboardHide={ onKeyboardHide }
Expand All @@ -198,10 +198,10 @@ function InserterMenu( {
</>
}
hasNavigation
setMinHeightToMaxHeight={ true }
setMinHeightToMaxHeight
contentStyle={ styles[ 'inserter-menu__list' ] }
isFullScreen={ isFullScreen }
allowDragIndicator={ true }
allowDragIndicator
>
<BottomSheetConsumer>
{ ( { listProps } ) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
resetAll={ resetAll }
key={ panelId }
panelId={ panelId }
hasInnerWrapper={ true }
shouldRenderPlaceholderItems={ true } // Required to maintain fills ordering.
hasInnerWrapper
shouldRenderPlaceholderItems // Required to maintain fills ordering.
__experimentalFirstVisibleItemClass="first"
__experimentalLastVisibleItemClass="last"
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ControlledLineHeightControl = () => {
<LineHeightControl
value={ value }
onChange={ setValue }
__nextHasNoMarginBottom={ true }
__nextHasNoMarginBottom
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const LinkControlSearchInput = forwardRef(
showSuggestions ? handleRenderSuggestions : null
}
__experimentalFetchLinkSuggestions={ searchHandler }
__experimentalHandleURLSuggestions={ true }
__experimentalHandleURLSuggestions
__experimentalShowInitialSuggestions={
showInitialSuggestions
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function ListViewBranch( props ) {
level={ level }
setSize={ rowCount }
positionInSet={ rowCount }
isExpanded={ true }
isExpanded
>
<TreeGridCell>
{ ( treeGridCellProps ) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default function ListViewDropIndicatorPreview( {
className="block-editor-list-view-drop-indicator--preview"
variant="unstyled"
flip={ false }
resize={ true }
resize
>
<div
style={ style }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function ListViewComponent(
description && `block-editor-list-view-description-${ instanceId }`;

return (
<AsyncModeProvider value={ true }>
<AsyncModeProvider value>
<ListViewDropIndicatorPreview
draggedBlockClientId={ firstDraggedBlockClientId }
listViewRef={ elementRef }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const PanelColorSettings = ( { colorSettings, ...props } ) => {
<PanelColorGradientSettings
settings={ settings }
gradients={ [] }
disableCustomGradients={ true }
disableCustomGradients
{ ...props }
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe( 'PanelColorSettings', () => {
<PanelColorSettings
title="Test Title"
colors={ [] }
disableCustomColors={ true }
disableCustomColors
colorSettings={ [
{
value: '#000',
Expand All @@ -39,7 +39,7 @@ describe( 'PanelColorSettings', () => {
<PanelColorSettings
title="Test Title"
colors={ [] }
disableCustomColors={ true }
disableCustomColors
colorSettings={ [
{
value: '#000',
Expand All @@ -63,7 +63,7 @@ describe( 'PanelColorSettings', () => {
<PanelColorSettings
title="Test Title"
colors={ [] }
disableCustomColors={ true }
disableCustomColors
colorSettings={ [
{
value: '#000',
Expand Down
5 changes: 1 addition & 4 deletions packages/block-editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(

export const BlockEditorProvider = ( props ) => {
return (
<ExperimentalBlockEditorProvider
{ ...props }
stripExperimentalSettings={ true }
>
<ExperimentalBlockEditorProvider { ...props } stripExperimentalSettings>
{ props.children }
</ExperimentalBlockEditorProvider>
);
Expand Down
Loading
Loading