From 3a2977150d86f9166f4175c6b0e0753ab7f2256a Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Fri, 8 Nov 2024 12:04:51 +0200 Subject: [PATCH] Remove unnecessary boolean assignments (#66857) Co-authored-by: ntsekouras Co-authored-by: mcsf --- packages/block-library/src/cover/edit/index.js | 2 +- packages/block-library/src/paragraph/edit.js | 2 +- packages/block-library/src/search/index.php | 4 ++-- packages/components/CHANGELOG.md | 1 + .../src/border-control/border-control-dropdown/component.tsx | 2 +- packages/docgen/lib/index.js | 2 +- packages/e2e-test-utils-playwright/src/request-utils/rest.ts | 2 +- packages/media-utils/src/components/media-upload/index.js | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/cover/edit/index.js b/packages/block-library/src/cover/edit/index.js index 1202f28cee50cd..1c86d953bc0bab 100644 --- a/packages/block-library/src/cover/edit/index.js +++ b/packages/block-library/src/cover/edit/index.js @@ -471,7 +471,7 @@ function CoverEdit( { setAttributes( { minHeight: newMinHeight } ); }, // Hide the resize handle if an aspect ratio is set, as the aspect ratio takes precedence. - showHandle: ! attributes.style?.dimensions?.aspectRatio ? true : false, + showHandle: ! attributes.style?.dimensions?.aspectRatio, size: resizableBoxDimensions, width, }; diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index b7f4283d4ec671..b0dc5ab255af78 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -83,7 +83,7 @@ function DropCapControl( { clientId, attributes, setAttributes } ) { checked={ !! dropCap } onChange={ () => setAttributes( { dropCap: ! dropCap } ) } help={ helpText } - disabled={ hasDropCapDisabled( align ) ? true : false } + disabled={ hasDropCapDisabled( align ) } /> ); diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index e4259bb0ce2c7f..b74daf548a8025 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -31,8 +31,8 @@ function render_block_core_search( $attributes ) { $input_id = wp_unique_id( 'wp-block-search__input-' ); $classnames = classnames_for_block_core_search( $attributes ); - $show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false; - $use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false; + $show_label = ! empty( $attributes['showLabel'] ); + $use_icon_button = ! empty( $attributes['buttonUseIcon'] ); $show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true; $button_position = $show_button ? $attributes['buttonPosition'] : null; $query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array(); diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 93b191bff269d6..97cb5d117e17d2 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -17,6 +17,7 @@ ### Internal - `Snackbar`: Use link variant for action Button ([#66560](https://github.com/WordPress/gutenberg/pull/66560)). +- `BorderControl`: Remove unnecessary boolean assignments ([#66857](https://github.com/WordPress/gutenberg/pull/66857)). ## 28.11.0 (2024-10-30) diff --git a/packages/components/src/border-control/border-control-dropdown/component.tsx b/packages/components/src/border-control/border-control-dropdown/component.tsx index 827e7973a90432..707497ae2993c0 100644 --- a/packages/components/src/border-control/border-control-dropdown/component.tsx +++ b/packages/components/src/border-control/border-control-dropdown/component.tsx @@ -188,7 +188,7 @@ const BorderControlDropdown = ( tooltipPosition={ dropdownPosition } label={ __( 'Border color and style picker' ) } showTooltip - __next40pxDefaultSize={ size === '__unstable-large' ? true : false } + __next40pxDefaultSize={ size === '__unstable-large' } > { } sourceFile = path.join( processDir, sourceFile ); - const debugMode = options.debug ? true : false; + const debugMode = options.debug; const inputBase = path.join( path.dirname( sourceFile ), diff --git a/packages/e2e-test-utils-playwright/src/request-utils/rest.ts b/packages/e2e-test-utils-playwright/src/request-utils/rest.ts index 79b49dc3c7b646..45032947d7cc52 100644 --- a/packages/e2e-test-utils-playwright/src/request-utils/rest.ts +++ b/packages/e2e-test-utils-playwright/src/request-utils/rest.ts @@ -58,7 +58,7 @@ async function setupRest( this: RequestUtils ): Promise< StorageState > { return error; } - return nonce && rootURL ? true : false; + return !! ( nonce && rootURL ); }, { message: 'Failed to setup REST API.', diff --git a/packages/media-utils/src/components/media-upload/index.js b/packages/media-utils/src/components/media-upload/index.js index ed0a59ddbc684a..4067193f176062 100644 --- a/packages/media-utils/src/components/media-upload/index.js +++ b/packages/media-utils/src/components/media-upload/index.js @@ -327,7 +327,7 @@ class MediaUpload extends Component { state: currentState, multiple, selection, - editing: value && value.length ? true : false, + editing: !! value?.length, } ); wp.media.frame = this.frame; this.initializeListeners();