diff --git a/bin/api-docs/gen-theme-reference.js b/bin/api-docs/gen-theme-reference.js index 6bb0e5d5b4ce2..07a8c2fcc697d 100644 --- a/bin/api-docs/gen-theme-reference.js +++ b/bin/api-docs/gen-theme-reference.js @@ -241,10 +241,13 @@ const formatType = ( prop ) => { const types = []; propTypes.forEach( ( item ) => { - if ( item.type ) types.push( item.type ); + if ( item.type ) { + types.push( item.type ); + } // refComplete is always an object - if ( item.$ref && item.$ref === '#/definitions/refComplete' ) + if ( item.$ref && item.$ref === '#/definitions/refComplete' ) { types.push( 'object' ); + } } ); type = [ ...new Set( types ) ].join( ', ' ); diff --git a/bin/plugin/commands/performance.js b/bin/plugin/commands/performance.js index edb5344d60e77..9d9b39fce0984 100644 --- a/bin/plugin/commands/performance.js +++ b/bin/plugin/commands/performance.js @@ -63,7 +63,9 @@ function sanitizeBranchName( branch ) { * @return {number|undefined} Median value or undefined if array empty. */ function median( array ) { - if ( ! array || ! array.length ) return undefined; + if ( ! array || ! array.length ) { + return undefined; + } const numbers = [ ...array ].sort( ( a, b ) => a - b ); const middleIndex = Math.floor( numbers.length / 2 ); diff --git a/packages/block-editor/src/components/alignment-control/ui.js b/packages/block-editor/src/components/alignment-control/ui.js index b41cb4b0d2520..9eb47533c5b7a 100644 --- a/packages/block-editor/src/components/alignment-control/ui.js +++ b/packages/block-editor/src/components/alignment-control/ui.js @@ -45,7 +45,9 @@ function AlignmentUI( { ); function setIcon() { - if ( activeAlignment ) return activeAlignment.icon; + if ( activeAlignment ) { + return activeAlignment.icon; + } return isRTL() ? alignRight : alignLeft; } diff --git a/packages/block-editor/src/components/block-mover/index.native.js b/packages/block-editor/src/components/block-mover/index.native.js index d8d7e848ede2e..326479cd3bc6e 100644 --- a/packages/block-editor/src/components/block-mover/index.native.js +++ b/packages/block-editor/src/components/block-mover/index.native.js @@ -90,7 +90,9 @@ export const BlockMover = ( { const option = blockPageMoverOptions.find( ( el ) => el.value === value ); - if ( option && option.onSelect ) option.onSelect(); + if ( option && option.onSelect ) { + option.onSelect(); + } }; const onLongPressMoveUp = useCallback( diff --git a/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js b/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js index 84f2d4b6a7a95..792f6d0bb2012 100644 --- a/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js +++ b/packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js @@ -34,7 +34,9 @@ function PatternTransformationsMenu( { } ) { const [ showTransforms, setShowTransforms ] = useState( false ); const patterns = useTransformedPatterns( statePatterns, blocks ); - if ( ! patterns.length ) return null; + if ( ! patterns.length ) { + return null; + } return ( diff --git a/packages/block-editor/src/components/block-switcher/use-transformed-patterns.js b/packages/block-editor/src/components/block-switcher/use-transformed-patterns.js index ba340f62d5e83..86055d5425255 100644 --- a/packages/block-editor/src/components/block-switcher/use-transformed-patterns.js +++ b/packages/block-editor/src/components/block-switcher/use-transformed-patterns.js @@ -62,7 +62,9 @@ export const getPatternTransformedBlocks = ( selectedBlock.name, consumedBlocks ); - if ( ! match ) continue; + if ( ! match ) { + continue; + } isMatch = true; consumedBlocks.add( match.clientId ); // We update (mutate) the matching pattern block. @@ -71,7 +73,9 @@ export const getPatternTransformedBlocks = ( break; } // Bail eary if a selected block has not been matched. - if ( ! isMatch ) return; + if ( ! isMatch ) { + return; + } } return _patternBlocks; }; diff --git a/packages/block-editor/src/components/block-switcher/utils.js b/packages/block-editor/src/components/block-switcher/utils.js index d74f9199aff6e..ebd95fc460e33 100644 --- a/packages/block-editor/src/components/block-switcher/utils.js +++ b/packages/block-editor/src/components/block-switcher/utils.js @@ -22,8 +22,12 @@ export const getMatchingBlockByName = ( ) => { const { clientId, name, innerBlocks = [] } = block; // Check if block has been consumed already. - if ( consumedBlocks.has( clientId ) ) return; - if ( name === selectedBlockName ) return block; + if ( consumedBlocks.has( clientId ) ) { + return; + } + if ( name === selectedBlockName ) { + return block; + } // Try to find a matching block from InnerBlocks recursively. for ( const innerBlock of innerBlocks ) { const match = getMatchingBlockByName( @@ -31,7 +35,9 @@ export const getMatchingBlockByName = ( selectedBlockName, consumedBlocks ); - if ( match ) return match; + if ( match ) { + return match; + } } }; @@ -47,11 +53,14 @@ export const getMatchingBlockByName = ( */ export const getRetainedBlockAttributes = ( name, attributes ) => { const contentAttributes = getBlockAttributesNamesByRole( name, 'content' ); - if ( ! contentAttributes?.length ) return attributes; + if ( ! contentAttributes?.length ) { + return attributes; + } return contentAttributes.reduce( ( _accumulator, attribute ) => { - if ( attributes[ attribute ] ) + if ( attributes[ attribute ] ) { _accumulator[ attribute ] = attributes[ attribute ]; + } return _accumulator; }, {} ); }; diff --git a/packages/block-editor/src/components/block-tools/index.js b/packages/block-editor/src/components/block-tools/index.js index 17e4e026cbbab..3606a8f757cfd 100644 --- a/packages/block-editor/src/components/block-tools/index.js +++ b/packages/block-editor/src/components/block-tools/index.js @@ -85,7 +85,9 @@ export default function BlockTools( { } = unlock( useDispatch( blockEditorStore ) ); function onKeyDown( event ) { - if ( event.defaultPrevented ) return; + if ( event.defaultPrevented ) { + return; + } if ( isMatch( 'core/block-editor/move-up', event ) ) { const clientIds = getSelectedBlockClientIds(); diff --git a/packages/block-editor/src/components/block-variation-transforms/index.js b/packages/block-editor/src/components/block-variation-transforms/index.js index bcaf7f9f6662b..b7ecaad635e44 100644 --- a/packages/block-editor/src/components/block-variation-transforms/index.js +++ b/packages/block-editor/src/components/block-variation-transforms/index.js @@ -180,7 +180,9 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) { }; // Skip rendering if there are no variations - if ( ! variations?.length ) return null; + if ( ! variations?.length ) { + return null; + } const baseClass = 'block-editor-block-variation-transforms'; diff --git a/packages/block-editor/src/components/floating-toolbar/index.native.js b/packages/block-editor/src/components/floating-toolbar/index.native.js index f4ebf1d9ebe8d..d78262fb01f27 100644 --- a/packages/block-editor/src/components/floating-toolbar/index.native.js +++ b/packages/block-editor/src/components/floating-toolbar/index.native.js @@ -47,8 +47,9 @@ const FloatingToolbar = ( { }, [ showFloatingToolbar ] ); useEffect( () => { - if ( showFloatingToolbar ) + if ( showFloatingToolbar ) { setPreviousSelection( { clientId: selectedClientId, parentId } ); + } }, [ selectedClientId ] ); const translationRange = @@ -115,7 +116,9 @@ export default compose( [ const selectedClientId = getSelectedBlockClientId(); - if ( ! selectedClientId ) return; + if ( ! selectedClientId ) { + return; + } const rootBlockId = getBlockHierarchyRootClientId( selectedClientId ); diff --git a/packages/block-editor/src/components/global-styles/color-panel.js b/packages/block-editor/src/components/global-styles/color-panel.js index 9b6f9bcede9a8..a0e469c502d15 100644 --- a/packages/block-editor/src/components/global-styles/color-panel.js +++ b/packages/block-editor/src/components/global-styles/color-panel.js @@ -587,7 +587,9 @@ export default function ColorPanel( { ].filter( Boolean ); elements.forEach( ( { name, label, showPanel } ) => { - if ( ! showPanel ) return; + if ( ! showPanel ) { + return; + } const elementBackgroundColor = decodeValue( inheritedValue?.elements?.[ name ]?.color?.background diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index e150a96187e04..33737c16bcb50 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -271,7 +271,9 @@ function InserterMenu( __nextHasNoMarginBottom className="block-editor-inserter__search" onChange={ ( value ) => { - if ( hoveredItem ) setHoveredItem( null ); + if ( hoveredItem ) { + setHoveredItem( null ); + } setFilterValue( value ); } } value={ filterValue } diff --git a/packages/block-editor/src/components/line-height-control/index.js b/packages/block-editor/src/components/line-height-control/index.js index a57add244cc76..8150c2d60027e 100644 --- a/packages/block-editor/src/components/line-height-control/index.js +++ b/packages/block-editor/src/components/line-height-control/index.js @@ -28,7 +28,9 @@ const LineHeightControl = ( { const adjustNextValue = ( nextValue, wasTypedOrPasted ) => { // Set the next value without modification if lineHeight has been defined. - if ( isDefined ) return nextValue; + if ( isDefined ) { + return nextValue; + } /** * The following logic handles the initial spin up/down action @@ -47,7 +49,9 @@ const LineHeightControl = ( { case '0': { // This means the user explicitly input '0', rather than using the // spin down action from an undefined value state. - if ( wasTypedOrPasted ) return nextValue; + if ( wasTypedOrPasted ) { + return nextValue; + } // Decrement by spin value. return BASE_DEFAULT_VALUE - spin; } diff --git a/packages/block-editor/src/components/link-control/search-item.js b/packages/block-editor/src/components/link-control/search-item.js index 7fa8ee1803644..fa8d1540b3dae 100644 --- a/packages/block-editor/src/components/link-control/search-item.js +++ b/packages/block-editor/src/components/link-control/search-item.js @@ -63,7 +63,9 @@ function SearchItemIcon( { isURL, suggestion } ) { function addLeadingSlash( url ) { const trimmedURL = url?.trim(); - if ( ! trimmedURL?.length ) return url; + if ( ! trimmedURL?.length ) { + return url; + } return url?.replace( /^\/?/, '/' ); } @@ -71,7 +73,9 @@ function addLeadingSlash( url ) { function removeTrailingSlash( url ) { const trimmedURL = url?.trim(); - if ( ! trimmedURL?.length ) return url; + if ( ! trimmedURL?.length ) { + return url; + } return url?.replace( /\/$/, '' ); } @@ -95,7 +99,9 @@ const defaultTo = ( d ) => ( v ) => { * @return {string} the processed url to display. */ function getURLForDisplay( url ) { - if ( ! url ) return url; + if ( ! url ) { + return url; + } return pipe( safeDecodeURI, diff --git a/packages/block-editor/src/components/list-view/utils.js b/packages/block-editor/src/components/list-view/utils.js index dde1d39567f58..d6ca4a1f2e005 100644 --- a/packages/block-editor/src/components/list-view/utils.js +++ b/packages/block-editor/src/components/list-view/utils.js @@ -74,7 +74,9 @@ export function focusListItem( focusClientId, treeGridElement ) { const row = treeGridElement?.querySelector( `[role=row][data-block="${ focusClientId }"]` ); - if ( ! row ) return null; + if ( ! row ) { + return null; + } // Focus the first focusable in the row, which is the ListViewBlockSelectButton. return focus.focusable.find( row )[ 0 ]; }; diff --git a/packages/block-editor/src/components/navigable-toolbar/index.js b/packages/block-editor/src/components/navigable-toolbar/index.js index 0044782b7fa3c..378d72919cccf 100644 --- a/packages/block-editor/src/components/navigable-toolbar/index.js +++ b/packages/block-editor/src/components/navigable-toolbar/index.js @@ -165,7 +165,9 @@ function useToolbarFocus( { } return () => { window.cancelAnimationFrame( raf ); - if ( ! onIndexChange || ! navigableToolbarRef ) return; + if ( ! onIndexChange || ! navigableToolbarRef ) { + return; + } // When the toolbar element is unmounted and onIndexChange is passed, we // pass the focused toolbar item index so it can be hydrated later. const items = getAllFocusableToolbarItemsIn( navigableToolbarRef ); diff --git a/packages/block-editor/src/components/provider/use-block-sync.js b/packages/block-editor/src/components/provider/use-block-sync.js index f266251759dfe..57e53979142d6 100644 --- a/packages/block-editor/src/components/provider/use-block-sync.js +++ b/packages/block-editor/src/components/provider/use-block-sync.js @@ -198,8 +198,9 @@ export default function useBlockSync( { // the subscription is triggering for a block (`clientId !== null`) // and its block name can't be found because it's not on the list. // (`getBlockName( clientId ) === null`). - if ( clientId !== null && getBlockName( clientId ) === null ) + if ( clientId !== null && getBlockName( clientId ) === null ) { return; + } // When RESET_BLOCKS on parent blocks get called, the controlled blocks // can reset to uncontrolled, in these situations, it means we need to populate diff --git a/packages/block-editor/src/components/rich-text/multiline.js b/packages/block-editor/src/components/rich-text/multiline.js index 760a7718fd864..10d318b741600 100644 --- a/packages/block-editor/src/components/rich-text/multiline.js +++ b/packages/block-editor/src/components/rich-text/multiline.js @@ -84,7 +84,9 @@ function RichTextMultiline( const newValues = values.slice(); let offset = 0; if ( forward ) { - if ( ! newValues[ index + 1 ] ) return; + if ( ! newValues[ index + 1 ] ) { + return; + } newValues.splice( index, 2, @@ -92,7 +94,9 @@ function RichTextMultiline( ); offset = newValues[ index ].length - 1; } else { - if ( ! newValues[ index - 1 ] ) return; + if ( ! newValues[ index - 1 ] ) { + return; + } newValues.splice( index - 1, 2, diff --git a/packages/block-editor/src/components/rich-text/use-format-types.js b/packages/block-editor/src/components/rich-text/use-format-types.js index 9d26d61943249..3c9b3b62ef78a 100644 --- a/packages/block-editor/src/components/rich-text/use-format-types.js +++ b/packages/block-editor/src/components/rich-text/use-format-types.js @@ -29,7 +29,9 @@ const interactiveContentTags = new Set( [ ] ); function prefixSelectKeys( selected, prefix ) { - if ( typeof selected !== 'object' ) return { [ prefix ]: selected }; + if ( typeof selected !== 'object' ) { + return { [ prefix ]: selected }; + } return Object.fromEntries( Object.entries( selected ).map( ( [ key, value ] ) => [ `${ prefix }.${ key }`, @@ -39,7 +41,9 @@ function prefixSelectKeys( selected, prefix ) { } function getPrefixedSelectKeys( selected, prefix ) { - if ( selected[ prefix ] ) return selected[ prefix ]; + if ( selected[ prefix ] ) { + return selected[ prefix ]; + } return Object.keys( selected ) .filter( ( key ) => key.startsWith( prefix + '.' ) ) .reduce( ( accumulator, key ) => { diff --git a/packages/block-editor/src/components/use-block-display-information/index.js b/packages/block-editor/src/components/use-block-display-information/index.js index 8ae50792f31f5..0da99d415f53f 100644 --- a/packages/block-editor/src/components/use-block-display-information/index.js +++ b/packages/block-editor/src/components/use-block-display-information/index.js @@ -68,14 +68,18 @@ function getPositionTypeLabel( attributes ) { export default function useBlockDisplayInformation( clientId ) { return useSelect( ( select ) => { - if ( ! clientId ) return null; + if ( ! clientId ) { + return null; + } const { getBlockName, getBlockAttributes } = select( blockEditorStore ); const { getBlockType, getActiveBlockVariation } = select( blocksStore ); const blockName = getBlockName( clientId ); const blockType = getBlockType( blockName ); - if ( ! blockType ) return null; + if ( ! blockType ) { + return null; + } const attributes = getBlockAttributes( clientId ); const match = getActiveBlockVariation( blockName, attributes ); const isSynced = @@ -95,7 +99,9 @@ export default function useBlockDisplayInformation( clientId ) { positionType: attributes?.style?.position?.type, name: attributes?.metadata?.name, }; - if ( ! match ) return blockTypeInfo; + if ( ! match ) { + return blockTypeInfo; + } return { isSynced, diff --git a/packages/block-editor/src/components/use-on-block-drop/index.js b/packages/block-editor/src/components/use-on-block-drop/index.js index 58ce615436d8e..420cd398edfa3 100644 --- a/packages/block-editor/src/components/use-on-block-drop/index.js +++ b/packages/block-editor/src/components/use-on-block-drop/index.js @@ -252,7 +252,9 @@ export default function useOnBlockDrop( initialPosition = 0, clientIdsToReplace = [] ) => { - if ( ! Array.isArray( blocks ) ) blocks = [ blocks ]; + if ( ! Array.isArray( blocks ) ) { + blocks = [ blocks ]; + } const clientIds = getBlockOrder( targetRootClientId ); const clientId = clientIds[ targetBlockIndex ]; diff --git a/packages/block-editor/src/components/writing-flow/use-drag-selection.js b/packages/block-editor/src/components/writing-flow/use-drag-selection.js index 4160565927ce2..1569c45a7c676 100644 --- a/packages/block-editor/src/components/writing-flow/use-drag-selection.js +++ b/packages/block-editor/src/components/writing-flow/use-drag-selection.js @@ -18,7 +18,9 @@ import { store as blockEditorStore } from '../../store'; function setContentEditableWrapper( node, value ) { node.contentEditable = value; // Firefox doesn't automatically move focus. - if ( value ) node.focus(); + if ( value ) { + node.focus(); + } } /** diff --git a/packages/block-editor/src/components/writing-flow/use-tab-nav.js b/packages/block-editor/src/components/writing-flow/use-tab-nav.js index bfc64dde07153..818a2cdbbda02 100644 --- a/packages/block-editor/src/components/writing-flow/use-tab-nav.js +++ b/packages/block-editor/src/components/writing-flow/use-tab-nav.js @@ -118,7 +118,9 @@ export default function useTabNav() { // do it again here because after clearing block selection, // focus land on the writing flow container and pressing Tab // will no longer send focus through the focus capture element. - if ( event.target === node ) setNavigationMode( true ); + if ( event.target === node ) { + setNavigationMode( true ); + } return; } diff --git a/packages/block-editor/src/hooks/duotone.js b/packages/block-editor/src/hooks/duotone.js index 0df0d50d64457..cd3271ae50d5e 100644 --- a/packages/block-editor/src/hooks/duotone.js +++ b/packages/block-editor/src/hooks/duotone.js @@ -291,7 +291,9 @@ function useDuotoneStyles( { const blockElement = useBlockElement( clientId ); useEffect( () => { - if ( ! isValidFilter ) return; + if ( ! isValidFilter ) { + return; + } // Safari does not always update the duotone filter when the duotone colors // are changed. When using Safari, force the block element to be repainted by diff --git a/packages/block-editor/src/hooks/utils.js b/packages/block-editor/src/hooks/utils.js index 62a6f3c6c5368..89ac3a9d70583 100644 --- a/packages/block-editor/src/hooks/utils.js +++ b/packages/block-editor/src/hooks/utils.js @@ -149,7 +149,9 @@ export function useStyleOverride( { const fallbackId = useId(); useEffect( () => { // Unmount if there is CSS and assets are empty. - if ( ! css && ! assets ) return; + if ( ! css && ! assets ) { + return; + } const _id = id || fallbackId; const override = { diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index faa36a286e046..bcc753253e8e7 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -675,7 +675,9 @@ export const __unstableDeleteSelection = const selectionAnchor = select.getSelectionStart(); const selectionFocus = select.getSelectionEnd(); - if ( selectionAnchor.clientId === selectionFocus.clientId ) return; + if ( selectionAnchor.clientId === selectionFocus.clientId ) { + return; + } // It's not mergeable if there's no rich text selection. if ( @@ -683,8 +685,9 @@ export const __unstableDeleteSelection = ! selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined' - ) + ) { return false; + } const anchorRootClientId = select.getBlockRootClientId( selectionAnchor.clientId @@ -825,7 +828,9 @@ export const __unstableSplitSelection = const selectionAnchor = select.getSelectionStart(); const selectionFocus = select.getSelectionEnd(); - if ( selectionAnchor.clientId === selectionFocus.clientId ) return; + if ( selectionAnchor.clientId === selectionFocus.clientId ) { + return; + } // Can't split if the selection is not set. if ( @@ -833,8 +838,9 @@ export const __unstableSplitSelection = ! selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined' - ) + ) { return; + } const anchorRootClientId = select.getBlockRootClientId( selectionAnchor.clientId @@ -931,7 +937,9 @@ export const mergeBlocks = const blockA = select.getBlock( clientIdA ); const blockAType = getBlockType( blockA.name ); - if ( ! blockAType ) return; + if ( ! blockAType ) { + return; + } const blockB = select.getBlock( clientIdB ); diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 19c609e848732..4ce85afb8cfd1 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -1030,7 +1030,9 @@ export function __unstableIsSelectionMergeable( state, isForward ) { const selectionFocus = getSelectionEnd( state ); // It's not mergeable if the start and end are within the same block. - if ( selectionAnchor.clientId === selectionFocus.clientId ) return false; + if ( selectionAnchor.clientId === selectionFocus.clientId ) { + return false; + } // It's not mergeable if there's no rich text selection. if ( @@ -1038,8 +1040,9 @@ export function __unstableIsSelectionMergeable( state, isForward ) { ! selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined' - ) + ) { return false; + } const anchorRootClientId = getBlockRootClientId( state, @@ -1081,12 +1084,16 @@ export function __unstableIsSelectionMergeable( state, isForward ) { const targetBlockName = getBlockName( state, targetBlockClientId ); const targetBlockType = getBlockType( targetBlockName ); - if ( ! targetBlockType.merge ) return false; + if ( ! targetBlockType.merge ) { + return false; + } const blockToMerge = getBlock( state, blockToMergeClientId ); // It's mergeable if the blocks are of the same type. - if ( blockToMerge.name === targetBlockName ) return true; + if ( blockToMerge.name === targetBlockName ) { + return true; + } // If the blocks are of a different type, try to transform the block being // merged into the same type of block. @@ -1938,7 +1945,9 @@ const buildBlockTypeItem = isDisabled, frecency: calculateFrecency( time, count ), }; - if ( buildScope === 'transform' ) return blockItemBase; + if ( buildScope === 'transform' ) { + return blockItemBase; + } const inserterVariations = getBlockVariations( blockType.name, @@ -2379,7 +2388,9 @@ export const __experimentalGetAllowedPatterns = createRegistrySelector( export const getPatternsByBlockTypes = createRegistrySelector( ( select ) => createSelector( ( state, blockNames, rootClientId = null ) => { - if ( ! blockNames ) return EMPTY_ARRAY; + if ( ! blockNames ) { + return EMPTY_ARRAY; + } const patterns = select( STORE_NAME ).__experimentalGetAllowedPatterns( rootClientId @@ -2438,7 +2449,9 @@ export const __experimentalGetPatternTransformItems = createRegistrySelector( ( select ) => createSelector( ( state, blocks, rootClientId = null ) => { - if ( ! blocks ) return EMPTY_ARRAY; + if ( ! blocks ) { + return EMPTY_ARRAY; + } /** * For now we only handle blocks without InnerBlocks and take into account * the `__experimentalRole` property of blocks' attributes for the transformation. diff --git a/packages/block-editor/src/utils/order-inserter-block-items.js b/packages/block-editor/src/utils/order-inserter-block-items.js index 696879b89db5e..aa2f1acd48c28 100644 --- a/packages/block-editor/src/utils/order-inserter-block-items.js +++ b/packages/block-editor/src/utils/order-inserter-block-items.js @@ -17,8 +17,12 @@ export const orderInserterBlockItems = ( items, priority ) => { let aIndex = priority.indexOf( aName ); let bIndex = priority.indexOf( bName ); // All other block items should come after that. - if ( aIndex < 0 ) aIndex = priority.length; - if ( bIndex < 0 ) bIndex = priority.length; + if ( aIndex < 0 ) { + aIndex = priority.length; + } + if ( bIndex < 0 ) { + bIndex = priority.length; + } return aIndex - bIndex; } ); diff --git a/packages/block-editor/src/utils/pasting.js b/packages/block-editor/src/utils/pasting.js index 3ce7c20083269..c106e78fe8465 100644 --- a/packages/block-editor/src/utils/pasting.js +++ b/packages/block-editor/src/utils/pasting.js @@ -112,7 +112,9 @@ export function shouldDismissPastedFiles( files, html /*, plainText */ ) { // other elements found, like
, but we assume that the user's // intention is to paste the actual image file. const IMAGE_TAG = /<\s*img\b/gi; - if ( html.match( IMAGE_TAG )?.length !== 1 ) return true; + if ( html.match( IMAGE_TAG )?.length !== 1 ) { + return true; + } // Even when there is exactly one tag in the HTML payload, we // choose to weed out local images, i.e. those whose source starts with @@ -121,7 +123,9 @@ export function shouldDismissPastedFiles( files, html /*, plainText */ ) { // text and exactly one image, and pasting that content using Google // Chrome. const IMG_WITH_LOCAL_SRC = /<\s*img\b[^>]*\bsrc="file:\/\//i; - if ( html.match( IMG_WITH_LOCAL_SRC ) ) return true; + if ( html.match( IMG_WITH_LOCAL_SRC ) ) { + return true; + } } return false; diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index 3165b41b05ec4..8a2c292f395b5 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -92,7 +92,9 @@ const useInferredLayout = ( blocks, parentLayout ) => { function hasOverridableBlocks( blocks ) { return blocks.some( ( block ) => { - if ( isOverridableBlock( block ) ) return true; + if ( isOverridableBlock( block ) ) { + return true; + } return hasOverridableBlocks( block.innerBlocks ); } ); } @@ -159,7 +161,9 @@ function getContentValuesFromInnerBlocks( blocks, defaultValues, legacyIdMap ) { /** @type {Record}>} */ const content = {}; for ( const block of blocks ) { - if ( block.name === patternBlockName ) continue; + if ( block.name === patternBlockName ) { + continue; + } if ( block.innerBlocks.length ) { Object.assign( content, diff --git a/packages/block-library/src/column/edit.native.js b/packages/block-library/src/column/edit.native.js index 871a12c7ee600..0a88d36beaf96 100644 --- a/packages/block-library/src/column/edit.native.js +++ b/packages/block-library/src/column/edit.native.js @@ -220,7 +220,9 @@ function ColumnEditWrapper( props ) { const { verticalAlignment } = props.attributes; const getVerticalAlignmentRemap = ( alignment ) => { - if ( ! alignment ) return styles.flexBase; + if ( ! alignment ) { + return styles.flexBase; + } return { ...styles.flexBase, ...styles[ `is-vertically-aligned-${ alignment }` ], diff --git a/packages/block-library/src/comment-template/util.js b/packages/block-library/src/comment-template/util.js index 32aab0a568709..88fc666204922 100644 --- a/packages/block-library/src/comment-template/util.js +++ b/packages/block-library/src/comment-template/util.js @@ -30,7 +30,9 @@ export const convertToTree = ( data ) => { const table = {}; - if ( ! data ) return []; + if ( ! data ) { + return []; + } // First create a hash table of { [id]: { ...comment, children: [] }} data.forEach( ( item ) => { diff --git a/packages/block-library/src/cover/shared.js b/packages/block-library/src/cover/shared.js index 35a2a6a5a5157..37390354a37d6 100644 --- a/packages/block-library/src/cover/shared.js +++ b/packages/block-library/src/cover/shared.js @@ -103,7 +103,9 @@ export function getPositionClassName( contentPosition ) { /* * Only render a className if the contentPosition is not center (the default). */ - if ( isContentPositionCenter( contentPosition ) ) return ''; + if ( isContentPositionCenter( contentPosition ) ) { + return ''; + } return POSITION_CLASSNAMES[ contentPosition ]; } diff --git a/packages/block-library/src/embed/util.js b/packages/block-library/src/embed/util.js index c591c5d19e2d2..01596f4f22822 100644 --- a/packages/block-library/src/embed/util.js +++ b/packages/block-library/src/embed/util.js @@ -97,7 +97,9 @@ export const createUpgradedEmbedBlock = ( const { preview, attributes = {} } = props; const { url, providerNameSlug, type, ...restAttributes } = attributes; - if ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return; + if ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) { + return; + } const matchedBlock = findMoreSuitableBlock( url ); diff --git a/packages/block-library/src/embed/variations.js b/packages/block-library/src/embed/variations.js index 66cd266b060d9..6083ea1adc90b 100644 --- a/packages/block-library/src/embed/variations.js +++ b/packages/block-library/src/embed/variations.js @@ -368,7 +368,9 @@ const variations = [ * Block by providing its attributes. */ variations.forEach( ( variation ) => { - if ( variation.isActive ) return; + if ( variation.isActive ) { + return; + } variation.isActive = ( blockAttributes, variationAttributes ) => blockAttributes.providerNameSlug === variationAttributes.providerNameSlug; diff --git a/packages/block-library/src/embed/wp-embed-preview.js b/packages/block-library/src/embed/wp-embed-preview.js index 1992310217aca..ad68bc3f7aadd 100644 --- a/packages/block-library/src/embed/wp-embed-preview.js +++ b/packages/block-library/src/embed/wp-embed-preview.js @@ -20,10 +20,14 @@ export default function WpEmbedPreview( { html } ) { const iframe = doc.querySelector( 'iframe' ); const iframeProps = {}; - if ( ! iframe ) return iframeProps; + if ( ! iframe ) { + return iframeProps; + } Array.from( iframe.attributes ).forEach( ( { name, value } ) => { - if ( name === 'style' ) return; + if ( name === 'style' ) { + return; + } iframeProps[ attributeMap[ name ] || name ] = value; } ); diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 9c03489766101..13607508a56f6 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -200,7 +200,9 @@ export default function Image( { return; } - if ( externalBlob ) return; + if ( externalBlob ) { + return; + } window // Avoid cache, which seems to help avoid CORS problems. diff --git a/packages/block-library/src/image/view.js b/packages/block-library/src/image/view.js index c8ffdcba60b37..3d71e00aab324 100644 --- a/packages/block-library/src/image/view.js +++ b/packages/block-library/src/image/view.js @@ -174,7 +174,9 @@ const { state, actions, callbacks } = store( }, callbacks: { setOverlayStyles() { - if ( ! imageRef ) return; + if ( ! imageRef ) { + return; + } let { naturalWidth, diff --git a/packages/block-library/src/list-item/hooks/use-merge.js b/packages/block-library/src/list-item/hooks/use-merge.js index 2fbee4ba275a1..4b56abb320d92 100644 --- a/packages/block-library/src/list-item/hooks/use-merge.js +++ b/packages/block-library/src/list-item/hooks/use-merge.js @@ -35,8 +35,12 @@ export default function useMerge( clientId, onMerge ) { function getParentListItemId( id ) { const listId = getBlockRootClientId( id ); const parentListItemId = getBlockRootClientId( listId ); - if ( ! parentListItemId ) return; - if ( getBlockName( parentListItemId ) !== 'core/list-item' ) return; + if ( ! parentListItemId ) { + return; + } + if ( getBlockName( parentListItemId ) !== 'core/list-item' ) { + return; + } return parentListItemId; } @@ -49,9 +53,13 @@ export default function useMerge( clientId, onMerge ) { */ function _getNextId( id ) { const next = getNextBlockClientId( id ); - if ( next ) return next; + if ( next ) { + return next; + } const parentListItemId = getParentListItemId( id ); - if ( ! parentListItemId ) return; + if ( ! parentListItemId ) { + return; + } return _getNextId( parentListItemId ); } diff --git a/packages/block-library/src/list-item/hooks/use-outdent-list-item.js b/packages/block-library/src/list-item/hooks/use-outdent-list-item.js index a17890eada6c5..48bccc8f2cd4c 100644 --- a/packages/block-library/src/list-item/hooks/use-outdent-list-item.js +++ b/packages/block-library/src/list-item/hooks/use-outdent-list-item.js @@ -27,8 +27,12 @@ export default function useOutdentListItem() { function getParentListItemId( id ) { const listId = getBlockRootClientId( id ); const parentListItemId = getBlockRootClientId( listId ); - if ( ! parentListItemId ) return; - if ( getBlockName( parentListItemId ) !== 'core/list-item' ) return; + if ( ! parentListItemId ) { + return; + } + if ( getBlockName( parentListItemId ) !== 'core/list-item' ) { + return; + } return parentListItemId; } @@ -37,17 +41,23 @@ export default function useOutdentListItem() { clientIds = [ clientIds ]; } - if ( ! clientIds.length ) return; + if ( ! clientIds.length ) { + return; + } const firstClientId = clientIds[ 0 ]; // Can't outdent if it's not a list item. - if ( getBlockName( firstClientId ) !== 'core/list-item' ) return; + if ( getBlockName( firstClientId ) !== 'core/list-item' ) { + return; + } const parentListItemId = getParentListItemId( firstClientId ); // Can't outdent if it's at the top level. - if ( ! parentListItemId ) return; + if ( ! parentListItemId ) { + return; + } const parentListId = getBlockRootClientId( firstClientId ); const lastClientId = clientIds[ clientIds.length - 1 ]; diff --git a/packages/block-library/src/navigation/edit/are-blocks-dirty.js b/packages/block-library/src/navigation/edit/are-blocks-dirty.js index 1d7fa8a7286f2..c4d1a8f76456a 100644 --- a/packages/block-library/src/navigation/edit/are-blocks-dirty.js +++ b/packages/block-library/src/navigation/edit/are-blocks-dirty.js @@ -30,7 +30,9 @@ const isDeepEqual = ( x, y, shouldSkip ) => { y !== null && y !== undefined ) { - if ( Object.keys( x ).length !== Object.keys( y ).length ) return false; + if ( Object.keys( x ).length !== Object.keys( y ).length ) { + return false; + } for ( const prop in x ) { if ( y.hasOwnProperty( prop ) ) { @@ -39,9 +41,12 @@ const isDeepEqual = ( x, y, shouldSkip ) => { return true; } - if ( ! isDeepEqual( x[ prop ], y[ prop ], shouldSkip ) ) + if ( ! isDeepEqual( x[ prop ], y[ prop ], shouldSkip ) ) { return false; - } else return false; + } + } else { + return false; + } } return true; diff --git a/packages/block-library/src/navigation/edit/menu-inspector-controls.js b/packages/block-library/src/navigation/edit/menu-inspector-controls.js index 29e5e0c8c7966..e21655eef9071 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -49,7 +49,9 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) { const setInsertedBlockAttributes = ( _insertedBlockClientId ) => ( _updatedAttributes ) => { - if ( ! _insertedBlockClientId ) return; + if ( ! _insertedBlockClientId ) { + return; + } updateBlockAttributes( _insertedBlockClientId, _updatedAttributes ); }; diff --git a/packages/block-library/src/navigation/view.js b/packages/block-library/src/navigation/view.js index ca593e7537ce9..14d09e061848e 100644 --- a/packages/block-library/src/navigation/view.js +++ b/packages/block-library/src/navigation/view.js @@ -94,7 +94,9 @@ const { state, actions } = store( const ctx = getContext(); const { ref } = getElement(); // Safari won't send focus to the clicked element, so we need to manually place it: https://bugs.webkit.org/show_bug.cgi?id=22261 - if ( window.document.activeElement !== ref ) ref.focus(); + if ( window.document.activeElement !== ref ) { + ref.focus(); + } const { menuOpenedBy } = state; if ( menuOpenedBy.click || menuOpenedBy.focus ) { actions.closeMenu( 'click' ); diff --git a/packages/block-library/src/post-excerpt/edit.js b/packages/block-library/src/post-excerpt/edit.js index 13ed3bb08258b..2f0cee86f0932 100644 --- a/packages/block-library/src/post-excerpt/edit.js +++ b/packages/block-library/src/post-excerpt/edit.js @@ -89,7 +89,9 @@ export default function PostExcerptEditor( { * excerpt has been produced from the content. */ const strippedRenderedExcerpt = useMemo( () => { - if ( ! renderedExcerpt ) return ''; + if ( ! renderedExcerpt ) { + return ''; + } const document = new window.DOMParser().parseFromString( renderedExcerpt, 'text/html' diff --git a/packages/block-library/src/post-featured-image/dimension-controls.js b/packages/block-library/src/post-featured-image/dimension-controls.js index d59d586eb04b4..b64b3299fc96b 100644 --- a/packages/block-library/src/post-featured-image/dimension-controls.js +++ b/packages/block-library/src/post-featured-image/dimension-controls.js @@ -81,7 +81,9 @@ const DimensionControls = ( { * we don't want to set the attribute, as it would * end up having the unit as value without any number. */ - if ( isNaN( parsedValue ) && nextValue ) return; + if ( isNaN( parsedValue ) && nextValue ) { + return; + } setAttributes( { [ dimension ]: parsedValue < 0 ? '0' : nextValue, } ); diff --git a/packages/block-library/src/post-navigation-link/variations.js b/packages/block-library/src/post-navigation-link/variations.js index 6d3e7f76cd7fa..945d6eb550f27 100644 --- a/packages/block-library/src/post-navigation-link/variations.js +++ b/packages/block-library/src/post-navigation-link/variations.js @@ -34,7 +34,9 @@ const variations = [ * Block by providing its attributes. */ variations.forEach( ( variation ) => { - if ( variation.isActive ) return; + if ( variation.isActive ) { + return; + } variation.isActive = ( blockAttributes, variationAttributes ) => blockAttributes.type === variationAttributes.type; } ); diff --git a/packages/block-library/src/post-terms/edit.js b/packages/block-library/src/post-terms/edit.js index b6da2dc7f8605..95fca21a3a26a 100644 --- a/packages/block-library/src/post-terms/edit.js +++ b/packages/block-library/src/post-terms/edit.js @@ -49,7 +49,9 @@ export default function PostTermsEdit( { const selectedTerm = useSelect( ( select ) => { - if ( ! term ) return {}; + if ( ! term ) { + return {}; + } const { getTaxonomy } = select( coreStore ); const taxonomy = getTaxonomy( term ); return taxonomy?.visibility?.publicly_queryable ? taxonomy : {}; diff --git a/packages/block-library/src/query-title/variations.js b/packages/block-library/src/query-title/variations.js index 741f74c8b82ce..6ee004259e2ff 100644 --- a/packages/block-library/src/query-title/variations.js +++ b/packages/block-library/src/query-title/variations.js @@ -38,7 +38,9 @@ const variations = [ * Block by providing its attributes. */ variations.forEach( ( variation ) => { - if ( variation.isActive ) return; + if ( variation.isActive ) { + return; + } variation.isActive = ( blockAttributes, variationAttributes ) => blockAttributes.type === variationAttributes.type; } ); diff --git a/packages/block-library/src/query/edit/inspector-controls/author-control.js b/packages/block-library/src/query/edit/inspector-controls/author-control.js index 68f4f32093c9e..5b154346f0a76 100644 --- a/packages/block-library/src/query/edit/inspector-controls/author-control.js +++ b/packages/block-library/src/query/edit/inspector-controls/author-control.js @@ -52,14 +52,18 @@ function AuthorControl( { value, onChange } ) { const getIdByValue = ( entitiesMappedByName, authorValue ) => { const id = authorValue?.id || entitiesMappedByName[ authorValue ]?.id; - if ( id ) return id; + if ( id ) { + return id; + } }; const onAuthorChange = ( newValue ) => { const ids = Array.from( newValue.reduce( ( accumulator, author ) => { // Verify that new values point to existing entities. const id = getIdByValue( authorsInfo.mapByName, author ); - if ( id ) accumulator.add( id ); + if ( id ) { + accumulator.add( id ); + } return accumulator; }, new Set() ) ); diff --git a/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js b/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js index ac9904f0f2d51..a8be9ed1c8d4f 100644 --- a/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js +++ b/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js @@ -8,7 +8,9 @@ import { addQueryArgs } from '@wordpress/url'; const CreateNewPostLink = ( { attributes: { query: { postType } = {} } = {}, } ) => { - if ( ! postType ) return null; + if ( ! postType ) { + return null; + } const newPostUrl = addQueryArgs( 'post-new.php', { post_type: postType, } ); diff --git a/packages/block-library/src/query/edit/inspector-controls/parent-control.js b/packages/block-library/src/query/edit/inspector-controls/parent-control.js index 830600e47481d..36cb518647690 100644 --- a/packages/block-library/src/query/edit/inspector-controls/parent-control.js +++ b/packages/block-library/src/query/edit/inspector-controls/parent-control.js @@ -55,7 +55,9 @@ function ParentControl( { parents, postType, onChange } ) { ); const currentParents = useSelect( ( select ) => { - if ( ! parents?.length ) return EMPTY_ARRAY; + if ( ! parents?.length ) { + return EMPTY_ARRAY; + } const { getEntityRecords } = select( coreStore ); return getEntityRecords( 'postType', postType, { ...BASE_QUERY, @@ -71,7 +73,9 @@ function ParentControl( { parents, postType, onChange } ) { if ( ! parents?.length ) { setValue( EMPTY_ARRAY ); } - if ( ! currentParents?.length ) return; + if ( ! currentParents?.length ) { + return; + } const currentParentsInfo = getEntitiesInfo( mapToIHasNameAndId( currentParents, 'title.rendered' ) ); @@ -91,27 +95,35 @@ function ParentControl( { parents, postType, onChange } ) { }, [ parents, currentParents ] ); const entitiesInfo = useMemo( () => { - if ( ! searchResults?.length ) return EMPTY_ARRAY; + if ( ! searchResults?.length ) { + return EMPTY_ARRAY; + } return getEntitiesInfo( mapToIHasNameAndId( searchResults, 'title.rendered' ) ); }, [ searchResults ] ); // Update suggestions only when the query has resolved. useEffect( () => { - if ( ! searchHasResolved ) return; + if ( ! searchHasResolved ) { + return; + } setSuggestions( entitiesInfo.names ); }, [ entitiesInfo.names, searchHasResolved ] ); const getIdByValue = ( entitiesMappedByName, entity ) => { const id = entity?.id || entitiesMappedByName?.[ entity ]?.id; - if ( id ) return id; + if ( id ) { + return id; + } }; const onParentChange = ( newValue ) => { const ids = Array.from( newValue.reduce( ( accumulator, entity ) => { // Verify that new values point to existing entities. const id = getIdByValue( entitiesInfo.mapByName, entity ); - if ( id ) accumulator.add( id ); + if ( id ) { + accumulator.add( id ); + } return accumulator; }, new Set() ) ); diff --git a/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js b/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js index 6aa57d69141c7..41f4376d08e47 100644 --- a/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js +++ b/packages/block-library/src/query/edit/inspector-controls/taxonomy-controls.js @@ -124,7 +124,9 @@ function TaxonomyItem( { taxonomy, termIds, onChange } ) { // and to sanitize the provided `termIds`, by setting only the ones that exist. const existingTerms = useSelect( ( select ) => { - if ( ! termIds?.length ) return EMPTY_ARRAY; + if ( ! termIds?.length ) { + return EMPTY_ARRAY; + } const { getEntityRecords } = select( coreStore ); return getEntityRecords( 'taxonomy', taxonomy.slug, { ...BASE_QUERY, @@ -140,7 +142,9 @@ function TaxonomyItem( { taxonomy, termIds, onChange } ) { if ( ! termIds?.length ) { setValue( EMPTY_ARRAY ); } - if ( ! existingTerms?.length ) return; + if ( ! existingTerms?.length ) { + return; + } // Returns only the existing entity ids. This prevents the component // from crashing in the editor, when non existing ids are provided. const sanitizedValue = termIds.reduce( ( accumulator, id ) => { @@ -157,7 +161,9 @@ function TaxonomyItem( { taxonomy, termIds, onChange } ) { }, [ termIds, existingTerms ] ); // Update suggestions only when the query has resolved. useEffect( () => { - if ( ! searchHasResolved ) return; + if ( ! searchHasResolved ) { + return; + } setSuggestions( searchResults.map( ( result ) => result.name ) ); }, [ searchResults, searchHasResolved ] ); const onTermsChange = ( newTermValues ) => { diff --git a/packages/block-library/src/query/utils.js b/packages/block-library/src/query/utils.js index f11e523a35c77..5dac08b81c353 100644 --- a/packages/block-library/src/query/utils.js +++ b/packages/block-library/src/query/utils.js @@ -108,7 +108,9 @@ export const usePostTypes = () => { return filteredPostTypes; }, [] ); const postTypesTaxonomiesMap = useMemo( () => { - if ( ! postTypes?.length ) return; + if ( ! postTypes?.length ) { + return; + } return postTypes.reduce( ( accumulator, type ) => { accumulator[ type.slug ] = type.taxonomies; return accumulator; diff --git a/packages/block-library/src/social-link/variations.js b/packages/block-library/src/social-link/variations.js index af3219d2084c8..24a6c60c3db77 100644 --- a/packages/block-library/src/social-link/variations.js +++ b/packages/block-library/src/social-link/variations.js @@ -339,7 +339,9 @@ const variations = [ * Block by providing its attributes. */ variations.forEach( ( variation ) => { - if ( variation.isActive ) return; + if ( variation.isActive ) { + return; + } variation.isActive = ( blockAttributes, variationAttributes ) => blockAttributes.service === variationAttributes.service; } ); diff --git a/packages/block-library/src/template-part/variations.js b/packages/block-library/src/template-part/variations.js index 79881ee5f89e4..acd8af13508ba 100644 --- a/packages/block-library/src/template-part/variations.js +++ b/packages/block-library/src/template-part/variations.js @@ -31,10 +31,14 @@ export function enhanceTemplatePartVariations( settings, name ) { const { area, theme, slug } = blockAttributes; // We first check the `area` block attribute which is set during insertion. // This property is removed on the creation of a template part. - if ( area ) return area === variationAttributes.area; + if ( area ) { + return area === variationAttributes.area; + } // Find a matching variation from the created template part // by checking the entity's `area` property. - if ( ! slug ) return false; + if ( ! slug ) { + return false; + } const { getCurrentTheme, getEntityRecord } = select( coreDataStore ); const entity = getEntityRecord( diff --git a/packages/blocks/src/api/serializer.js b/packages/blocks/src/api/serializer.js index 5883f47536431..609e62fc7e84b 100644 --- a/packages/blocks/src/api/serializer.js +++ b/packages/blocks/src/api/serializer.js @@ -128,7 +128,9 @@ export function getSaveElement( ) { const blockType = normalizeBlockType( blockTypeOrName ); - if ( ! blockType?.save ) return null; + if ( ! blockType?.save ) { + return null; + } let { save } = blockType; diff --git a/packages/blocks/src/api/utils.js b/packages/blocks/src/api/utils.js index a1c85910210b7..a68937586f927 100644 --- a/packages/blocks/src/api/utils.js +++ b/packages/blocks/src/api/utils.js @@ -334,9 +334,13 @@ export function __experimentalSanitizeBlockAttributes( name, attributes ) { */ export function __experimentalGetBlockAttributesNamesByRole( name, role ) { const attributes = getBlockType( name )?.attributes; - if ( ! attributes ) return []; + if ( ! attributes ) { + return []; + } const attributesNames = Object.keys( attributes ); - if ( ! role ) return attributesNames; + if ( ! role ) { + return attributesNames; + } return attributesNames.filter( ( attributeName ) => attributes[ attributeName ]?.__experimentalRole === role diff --git a/packages/commands/src/components/command-menu.js b/packages/commands/src/components/command-menu.js index 7d5f6f2574777..0d90f62a8737b 100644 --- a/packages/commands/src/components/command-menu.js +++ b/packages/commands/src/components/command-menu.js @@ -221,7 +221,9 @@ export function CommandMenu() { /** @type {import('react').KeyboardEventHandler} */ ( event ) => { // Bails to avoid obscuring the effect of the preceding handler(s). - if ( event.defaultPrevented ) return; + if ( event.defaultPrevented ) { + return; + } event.preventDefault(); if ( isOpen ) { diff --git a/packages/components/src/alignment-matrix-control/index.tsx b/packages/components/src/alignment-matrix-control/index.tsx index 3de0e401187d5..daf234a32b491 100644 --- a/packages/components/src/alignment-matrix-control/index.tsx +++ b/packages/components/src/alignment-matrix-control/index.tsx @@ -61,7 +61,9 @@ export function AlignmentMatrixControl( { activeId: getItemId( baseId, value ), setActiveId: ( nextActiveId ) => { const nextValue = getItemValue( baseId, nextActiveId ); - if ( nextValue ) onChange?.( nextValue ); + if ( nextValue ) { + onChange?.( nextValue ); + } }, rtl: isRTL(), } ); diff --git a/packages/components/src/alignment-matrix-control/utils.tsx b/packages/components/src/alignment-matrix-control/utils.tsx index 54455b61229b0..e206e197c2555 100644 --- a/packages/components/src/alignment-matrix-control/utils.tsx +++ b/packages/components/src/alignment-matrix-control/utils.tsx @@ -65,7 +65,9 @@ export function getItemId( value?: AlignmentMatrixControlValue ) { const normalized = normalize( value ); - if ( ! normalized ) return; + if ( ! normalized ) { + return; + } const id = normalized.replace( ' ', '-' ); return `${ prefixId }-${ id }`; @@ -94,7 +96,9 @@ export function getAlignmentIndex( alignment: AlignmentMatrixControlValue = 'center' ) { const normalized = normalize( alignment ); - if ( ! normalized ) return undefined; + if ( ! normalized ) { + return undefined; + } const index = ALIGNMENTS.indexOf( normalized ); return index > -1 ? index : undefined; diff --git a/packages/components/src/autocomplete/autocompleter-ui.tsx b/packages/components/src/autocomplete/autocompleter-ui.tsx index 663316c39b32e..b95ee0548dc0a 100644 --- a/packages/components/src/autocomplete/autocompleter-ui.tsx +++ b/packages/components/src/autocomplete/autocompleter-ui.tsx @@ -55,7 +55,9 @@ export function getAutoCompleterUI( autocompleter: WPCompleter ) { popoverRef, useRefEffect( ( node ) => { - if ( ! contentRef.current ) return; + if ( ! contentRef.current ) { + return; + } // If the popover is rendered in a different document than // the content, we need to duplicate the options list in the diff --git a/packages/components/src/autocomplete/index.tsx b/packages/components/src/autocomplete/index.tsx index 944eebf83de06..3bde3a73999f6 100644 --- a/packages/components/src/autocomplete/index.tsx +++ b/packages/components/src/autocomplete/index.tsx @@ -253,7 +253,9 @@ export function useAutocomplete( { useEffect( () => { if ( ! textContent ) { - if ( autocompleter ) reset(); + if ( autocompleter ) { + reset(); + } return; } @@ -277,7 +279,9 @@ export function useAutocomplete( { ); if ( ! completer ) { - if ( autocompleter ) reset(); + if ( autocompleter ) { + reset(); + } return; } @@ -293,7 +297,9 @@ export function useAutocomplete( { // significantly. This could happen, for example, if `matchingWhileBackspacing` // is true and one of the "words" end up being too long. If that's the case, // it will be caught by this guard. - if ( tooDistantFromTrigger ) return; + if ( tooDistantFromTrigger ) { + return; + } const mismatch = filteredOptions.length === 0; const wordsFromTrigger = textWithoutTrigger.split( /\s/ ); @@ -318,7 +324,9 @@ export function useAutocomplete( { backspacing.current && wordsFromTrigger.length <= 3; if ( mismatch && ! ( matchingWhileBackspacing || hasOneTriggerWord ) ) { - if ( autocompleter ) reset(); + if ( autocompleter ) { + reset(); + } return; } @@ -333,7 +341,9 @@ export function useAutocomplete( { textAfterSelection ) ) { - if ( autocompleter ) reset(); + if ( autocompleter ) { + reset(); + } return; } @@ -341,12 +351,16 @@ export function useAutocomplete( { /^\s/.test( textWithoutTrigger ) || /\s\s+$/.test( textWithoutTrigger ) ) { - if ( autocompleter ) reset(); + if ( autocompleter ) { + reset(); + } return; } if ( ! /[\u0000-\uFFFF]*$/.test( textWithoutTrigger ) ) { - if ( autocompleter ) reset(); + if ( autocompleter ) { + reset(); + } return; } diff --git a/packages/components/src/color-picker/hex-input.tsx b/packages/components/src/color-picker/hex-input.tsx index 6001892ff8afa..90ebc0a101bd3 100644 --- a/packages/components/src/color-picker/hex-input.tsx +++ b/packages/components/src/color-picker/hex-input.tsx @@ -21,7 +21,9 @@ import type { HexInputProps } from './types'; export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => { const handleChange = ( nextValue: string | undefined ) => { - if ( ! nextValue ) return; + if ( ! nextValue ) { + return; + } const hexValue = nextValue.startsWith( '#' ) ? nextValue : '#' + nextValue; diff --git a/packages/components/src/color-picker/hue-picker.native.js b/packages/components/src/color-picker/hue-picker.native.js index d7d391e183765..691e9396ee2d8 100644 --- a/packages/components/src/color-picker/hue-picker.native.js +++ b/packages/components/src/color-picker/hue-picker.native.js @@ -72,8 +72,12 @@ export default class HuePicker extends Component { } normalizeValue( value ) { - if ( value < 0 ) return 0; - if ( value > 1 ) return 1; + if ( value < 0 ) { + return 0; + } + if ( value > 1 ) { + return 1; + } return value; } diff --git a/packages/components/src/color-picker/index.native.js b/packages/components/src/color-picker/index.native.js index a2fee512ce26f..92228ca669064 100644 --- a/packages/components/src/color-picker/index.native.js +++ b/packages/components/src/color-picker/index.native.js @@ -82,9 +82,15 @@ function ColorPicker( { const currentColor = combineToHex(); const updateColor = ( { hue: h, saturation: s, value: v } ) => { - if ( h !== undefined ) setHue( h ); - if ( s !== undefined ) setSaturation( s ); - if ( v !== undefined ) setValue( v ); + if ( h !== undefined ) { + setHue( h ); + } + if ( s !== undefined ) { + setSaturation( s ); + } + if ( v !== undefined ) { + setValue( v ); + } setColor( combineToHex( h, s, v ) ); }; diff --git a/packages/components/src/color-picker/saturation-picker.native.js b/packages/components/src/color-picker/saturation-picker.native.js index 5c7e2e6d562a1..5ca35d257565f 100644 --- a/packages/components/src/color-picker/saturation-picker.native.js +++ b/packages/components/src/color-picker/saturation-picker.native.js @@ -56,8 +56,12 @@ export default class SaturationValuePicker extends Component { } normalizeValue( value ) { - if ( value < 0 ) return 0; - if ( value > 1 ) return 1; + if ( value < 0 ) { + return 0; + } + if ( value > 1 ) { + return 1; + } return value; } diff --git a/packages/components/src/color-picker/use-deprecated-props.ts b/packages/components/src/color-picker/use-deprecated-props.ts index cc835d68fd10b..68820af887a94 100644 --- a/packages/components/src/color-picker/use-deprecated-props.ts +++ b/packages/components/src/color-picker/use-deprecated-props.ts @@ -25,11 +25,17 @@ function isLegacyProps( props: any ): props is LegacyProps { function getColorFromLegacyProps( color: LegacyProps[ 'color' ] ): string | undefined { - if ( color === undefined ) return; + if ( color === undefined ) { + return; + } - if ( typeof color === 'string' ) return color; + if ( typeof color === 'string' ) { + return color; + } - if ( color.hex ) return color.hex; + if ( color.hex ) { + return color.hex; + } return undefined; } diff --git a/packages/components/src/context/context-connect.ts b/packages/components/src/context/context-connect.ts index f938fa0b1f324..bbab68222abb9 100644 --- a/packages/components/src/context/context-connect.ts +++ b/packages/components/src/context/context-connect.ts @@ -116,7 +116,9 @@ function _contextConnect< export function getConnectNamespace( Component: ReactChild | undefined | {} ): string[] { - if ( ! Component ) return []; + if ( ! Component ) { + return []; + } let namespaces = []; @@ -145,7 +147,9 @@ export function hasConnectNamespace( Component: ReactNode, match: string[] | string ): boolean { - if ( ! Component ) return false; + if ( ! Component ) { + return false; + } if ( typeof match === 'string' ) { return getConnectNamespace( Component ).includes( match ); diff --git a/packages/components/src/custom-select-control-v2/legacy-component/index.tsx b/packages/components/src/custom-select-control-v2/legacy-component/index.tsx index 8071a7e932a8b..0472d7df327b6 100644 --- a/packages/components/src/custom-select-control-v2/legacy-component/index.tsx +++ b/packages/components/src/custom-select-control-v2/legacy-component/index.tsx @@ -30,7 +30,9 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) { // Forward props + store from v2 implementation const store = Ariakit.useSelectStore( { async setValue( nextValue ) { - if ( ! onChange ) return; + if ( ! onChange ) { + return; + } // Executes the logic in a microtask after the popup is closed. // This is simply to ensure the isOpen state matches that in Downshift. diff --git a/packages/components/src/dropdown/styles.ts b/packages/components/src/dropdown/styles.ts index 6d5412f9a8121..24f4de4b4c6c9 100644 --- a/packages/components/src/dropdown/styles.ts +++ b/packages/components/src/dropdown/styles.ts @@ -11,7 +11,9 @@ import { space } from '../utils/space'; import type { DropdownContentWrapperProps } from './types'; const padding = ( { paddingSize = 'small' }: DropdownContentWrapperProps ) => { - if ( paddingSize === 'none' ) return; + if ( paddingSize === 'none' ) { + return; + } const paddingValues = { small: space( 2 ), diff --git a/packages/components/src/duotone-picker/utils.ts b/packages/components/src/duotone-picker/utils.ts index 06d371902f882..3f3eb1fd1eb24 100644 --- a/packages/components/src/duotone-picker/utils.ts +++ b/packages/components/src/duotone-picker/utils.ts @@ -31,7 +31,9 @@ export function getDefaultColors( palette: DuotonePickerProps[ 'colorPalette' ] ) { // A default dark and light color are required. - if ( ! palette || palette.length < 2 ) return [ '#000', '#fff' ]; + if ( ! palette || palette.length < 2 ) { + return [ '#000', '#fff' ]; + } return palette .map( ( { color } ) => ( { diff --git a/packages/components/src/focal-point-picker/controls.tsx b/packages/components/src/focal-point-picker/controls.tsx index 40cf8d215704b..3df1725bf3bed 100644 --- a/packages/components/src/focal-point-picker/controls.tsx +++ b/packages/components/src/focal-point-picker/controls.tsx @@ -38,7 +38,9 @@ export default function FocalPointPickerControls( { value: Parameters< UnitControlOnChangeCallback >[ 0 ], axis: FocalPointAxis ) => { - if ( value === undefined ) return; + if ( value === undefined ) { + return; + } const num = parseInt( value, 10 ); diff --git a/packages/components/src/focal-point-picker/index.tsx b/packages/components/src/focal-point-picker/index.tsx index 33fd505f67fe1..0e633dae47cd8 100644 --- a/packages/components/src/focal-point-picker/index.tsx +++ b/packages/components/src/focal-point-picker/index.tsx @@ -111,7 +111,9 @@ export function FocalPointPicker( { // `value` can technically be undefined if getValueWithinDragArea() is // called before dragAreaRef is set, but this shouldn't happen in reality. - if ( ! value ) return; + if ( ! value ) { + return; + } onDragStart?.( value, event ); setPoint( value ); @@ -120,7 +122,9 @@ export function FocalPointPicker( { // Prevents text-selection when dragging. event.preventDefault(); const value = getValueWithinDragArea( event ); - if ( ! value ) return; + if ( ! value ) { + return; + } onDrag?.( value, event ); setPoint( value ); }, @@ -136,7 +140,9 @@ export function FocalPointPicker( { const dragAreaRef = useRef< HTMLDivElement >( null ); const [ bounds, setBounds ] = useState( INITIAL_BOUNDS ); const refUpdateBounds = useRef( () => { - if ( ! dragAreaRef.current ) return; + if ( ! dragAreaRef.current ) { + return; + } const { clientWidth: width, clientHeight: height } = dragAreaRef.current; @@ -150,7 +156,9 @@ export function FocalPointPicker( { useEffect( () => { const updateBounds = refUpdateBounds.current; - if ( ! dragAreaRef.current ) return; + if ( ! dragAreaRef.current ) { + return; + } const { defaultView } = dragAreaRef.current.ownerDocument; defaultView?.addEventListener( 'resize', updateBounds ); @@ -171,7 +179,9 @@ export function FocalPointPicker( { clientY: number; shiftKey: boolean; } ) => { - if ( ! dragAreaRef.current ) return; + if ( ! dragAreaRef.current ) { + return; + } const { top, left } = dragAreaRef.current.getBoundingClientRect(); let nextX = ( clientX - left ) / bounds.width; @@ -203,8 +213,9 @@ export function FocalPointPicker( { ! [ 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight' ].includes( code ) - ) + ) { return; + } event.preventDefault(); const value = { x, y }; @@ -253,7 +264,9 @@ export function FocalPointPicker( { onKeyDown={ arrowKeyStep } onMouseDown={ startDrag } onBlur={ () => { - if ( isDragging ) endDrag(); + if ( isDragging ) { + endDrag(); + } } } ref={ dragAreaRef } role="button" diff --git a/packages/components/src/focal-point-picker/utils.ts b/packages/components/src/focal-point-picker/utils.ts index 9ded459d2ac41..0fa5f5707e924 100644 --- a/packages/components/src/focal-point-picker/utils.ts +++ b/packages/components/src/focal-point-picker/utils.ts @@ -34,7 +34,9 @@ export function getExtension( filename = '' ): string { * @return Whether the file is a video. */ export function isVideoType( filename: string = '' ): boolean { - if ( ! filename ) return false; + if ( ! filename ) { + return false; + } return ( filename.startsWith( 'data:video/' ) || VIDEO_EXTENSIONS.includes( getExtension( filename ) ) diff --git a/packages/components/src/input-control/input-field.tsx b/packages/components/src/input-control/input-field.tsx index a7ff4a6e6aeae..d9b5a293a0fa6 100644 --- a/packages/components/src/input-control/input-field.tsx +++ b/packages/components/src/input-control/input-field.tsx @@ -155,7 +155,9 @@ function InputField( target, }; - if ( ! distance ) return; + if ( ! distance ) { + return; + } event.stopPropagation(); /** diff --git a/packages/components/src/input-control/label.tsx b/packages/components/src/input-control/label.tsx index 9c82d4d790273..50a92289be020 100644 --- a/packages/components/src/input-control/label.tsx +++ b/packages/components/src/input-control/label.tsx @@ -15,7 +15,9 @@ export default function Label( { htmlFor, ...props }: WordPressComponentProps< InputControlLabelProps, 'label', false > ) { - if ( ! children ) return null; + if ( ! children ) { + return null; + } if ( hideLabelFromVision ) { return ( diff --git a/packages/components/src/input-control/styles/input-control-styles.tsx b/packages/components/src/input-control/styles/input-control-styles.tsx index c52078223e36f..3192141a8ac0b 100644 --- a/packages/components/src/input-control/styles/input-control-styles.tsx +++ b/packages/components/src/input-control/styles/input-control-styles.tsx @@ -107,9 +107,13 @@ const containerWidthStyles = ( { __unstableInputWidth, labelPosition, }: ContainerProps ) => { - if ( ! __unstableInputWidth ) return css( { width: '100%' } ); + if ( ! __unstableInputWidth ) { + return css( { width: '100%' } ); + } - if ( labelPosition === 'side' ) return ''; + if ( labelPosition === 'side' ) { + return ''; + } if ( labelPosition === 'edge' ) { return css( { @@ -143,7 +147,9 @@ type InputProps = { }; const disabledStyles = ( { disabled }: InputProps ) => { - if ( ! disabled ) return ''; + if ( ! disabled ) { + return ''; + } return css( { color: COLORS.ui.textDisabled, @@ -161,7 +167,9 @@ export const fontSizeStyles = ( { inputSize: size }: InputProps ) => { const fontSize = sizes[ size as Size ] || sizes.default; const fontSizeMobile = '16px'; - if ( ! fontSize ) return ''; + if ( ! fontSize ) { + return ''; + } return css` font-size: ${ fontSizeMobile }; diff --git a/packages/components/src/input-control/test/index.js b/packages/components/src/input-control/test/index.js index 1ca2860442bd9..4a2230bb664fe 100644 --- a/packages/components/src/input-control/test/index.js +++ b/packages/components/src/input-control/test/index.js @@ -112,10 +112,13 @@ describe( 'InputControl', () => { const onKeyDown = ( { key } ) => { heldKeySet.add( key ); if ( key === 'Escape' ) { - if ( heldKeySet.has( 'Meta' ) ) setState( 'qux' ); - else if ( heldKeySet.has( 'Alt' ) ) + if ( heldKeySet.has( 'Meta' ) ) { + setState( 'qux' ); + } else if ( heldKeySet.has( 'Alt' ) ) { setState( undefined ); - else setState( '' ); + } else { + setState( '' ); + } } }; const onKeyUp = ( { key } ) => heldKeySet.delete( key ); @@ -204,8 +207,9 @@ describe( 'InputControl', () => { if ( action.type === 'COMMIT' && action.payload.event.type === 'blur' - ) + ) { value = value.replace( /\bnow\b/, 'meow' ); + } return { ...state, value }; } } diff --git a/packages/components/src/input-control/utils.ts b/packages/components/src/input-control/utils.ts index f82002fb6d78b..7e3eb93980800 100644 --- a/packages/components/src/input-control/utils.ts +++ b/packages/components/src/input-control/utils.ts @@ -86,10 +86,11 @@ export function useDraft( props: { useLayoutEffect( () => { const { current: previousValue } = refPreviousValue; refPreviousValue.current = props.value; - if ( draft.value !== undefined && ! draft.isStale ) + if ( draft.value !== undefined && ! draft.isStale ) { setDraft( { ...draft, isStale: true } ); - else if ( draft.isStale && props.value !== previousValue ) + } else if ( draft.isStale && props.value !== previousValue ) { setDraft( {} ); + } }, [ props.value, draft ] ); const onChange: InputChangeCallback = ( nextValue, extra ) => { diff --git a/packages/components/src/mobile/gradient/index.native.js b/packages/components/src/mobile/gradient/index.native.js index 975afec2e4980..830ea97253b47 100644 --- a/packages/components/src/mobile/gradient/index.native.js +++ b/packages/components/src/mobile/gradient/index.native.js @@ -51,7 +51,9 @@ export function getGradientAngle( gradientValue ) { } } else if ( angleType === 'angle' ) { return parseFloat( angle ); - } else return 4 * angleBase; + } else { + return 4 * angleBase; + } } export function getGradientColorGroup( gradientValue ) { diff --git a/packages/components/src/modal/aria-helper.ts b/packages/components/src/modal/aria-helper.ts index 6d4427ddea948..6a1d39c0a4ed3 100644 --- a/packages/components/src/modal/aria-helper.ts +++ b/packages/components/src/modal/aria-helper.ts @@ -25,7 +25,9 @@ export function modalize( modalElement?: HTMLDivElement ) { const hiddenElements: Element[] = []; hiddenElementsByDepth.push( hiddenElements ); for ( const element of elements ) { - if ( element === modalElement ) continue; + if ( element === modalElement ) { + continue; + } if ( elementShouldBeHidden( element ) ) { element.setAttribute( 'aria-hidden', 'true' ); @@ -56,8 +58,11 @@ export function elementShouldBeHidden( element: Element ) { */ export function unmodalize() { const hiddenElements = hiddenElementsByDepth.pop(); - if ( ! hiddenElements ) return; + if ( ! hiddenElements ) { + return; + } - for ( const element of hiddenElements ) + for ( const element of hiddenElements ) { element.removeAttribute( 'aria-hidden' ); + } } diff --git a/packages/components/src/modal/index.tsx b/packages/components/src/modal/index.tsx index 653c6e7470b32..c505ce210fa5c 100644 --- a/packages/components/src/modal/index.tsx +++ b/packages/components/src/modal/index.tsx @@ -154,7 +154,9 @@ function UnforwardedModal( useEffect( () => { dismissers.push( refOnRequestClose ); const [ first, second ] = dismissers; - if ( second ) first?.current?.(); + if ( second ) { + first?.current?.(); + } const nested = nestedDismissers.current; return () => { @@ -243,7 +245,9 @@ function UnforwardedModal( onPointerUp: ( { target, button } ) => { const isSameTarget = target === pressTarget; pressTarget = null; - if ( button === 0 && isSameTarget ) onRequestClose(); + if ( button === 0 && isSameTarget ) { + onRequestClose(); + } }, }; diff --git a/packages/components/src/modal/test/index.tsx b/packages/components/src/modal/test/index.tsx index b51fc7db1b089..a0d0ee2653edb 100644 --- a/packages/components/src/modal/test/index.tsx +++ b/packages/components/src/modal/test/index.tsx @@ -178,7 +178,9 @@ describe( 'Modal', () => { { isShown && ( { - if ( key === 'o' ) setIsShown( false ); + if ( key === 'o' ) { + setIsShown( false ); + } } } onRequestClose={ noop } > @@ -402,12 +404,17 @@ describe( 'Modal', () => { metaKey, } ) => { if ( key === 'a' ) { - if ( metaKey ) return setIsA1Shown( ( v ) => ! v ); + if ( metaKey ) { + return setIsA1Shown( ( v ) => ! v ); + } return setIsAShown( ( v ) => ! v ); } - if ( key === 'b' ) return setIsBShown( ( v ) => ! v ); - if ( key === 'c' ) + if ( key === 'b' ) { + return setIsBShown( ( v ) => ! v ); + } + if ( key === 'c' ) { return setIsClassOverriden( ( v ) => ! v ); + } }; document.addEventListener( 'keydown', toggles ); return () => diff --git a/packages/components/src/panel/body.tsx b/packages/components/src/panel/body.tsx index 46841f428fac1..d395ed8ed98f4 100644 --- a/packages/components/src/panel/body.tsx +++ b/packages/components/src/panel/body.tsx @@ -109,7 +109,9 @@ const PanelBodyTitle = forwardRef( }: WordPressComponentProps< PanelBodyTitleProps, 'button' >, ref: React.ForwardedRef< any > ) => { - if ( ! title ) return null; + if ( ! title ) { + return null; + } return (

diff --git a/packages/components/src/popover/index.tsx b/packages/components/src/popover/index.tsx index 5fcb5407e4a3f..4ac17056c86ca 100644 --- a/packages/components/src/popover/index.tsx +++ b/packages/components/src/popover/index.tsx @@ -226,8 +226,9 @@ const UnforwardedPopover = ( const { firstElementChild } = refs.floating.current ?? {}; // Only HTMLElement instances have the `style` property. - if ( ! ( firstElementChild instanceof HTMLElement ) ) + if ( ! ( firstElementChild instanceof HTMLElement ) ) { return; + } // Reduce the height of the popover to the available space. Object.assign( firstElementChild.style, { diff --git a/packages/components/src/popover/overlay-middlewares.tsx b/packages/components/src/popover/overlay-middlewares.tsx index fb64d739dce3b..8647fe6fb5251 100644 --- a/packages/components/src/popover/overlay-middlewares.tsx +++ b/packages/components/src/popover/overlay-middlewares.tsx @@ -17,7 +17,9 @@ export function overlayMiddlewares() { const { firstElementChild } = elements.floating ?? {}; // Only HTMLElement instances have the `style` property. - if ( ! ( firstElementChild instanceof HTMLElement ) ) return; + if ( ! ( firstElementChild instanceof HTMLElement ) ) { + return; + } // Reduce the height of the popover to the available space. Object.assign( firstElementChild.style, { diff --git a/packages/components/src/query-controls/author-select.tsx b/packages/components/src/query-controls/author-select.tsx index f5f4feb9525f1..aad1184b44e48 100644 --- a/packages/components/src/query-controls/author-select.tsx +++ b/packages/components/src/query-controls/author-select.tsx @@ -13,7 +13,9 @@ export default function AuthorSelect( { selectedAuthorId, onChange: onChangeProp, }: AuthorSelectProps ) { - if ( ! authorList ) return null; + if ( ! authorList ) { + return null; + } const termsTree = buildTermsTree( authorList ); return ( marks.push( { value: step * marks.length + min } ) ); + while ( count > marks.push( { value: step * marks.length + min } ) ) {} } const placedMarks: RangeMarkProps[] = []; diff --git a/packages/components/src/resizable-box/resize-tooltip/index.tsx b/packages/components/src/resizable-box/resize-tooltip/index.tsx index 4daef4d65d4df..996399f98a12a 100644 --- a/packages/components/src/resizable-box/resize-tooltip/index.tsx +++ b/packages/components/src/resizable-box/resize-tooltip/index.tsx @@ -55,7 +55,9 @@ function ResizeTooltip( position, } ); - if ( ! isVisible ) return null; + if ( ! isVisible ) { + return null; + } const classes = classnames( 'components-resize-tooltip', className ); diff --git a/packages/components/src/resizable-box/resize-tooltip/label.tsx b/packages/components/src/resizable-box/resize-tooltip/label.tsx index 36bb0db72dd2c..6f3cb4c77a49b 100644 --- a/packages/components/src/resizable-box/resize-tooltip/label.tsx +++ b/packages/components/src/resizable-box/resize-tooltip/label.tsx @@ -41,7 +41,9 @@ function Label( const isBottom = position === POSITIONS.bottom; const isCorner = position === POSITIONS.corner; - if ( ! showLabel ) return null; + if ( ! showLabel ) { + return null; + } let style: React.CSSProperties = { opacity: showLabel ? 1 : undefined, diff --git a/packages/components/src/resizable-box/resize-tooltip/utils.ts b/packages/components/src/resizable-box/resize-tooltip/utils.ts index 7daf1b77aa382..09484baaf6a78 100644 --- a/packages/components/src/resizable-box/resize-tooltip/utils.ts +++ b/packages/components/src/resizable-box/resize-tooltip/utils.ts @@ -90,7 +90,9 @@ export function useResizeLabel( { * If axis is controlled, we will avoid resetting the moveX and moveY values. * This will allow for the preferred axis values to persist in the label. */ - if ( isAxisControlled ) return; + if ( isAxisControlled ) { + return; + } setMoveX( false ); setMoveY( false ); }; @@ -109,12 +111,16 @@ export function useResizeLabel( { */ const isRendered = width !== null || height !== null; - if ( ! isRendered ) return; + if ( ! isRendered ) { + return; + } const didWidthChange = width !== widthRef.current; const didHeightChange = height !== heightRef.current; - if ( ! didWidthChange && ! didHeightChange ) return; + if ( ! didWidthChange && ! didHeightChange ) { + return; + } /* * After the initial render, the useResizeAware will set the first @@ -194,7 +200,9 @@ function getSizeLabel( { showPx = false, width, }: GetSizeLabelArgs ): string | undefined { - if ( ! moveX && ! moveY ) return undefined; + if ( ! moveX && ! moveY ) { + return undefined; + } /* * Corner position... diff --git a/packages/components/src/select-control/index.tsx b/packages/components/src/select-control/index.tsx index 4d93c5c870a01..4f2fd7587a4f2 100644 --- a/packages/components/src/select-control/index.tsx +++ b/packages/components/src/select-control/index.tsx @@ -55,7 +55,9 @@ function UnforwardedSelectControl( const helpId = help ? `${ id }__help` : undefined; // Disable reason: A select with an onchange throws a warning. - if ( ! options?.length && ! children ) return null; + if ( ! options?.length && ! children ) { + return null; + } const handleOnChange = ( event: React.ChangeEvent< HTMLSelectElement > diff --git a/packages/components/src/select-control/styles/select-control-styles.ts b/packages/components/src/select-control/styles/select-control-styles.ts index f4b5dc920c04c..cc8dc2cf330b3 100644 --- a/packages/components/src/select-control/styles/select-control-styles.ts +++ b/packages/components/src/select-control/styles/select-control-styles.ts @@ -24,7 +24,9 @@ interface SelectProps } const disabledStyles = ( { disabled }: SelectProps ) => { - if ( ! disabled ) return ''; + if ( ! disabled ) { + return ''; + } return css( { color: COLORS.ui.textDisabled, diff --git a/packages/components/src/text/get-line-height.ts b/packages/components/src/text/get-line-height.ts index 906bd0eabfab9..345391ba334ff 100644 --- a/packages/components/src/text/get-line-height.ts +++ b/packages/components/src/text/get-line-height.ts @@ -14,9 +14,13 @@ export function getLineHeight( adjustLineHeightForInnerControls: Props[ 'adjustLineHeightForInnerControls' ], lineHeight: CSSProperties[ 'lineHeight' ] ) { - if ( lineHeight ) return lineHeight; + if ( lineHeight ) { + return lineHeight; + } - if ( ! adjustLineHeightForInnerControls ) return; + if ( ! adjustLineHeightForInnerControls ) { + return; + } let value = `calc(${ CONFIG.controlHeight } + ${ space( 2 ) })`; diff --git a/packages/components/src/text/utils.ts b/packages/components/src/text/utils.ts index 85e41a56c6e34..bcf7bff9c36ab 100644 --- a/packages/components/src/text/utils.ts +++ b/packages/components/src/text/utils.ts @@ -99,8 +99,12 @@ export function createHighlighterText( { unhighlightClassName = '', unhighlightStyle, }: Options ) { - if ( ! children ) return null; - if ( typeof children !== 'string' ) return children; + if ( ! children ) { + return null; + } + if ( typeof children !== 'string' ) { + return children; + } const textToHighlight = children; diff --git a/packages/components/src/theme/color-algorithms.ts b/packages/components/src/theme/color-algorithms.ts index b2f69e1db2128..bed8353c16b8b 100644 --- a/packages/components/src/theme/color-algorithms.ts +++ b/packages/components/src/theme/color-algorithms.ts @@ -76,7 +76,9 @@ function warnContrastIssues( issues: ReturnType< typeof checkContrasts > ) { } function generateAccentDependentColors( accent?: string ) { - if ( ! accent ) return {}; + if ( ! accent ) { + return {}; + } return { accent, @@ -87,7 +89,9 @@ function generateAccentDependentColors( accent?: string ) { } function generateBackgroundDependentColors( background?: string ) { - if ( ! background ) return {}; + if ( ! background ) { + return {}; + } const foreground = getForegroundForColor( background ); diff --git a/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx b/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx index 421a6078b0495..7990dd3b049c8 100644 --- a/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx +++ b/packages/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx @@ -147,7 +147,9 @@ function ToggleGroupControlOptionBase( { ...commonProps } onFocus={ ( event ) => { onFocusProp?.( event ); - if ( event.defaultPrevented ) return; + if ( event.defaultPrevented ) { + return; + } toggleGroupControlContext.setValue( value ); } } /> diff --git a/packages/components/src/tree-grid/roving-tab-index-item.tsx b/packages/components/src/tree-grid/roving-tab-index-item.tsx index 6bcea5862bf16..d5ed3410ddf68 100644 --- a/packages/components/src/tree-grid/roving-tab-index-item.tsx +++ b/packages/components/src/tree-grid/roving-tab-index-item.tsx @@ -41,7 +41,9 @@ export const RovingTabIndexItem = forwardRef( return children( allProps ); } - if ( ! Component ) return null; + if ( ! Component ) { + return null; + } return { children }; } diff --git a/packages/components/src/unit-control/index.tsx b/packages/components/src/unit-control/index.tsx index 93ec2c358ecf1..e6eb1ee1c09db 100644 --- a/packages/components/src/unit-control/index.tsx +++ b/packages/components/src/unit-control/index.tsx @@ -170,8 +170,12 @@ function UnforwardedUnitControl( // Unless the meta key was pressed (to avoid interfering with // shortcuts, e.g. pastes), moves focus to the unit select if a key // matches the first character of a unit. - if ( ! event.metaKey && reFirstCharacterOfUnits.test( event.key ) ) + if ( + ! event.metaKey && + reFirstCharacterOfUnits.test( event.key ) + ) { refInputSuffix.current?.focus(); + } }; } diff --git a/packages/components/src/utils/colors.js b/packages/components/src/utils/colors.js index 25e7e2063cabd..cab2202b0ce56 100644 --- a/packages/components/src/utils/colors.js +++ b/packages/components/src/utils/colors.js @@ -29,7 +29,9 @@ export function rgba( hexValue = '', alpha = 1 ) { * @return {HTMLDivElement | undefined} The HTML element for color computation. */ function getColorComputationNode() { - if ( typeof document === 'undefined' ) return; + if ( typeof document === 'undefined' ) { + return; + } if ( ! colorComputationNode ) { // Create a temporary element for style computation. @@ -49,7 +51,9 @@ function getColorComputationNode() { * @return {boolean} Whether the value is a valid color. */ function isColor( value ) { - if ( typeof value !== 'string' ) return false; + if ( typeof value !== 'string' ) { + return false; + } const test = colord( value ); return test.isValid(); @@ -64,16 +68,26 @@ function isColor( value ) { * @return {string} The computed background color. */ function _getComputedBackgroundColor( backgroundColor ) { - if ( typeof backgroundColor !== 'string' ) return ''; + if ( typeof backgroundColor !== 'string' ) { + return ''; + } - if ( isColor( backgroundColor ) ) return backgroundColor; + if ( isColor( backgroundColor ) ) { + return backgroundColor; + } - if ( ! backgroundColor.includes( 'var(' ) ) return ''; - if ( typeof document === 'undefined' ) return ''; + if ( ! backgroundColor.includes( 'var(' ) ) { + return ''; + } + if ( typeof document === 'undefined' ) { + return ''; + } // Attempts to gracefully handle CSS variables color values. const el = getColorComputationNode(); - if ( ! el ) return ''; + if ( ! el ) { + return ''; + } el.style.background = backgroundColor; // Grab the style. diff --git a/packages/components/src/utils/font-size.ts b/packages/components/src/utils/font-size.ts index e1a5a543709f4..c9a3b044b55a2 100644 --- a/packages/components/src/utils/font-size.ts +++ b/packages/components/src/utils/font-size.ts @@ -51,7 +51,9 @@ export function getFontSize( if ( typeof size !== 'number' ) { const parsed = parseFloat( size ); - if ( Number.isNaN( parsed ) ) return size; + if ( Number.isNaN( parsed ) ) { + return size; + } size = parsed; } diff --git a/packages/components/src/utils/get-valid-children.ts b/packages/components/src/utils/get-valid-children.ts index 726630cd6516b..07d4aa038e8a2 100644 --- a/packages/components/src/utils/get-valid-children.ts +++ b/packages/components/src/utils/get-valid-children.ts @@ -18,7 +18,9 @@ import { Children, isValidElement } from '@wordpress/element'; export function getValidChildren( children: ReactNode ): Array< ReactChild | ReactFragment | ReactPortal > { - if ( typeof children === 'string' ) return [ children ]; + if ( typeof children === 'string' ) { + return [ children ]; + } return Children.toArray( children ).filter( ( child ) => isValidElement( child ) diff --git a/packages/components/src/utils/use-responsive-value.ts b/packages/components/src/utils/use-responsive-value.ts index d8b324b097a52..be986cb4fe3c0 100644 --- a/packages/components/src/utils/use-responsive-value.ts +++ b/packages/components/src/utils/use-responsive-value.ts @@ -60,8 +60,9 @@ export function useResponsiveValue< T >( const index = useBreakpointIndex( options ); // Allow calling the function with a "normal" value without having to check on the outside. - if ( ! Array.isArray( values ) && typeof values !== 'function' ) + if ( ! Array.isArray( values ) && typeof values !== 'function' ) { return values; + } const array = values || []; diff --git a/packages/compose/src/hooks/use-focusable-iframe/index.ts b/packages/compose/src/hooks/use-focusable-iframe/index.ts index a184bde404558..31024bd8246d1 100644 --- a/packages/compose/src/hooks/use-focusable-iframe/index.ts +++ b/packages/compose/src/hooks/use-focusable-iframe/index.ts @@ -17,9 +17,13 @@ import useRefEffect from '../use-ref-effect'; export default function useFocusableIframe(): RefCallback< HTMLIFrameElement > { return useRefEffect( ( element ) => { const { ownerDocument } = element; - if ( ! ownerDocument ) return; + if ( ! ownerDocument ) { + return; + } const { defaultView } = ownerDocument; - if ( ! defaultView ) return; + if ( ! defaultView ) { + return; + } /** * Checks whether the iframe is the activeElement, inferring that it has diff --git a/packages/compose/src/hooks/use-instance-id/index.ts b/packages/compose/src/hooks/use-instance-id/index.ts index 8f21c9657e8fa..65edc2a5d05d0 100644 --- a/packages/compose/src/hooks/use-instance-id/index.ts +++ b/packages/compose/src/hooks/use-instance-id/index.ts @@ -51,7 +51,9 @@ function useInstanceId( preferredId?: string | number ): string | number { return useMemo( () => { - if ( preferredId ) return preferredId; + if ( preferredId ) { + return preferredId; + } const id = createId( object ); return prefix ? `${ prefix }-${ id }` : id; diff --git a/packages/core-data/src/footnotes/index.js b/packages/core-data/src/footnotes/index.js index 066c0ea37a824..9e30f10c06a93 100644 --- a/packages/core-data/src/footnotes/index.js +++ b/packages/core-data/src/footnotes/index.js @@ -12,17 +12,23 @@ let oldFootnotes = {}; export function updateFootnotesFromMeta( blocks, meta ) { const output = { blocks }; - if ( ! meta ) return output; + if ( ! meta ) { + return output; + } // If meta.footnotes is empty, it means the meta is not registered. - if ( meta.footnotes === undefined ) return output; + if ( meta.footnotes === undefined ) { + return output; + } const newOrder = getFootnotesOrder( blocks ); const footnotes = meta.footnotes ? JSON.parse( meta.footnotes ) : []; const currentOrder = footnotes.map( ( fn ) => fn.id ); - if ( currentOrder.join( '' ) === newOrder.join( '' ) ) return output; + if ( currentOrder.join( '' ) === newOrder.join( '' ) ) { + return output; + } const newFootnotes = newOrder.map( ( fnId ) => diff --git a/packages/core-data/src/selectors.ts b/packages/core-data/src/selectors.ts index d238438e10eb1..242d516170d27 100644 --- a/packages/core-data/src/selectors.ts +++ b/packages/core-data/src/selectors.ts @@ -619,9 +619,13 @@ export const getEntityRecordsTotalPages = ( if ( ! queriedState ) { return null; } - if ( query.per_page === -1 ) return 1; + if ( query.per_page === -1 ) { + return 1; + } const totalItems = getQueriedTotalItems( queriedState, query ); - if ( ! totalItems ) return totalItems; + if ( ! totalItems ) { + return totalItems; + } // If `per_page` is not set and the query relies on the defaults of the // REST endpoint, get the info from query's meta. if ( ! query.per_page ) { diff --git a/packages/dependency-extraction-webpack-plugin/test/build.js b/packages/dependency-extraction-webpack-plugin/test/build.js index 0b28b679bba92..050b816ded343 100644 --- a/packages/dependency-extraction-webpack-plugin/test/build.js +++ b/packages/dependency-extraction-webpack-plugin/test/build.js @@ -108,8 +108,12 @@ describe.each( /** @type {const} */ ( [ 'scripts', 'modules' ] ) )( const compareByModuleIdentifier = ( m1, m2 ) => { const i1 = m1.identifier(); const i2 = m2.identifier(); - if ( i1 < i2 ) return -1; - if ( i1 > i2 ) return 1; + if ( i1 < i2 ) { + return -1; + } + if ( i1 > i2 ) { + return 1; + } return 0; }; diff --git a/packages/dom/src/dom/get-rectangle-from-range.js b/packages/dom/src/dom/get-rectangle-from-range.js index 1874a331a641f..12946c753b43f 100644 --- a/packages/dom/src/dom/get-rectangle-from-range.js +++ b/packages/dom/src/dom/get-rectangle-from-range.js @@ -43,10 +43,18 @@ export default function getRectangleFromRange( range ) { } = filteredRects[ 0 ]; for ( const { top, bottom, left, right } of filteredRects ) { - if ( top < furthestTop ) furthestTop = top; - if ( bottom > furthestBottom ) furthestBottom = bottom; - if ( left < furthestLeft ) furthestLeft = left; - if ( right > furthestRight ) furthestRight = right; + if ( top < furthestTop ) { + furthestTop = top; + } + if ( bottom > furthestBottom ) { + furthestBottom = bottom; + } + if ( left < furthestLeft ) { + furthestLeft = left; + } + if ( right > furthestRight ) { + furthestRight = right; + } } return new window.DOMRect( diff --git a/packages/dom/src/dom/place-caret-at-edge.js b/packages/dom/src/dom/place-caret-at-edge.js index 9cb9958dc8843..4075fc7c43958 100644 --- a/packages/dom/src/dom/place-caret-at-edge.js +++ b/packages/dom/src/dom/place-caret-at-edge.js @@ -75,7 +75,9 @@ export default function placeCaretAtEdge( container, isReverse, x ) { getRange( container, isReverse, x ) ); - if ( ! range ) return; + if ( ! range ) { + return; + } const { ownerDocument } = container; const { defaultView } = ownerDocument; diff --git a/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts b/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts index e9cfefd9f65d5..5b06c6a2c53cb 100644 --- a/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts +++ b/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts @@ -24,10 +24,18 @@ export async function createNewPost( const query = new URLSearchParams(); const { postType, title, content, excerpt } = options; - if ( postType ) query.set( 'post_type', postType ); - if ( title ) query.set( 'post_title', title ); - if ( content ) query.set( 'content', content ); - if ( excerpt ) query.set( 'excerpt', excerpt ); + if ( postType ) { + query.set( 'post_type', postType ); + } + if ( title ) { + query.set( 'post_title', title ); + } + if ( content ) { + query.set( 'content', content ); + } + if ( excerpt ) { + query.set( 'excerpt', excerpt ); + } await this.visitAdminPage( 'post-new.php', query.toString() ); diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts index 5883a2b92a5bc..251dae98cf203 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts @@ -24,10 +24,18 @@ export async function visitSiteEditor( const { postId, postType, path, canvas } = options; const query = new URLSearchParams(); - if ( postId ) query.set( 'postId', String( postId ) ); - if ( postType ) query.set( 'postType', postType ); - if ( path ) query.set( 'path', path ); - if ( canvas ) query.set( 'canvas', canvas ); + if ( postId ) { + query.set( 'postId', String( postId ) ); + } + if ( postType ) { + query.set( 'postType', postType ); + } + if ( path ) { + query.set( 'path', path ); + } + if ( canvas ) { + query.set( 'canvas', canvas ); + } await this.visitAdminPage( 'site-editor.php', query.toString() ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js index 5b981c552b746..c78be9f81200a 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js @@ -147,9 +147,9 @@ store( 'directive-each', { state .animalBreeds .forEach( ( { name, breeds } ) => { - if ( name === 'Dog') breeds.unshift( 'german shepherd' ); - if ( name === 'Cat') breeds.unshift( 'maine coon' ); - if ( name === 'Rat') breeds.unshift( 'satin' ); + if ( name === 'Dog') {breeds.unshift( 'german shepherd' );} + if ( name === 'Cat') {breeds.unshift( 'maine coon' );} + if ( name === 'Rat') {breeds.unshift( 'satin' );} } ); } } diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js index c4a7ae2f6e875..d43c8b8373cf3 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js @@ -24,8 +24,8 @@ const namespace = 'directive-priorities'; */ const executionProof = ( n ) => { const el = document.querySelector( '[data-testid="execution order"]' ); - if ( ! el.textContent ) el.textContent = n; - else el.textContent += `, ${ n }`; + if ( ! el.textContent ) {el.textContent = n;} + else {el.textContent += `, ${ n }`;} }; /** diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js index c333269cd6377..67402099e00a5 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js @@ -13,7 +13,7 @@ directive( 'show-mock', ( { directives: { 'show-mock': showMock }, element, evaluate } ) => { const entry = showMock.find( ( { suffix } ) => suffix === 'default' ); - if ( ! evaluate( entry ) ) return null; + if ( ! evaluate( entry ) ) {return null;} return element; } ); diff --git a/packages/edit-site/src/components/add-new-pattern/index.js b/packages/edit-site/src/components/add-new-pattern/index.js index 8c051d5ca51ec..437e4a531b055 100644 --- a/packages/edit-site/src/components/add-new-pattern/index.js +++ b/packages/edit-site/src/components/add-new-pattern/index.js @@ -131,7 +131,9 @@ export default function AddNewPattern( { canCreateParts, canCreatePatterns } ) { ref={ patternUploadInputRef } onChange={ async ( event ) => { const file = event.target.files?.[ 0 ]; - if ( ! file ) return; + if ( ! file ) { + return; + } try { let currentCategoryId; // When we're not handling template parts, we should diff --git a/packages/edit-site/src/components/add-new-template/add-custom-template-modal-content.js b/packages/edit-site/src/components/add-new-template/add-custom-template-modal-content.js index 44554eac0dcd6..10f3c7c54521f 100644 --- a/packages/edit-site/src/components/add-new-template/add-custom-template-modal-content.js +++ b/packages/edit-site/src/components/add-new-template/add-custom-template-modal-content.js @@ -99,7 +99,9 @@ function useSearchSuggestions( entityForSuggestions, search ) { ); const [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY ); useEffect( () => { - if ( ! searchHasResolved ) return; + if ( ! searchHasResolved ) { + return; + } let newSuggestions = EMPTY_ARRAY; if ( searchResults?.length ) { newSuggestions = searchResults; diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/context.js b/packages/edit-site/src/components/global-styles/font-library-modal/context.js index ca8fb54d5e485..9eafabe9424fb 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/context.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/context.js @@ -496,11 +496,15 @@ function FontLibraryProvider( { children } ) { const loadFontFaceAsset = async ( fontFace ) => { // If the font doesn't have a src, don't load it. - if ( ! fontFace.src ) return; + if ( ! fontFace.src ) { + return; + } // Get the src of the font. const src = getDisplaySrcFromFontFace( fontFace.src ); // If the font is already loaded, don't load it again. - if ( ! src || loadedFontUrls.has( src ) ) return; + if ( ! src || loadedFontUrls.has( src ) ) { + return; + } // Load the font in the browser. loadFontFaceInBrowser( fontFace, src, 'document' ); // Add the font to the loaded fonts list. @@ -518,7 +522,9 @@ function FontLibraryProvider( { children } ) { const hasData = !! collections.find( ( collection ) => collection.slug === slug )?.font_families; - if ( hasData ) return; + if ( hasData ) { + return; + } const response = await fetchFontCollection( slug ); const updatedCollections = collections.map( ( collection ) => collection.slug === slug diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/utils/sort-font-faces.js b/packages/edit-site/src/components/global-styles/font-library-modal/utils/sort-font-faces.js index 4d94318c9b447..69798112f07d3 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/utils/sort-font-faces.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/utils/sort-font-faces.js @@ -16,8 +16,12 @@ function getNumericFontWeight( value ) { export function sortFontFaces( faces ) { return faces.sort( ( a, b ) => { // Ensure 'normal' fontStyle is always first - if ( a.fontStyle === 'normal' && b.fontStyle !== 'normal' ) return -1; - if ( b.fontStyle === 'normal' && a.fontStyle !== 'normal' ) return 1; + if ( a.fontStyle === 'normal' && b.fontStyle !== 'normal' ) { + return -1; + } + if ( b.fontStyle === 'normal' && a.fontStyle !== 'normal' ) { + return 1; + } // If both fontStyles are the same, sort by fontWeight if ( a.fontStyle === b.fontStyle ) { diff --git a/packages/edit-site/src/components/page-patterns/header.js b/packages/edit-site/src/components/page-patterns/header.js index 7cca997c7dd02..85ca443cff3b5 100644 --- a/packages/edit-site/src/components/page-patterns/header.js +++ b/packages/edit-site/src/components/page-patterns/header.js @@ -52,7 +52,9 @@ export default function PatternsHeader( { description = patternCategory?.description; } - if ( ! title ) return null; + if ( ! title ) { + return null; + } return ( diff --git a/packages/edit-site/src/components/resizable-frame/index.js b/packages/edit-site/src/components/resizable-frame/index.js index 65ffdc9a4ddb7..14d6f676b262e 100644 --- a/packages/edit-site/src/components/resizable-frame/index.js +++ b/packages/edit-site/src/components/resizable-frame/index.js @@ -226,8 +226,9 @@ function ResizableFrame( { variants={ frameAnimationVariants } animate={ isFullWidth ? 'fullWidth' : 'default' } onAnimationComplete={ ( definition ) => { - if ( definition === 'fullWidth' ) + if ( definition === 'fullWidth' ) { setFrameSize( { width: '100%', height: '100%' } ); + } } } transition={ FRAME_TRANSITION } size={ frameSize } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js index 4e335e94b8ffa..d766d04b132ca 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js @@ -10,7 +10,9 @@ import TemplatePartNavigationMenu from './template-part-navigation-menu'; import TemplatePartNavigationMenuList from './template-part-navigation-menu-list'; export default function TemplatePartNavigationMenus( { menus } ) { - if ( ! menus.length ) return null; + if ( ! menus.length ) { + return null; + } // if there is a single menu then render TemplatePartNavigationMenu if ( menus.length === 1 ) { diff --git a/packages/editor/src/components/preview-dropdown/index.js b/packages/editor/src/components/preview-dropdown/index.js index d78ef020fe232..1e61b004a20ee 100644 --- a/packages/editor/src/components/preview-dropdown/index.js +++ b/packages/editor/src/components/preview-dropdown/index.js @@ -38,7 +38,9 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) { }, [] ); const { setDeviceType } = useDispatch( editorStore ); const isMobile = useViewportMatch( 'medium', '<' ); - if ( isMobile ) return null; + if ( isMobile ) { + return null; + } const popoverProps = { placement: 'bottom-end', diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index d5848ed8f08e9..e1a6be18e4601 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -838,7 +838,9 @@ export const getSuggestedPostFormat = createRegistrySelector( ( select ) => () => { const blocks = select( blockEditorStore ).getBlocks(); - if ( blocks.length > 2 ) return null; + if ( blocks.length > 2 ) { + return null; + } let name; // If there is only one block in the content of the post grab its name diff --git a/packages/format-library/src/link/utils.js b/packages/format-library/src/link/utils.js index 12fc56f242031..314c8118713a4 100644 --- a/packages/format-library/src/link/utils.js +++ b/packages/format-library/src/link/utils.js @@ -102,8 +102,12 @@ export function createLinkFormat( { }, }; - if ( type ) format.attributes.type = type; - if ( id ) format.attributes.id = id; + if ( type ) { + format.attributes.type = type; + } + if ( id ) { + format.attributes.id = id; + } if ( opensInNewWindow ) { format.attributes.target = '_blank'; diff --git a/packages/format-library/src/text-color/inline.js b/packages/format-library/src/text-color/inline.js index 8bd4ae33c7844..68631e7e5b3b7 100644 --- a/packages/format-library/src/text-color/inline.js +++ b/packages/format-library/src/text-color/inline.js @@ -39,9 +39,15 @@ function parseCSS( css = '' ) { return css.split( ';' ).reduce( ( accumulator, rule ) => { if ( rule ) { const [ property, value ] = rule.split( ':' ); - if ( property === 'color' ) accumulator.color = value; - if ( property === 'background-color' && value !== transparentValue ) + if ( property === 'color' ) { + accumulator.color = value; + } + if ( + property === 'background-color' && + value !== transparentValue + ) { accumulator.backgroundColor = value; + } } return accumulator; }, {} ); @@ -108,8 +114,12 @@ function setColors( value, name, colorSettings, colors ) { } } - if ( styles.length ) attributes.style = styles.join( ';' ); - if ( classNames.length ) attributes.class = classNames.join( ' ' ); + if ( styles.length ) { + attributes.style = styles.join( ';' ); + } + if ( classNames.length ) { + attributes.class = classNames.join( ' ' ); + } return applyFormat( value, { type: name, attributes } ); } diff --git a/packages/format-library/src/text-color/inline.native.js b/packages/format-library/src/text-color/inline.native.js index 11d78d0a95543..4199ce413ee9f 100644 --- a/packages/format-library/src/text-color/inline.native.js +++ b/packages/format-library/src/text-color/inline.native.js @@ -28,9 +28,15 @@ function parseCSS( css = '' ) { return css.split( ';' ).reduce( ( accumulator, rule ) => { if ( rule ) { const [ property, value ] = rule.replace( / /g, '' ).split( ':' ); - if ( property === 'color' ) accumulator.color = value; - if ( property === 'background-color' && value !== transparentValue ) + if ( property === 'color' ) { + accumulator.color = value; + } + if ( + property === 'background-color' && + value !== transparentValue + ) { accumulator.backgroundColor = value; + } } return accumulator; }, {} ); @@ -82,8 +88,12 @@ function setColors( value, name, colorSettings, colors, contentRef ) { } } - if ( styles.length ) attributes.style = styles.join( ';' ); - if ( classNames.length ) attributes.class = classNames.join( ' ' ); + if ( styles.length ) { + attributes.style = styles.join( ';' ); + } + if ( classNames.length ) { + attributes.class = classNames.join( ' ' ); + } const format = { type: name, attributes }; const hasNoSelection = value.start === value.end; diff --git a/packages/interactivity-router/src/head.js b/packages/interactivity-router/src/head.js index a8cce487e592e..6106ad173d49f 100644 --- a/packages/interactivity-router/src/head.js +++ b/packages/interactivity-router/src/head.js @@ -21,11 +21,13 @@ export const updateHead = async ( newHead ) => { for ( const child of document.head.children ) { const id = getTagId( child ); // Always remove styles and links as they might change. - if ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) + if ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) { toRemove.push( child ); - else if ( newHeadMap.has( id ) ) newHeadMap.delete( id ); - else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) + } else if ( newHeadMap.has( id ) ) { + newHeadMap.delete( id ); + } else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) { toRemove.push( child ); + } } // Prepare new assets. diff --git a/packages/interactivity-router/src/index.js b/packages/interactivity-router/src/index.js index 03d75bafa82f4..7e786700338f5 100644 --- a/packages/interactivity-router/src/index.js +++ b/packages/interactivity-router/src/index.js @@ -41,7 +41,9 @@ const fetchPage = async ( url, { html } ) => { try { if ( ! html ) { const res = await window.fetch( url ); - if ( res.status !== 200 ) return false; + if ( res.status !== 200 ) { + return false; + } html = await res.text(); } const dom = new window.DOMParser().parseFromString( html, 'text/html' ); @@ -232,7 +234,9 @@ export const { state, actions } = store( 'core/router', { // Don't update the navigation status immediately, wait 400 ms. const loadingTimeout = setTimeout( () => { - if ( navigatingTo !== href ) return; + if ( navigatingTo !== href ) { + return; + } if ( loadingAnimation ) { navigation.hasStarted = true; @@ -254,7 +258,9 @@ export const { state, actions } = store( 'core/router', { // Once the page is fetched, the destination URL could have changed // (e.g., by clicking another link in the meantime). If so, bail // out, and let the newer execution to update the HTML. - if ( navigatingTo !== href ) return; + if ( navigatingTo !== href ) { + return; + } if ( page && @@ -289,7 +295,9 @@ export const { state, actions } = store( 'core/router', { // Scroll to the anchor if exits in the link. const { hash } = new URL( href, window.location ); - if ( hash ) document.querySelector( hash )?.scrollIntoView(); + if ( hash ) { + document.querySelector( hash )?.scrollIntoView(); + } } else { yield forcePageReload( href ); } @@ -308,7 +316,9 @@ export const { state, actions } = store( 'core/router', { */ prefetch( url, options = {} ) { const { clientNavigationDisabled } = getConfig(); - if ( clientNavigationDisabled ) return; + if ( clientNavigationDisabled ) { + return; + } const pagePath = getPagePath( url ); if ( options.force || ! pages.has( pagePath ) ) { diff --git a/packages/interactivity/src/directives.js b/packages/interactivity/src/directives.js index b90ebbdaad63e..7afcbbbd60e22 100644 --- a/packages/interactivity/src/directives.js +++ b/packages/interactivity/src/directives.js @@ -285,7 +285,9 @@ export default () => { on.filter( ( { suffix } ) => suffix !== 'default' ).forEach( ( entry ) => { const event = entry.suffix.split( '--' )[ 0 ]; - if ( ! events.has( event ) ) events.set( event, new Set() ); + if ( ! events.has( event ) ) { + events.set( event, new Set() ); + } events.get( event ).add( entry ); } ); @@ -318,14 +320,15 @@ export default () => { `(^|\\s)${ className }(\\s|$)`, 'g' ); - if ( ! result ) + if ( ! result ) { element.props.class = currentClass .replace( classFinder, ' ' ) .trim(); - else if ( ! classFinder.test( currentClass ) ) + } else if ( ! classFinder.test( currentClass ) ) { element.props.class = currentClass ? `${ currentClass } ${ className }` : className; + } useInit( () => { /* @@ -351,12 +354,16 @@ export default () => { const styleProp = entry.suffix; const result = evaluate( entry ); element.props.style = element.props.style || {}; - if ( typeof element.props.style === 'string' ) + if ( typeof element.props.style === 'string' ) { element.props.style = cssStringToObject( element.props.style ); - if ( ! result ) delete element.props.style[ styleProp ]; - else element.props.style[ styleProp ] = result; + } + if ( ! result ) { + delete element.props.style[ styleProp ]; + } else { + element.props.style[ styleProp ] = result; + } useInit( () => { /* @@ -395,8 +402,9 @@ export default () => { * logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L110-L129 */ if ( attribute === 'style' ) { - if ( typeof result === 'string' ) + if ( typeof result === 'string' ) { el.style.cssText = result; + } return; } else if ( attribute !== 'width' && @@ -496,7 +504,9 @@ export default () => { element, evaluate, } ) => { - if ( element.type !== 'template' ) return; + if ( element.type !== 'template' ) { + return; + } const { Provider } = inheritedContext; const inheritedValue = useContext( inheritedContext ); diff --git a/packages/interactivity/src/hooks.tsx b/packages/interactivity/src/hooks.tsx index 00c3c0d6d1729..f223ddceb9a41 100644 --- a/packages/interactivity/src/hooks.tsx +++ b/packages/interactivity/src/hooks.tsx @@ -112,8 +112,9 @@ const immutableHandlers = { deleteProperty: immutableError, }; const deepImmutable = < T extends Object = {} >( target: T ): T => { - if ( ! immutableMap.has( target ) ) + if ( ! immutableMap.has( target ) ) { immutableMap.set( target, new Proxy( target, immutableHandlers ) ); + } return immutableMap.get( target ); }; @@ -359,7 +360,9 @@ const Directives = ( { for ( const directiveName of currentPriorityLevel ) { const wrapper = directiveCallbacks[ directiveName ]?.( directiveArgs ); - if ( wrapper !== undefined ) props.children = wrapper; + if ( wrapper !== undefined ) { + props.children = wrapper; + } } resetScope(); @@ -373,10 +376,11 @@ options.vnode = ( vnode: VNode< any > ) => { if ( vnode.props.__directives ) { const props = vnode.props; const directives = props.__directives; - if ( directives.key ) + if ( directives.key ) { vnode.key = directives.key.find( ( { suffix } ) => suffix === 'default' ).value; + } delete props.__directives; const priorityLevels = getPriorityLevels( directives ); if ( priorityLevels.length > 0 ) { @@ -392,5 +396,7 @@ options.vnode = ( vnode: VNode< any > ) => { } } - if ( old ) old( vnode ); + if ( old ) { + old( vnode ); + } }; diff --git a/packages/interactivity/src/store.ts b/packages/interactivity/src/store.ts index 2aad8c23d1db1..81905071702af 100644 --- a/packages/interactivity/src/store.ts +++ b/packages/interactivity/src/store.ts @@ -26,7 +26,9 @@ const deepMerge = ( target: any, source: any ) => { if ( typeof getter === 'function' ) { Object.defineProperty( target, key, { get: getter } ); } else if ( isObject( source[ key ] ) ) { - if ( ! target[ key ] ) target[ key ] = {}; + if ( ! target[ key ] ) { + target[ key ] = {}; + } deepMerge( target[ key ], source[ key ] ); } else { try { @@ -133,7 +135,9 @@ const handlers = { resetNamespace(); } - if ( it.done ) break; + if ( it.done ) { + break; + } } return value; @@ -155,7 +159,9 @@ const handlers = { } // Check if the property is an object. If it is, proxyify it. - if ( isObject( result ) ) return proxify( result, ns ); + if ( isObject( result ) ) { + return proxify( result, ns ); + } return result; }, diff --git a/packages/interactivity/src/utils.ts b/packages/interactivity/src/utils.ts index e9162f0dd7cd7..4759a7b27a74a 100644 --- a/packages/interactivity/src/utils.ts +++ b/packages/interactivity/src/utils.ts @@ -141,7 +141,9 @@ export function withScope( func: ( ...args: unknown[] ) => unknown ) { } catch ( e ) { gen.throw( e ); } - if ( it.done ) break; + if ( it.done ) { + break; + } } return value; }; diff --git a/packages/interactivity/src/vdom.ts b/packages/interactivity/src/vdom.ts index 5a99799366809..05b49012c4886 100644 --- a/packages/interactivity/src/vdom.ts +++ b/packages/interactivity/src/vdom.ts @@ -50,7 +50,9 @@ export function toVdom( root ) { function walk( node ) { const { attributes, nodeType, localName } = node; - if ( nodeType === 3 ) return [ node.data ]; + if ( nodeType === 3 ) { + return [ node.data ]; + } if ( nodeType === 4 ) { const next = treeWalker.nextSibling(); node.replaceWith( new window.Text( node.nodeValue ) ); @@ -100,7 +102,7 @@ export function toVdom( root ) { props[ n ] = attributes[ i ].value; } - if ( ignore && ! island ) + if ( ignore && ! island ) { return [ h( localName, { ...props, @@ -108,14 +110,19 @@ export function toVdom( root ) { __directives: { ignore: true }, } ), ]; - if ( island ) hydratedIslands.add( node ); + } + if ( island ) { + hydratedIslands.add( node ); + } if ( directives.length ) { props.__directives = directives.reduce( ( obj, [ name, ns, value ] ) => { const [ , prefix, suffix = 'default' ] = directiveParser.exec( name ); - if ( ! obj[ prefix ] ) obj[ prefix ] = []; + if ( ! obj[ prefix ] ) { + obj[ prefix ] = []; + } obj[ prefix ].push( { namespace: ns ?? currentNamespace(), value, @@ -136,7 +143,9 @@ export function toVdom( root ) { if ( child ) { while ( child ) { const [ vnode, nextChild ] = walk( child ); - if ( vnode ) children.push( vnode ); + if ( vnode ) { + children.push( vnode ); + } child = nextChild || treeWalker.nextSibling(); } treeWalker.parentNode(); @@ -144,7 +153,9 @@ export function toVdom( root ) { } // Restore previous namespace. - if ( island ) namespaces.pop(); + if ( island ) { + namespaces.pop(); + } return [ h( localName, props, children ) ]; } diff --git a/packages/keyboard-shortcuts/src/components/shortcut-provider.js b/packages/keyboard-shortcuts/src/components/shortcut-provider.js index 485350bb3c0e9..997c9725096e4 100644 --- a/packages/keyboard-shortcuts/src/components/shortcut-provider.js +++ b/packages/keyboard-shortcuts/src/components/shortcut-provider.js @@ -23,7 +23,9 @@ export function ShortcutProvider( props ) { const [ keyboardShortcuts ] = useState( () => new Set() ); function onKeyDown( event ) { - if ( props.onKeyDown ) props.onKeyDown( event ); + if ( props.onKeyDown ) { + props.onKeyDown( event ); + } for ( const keyboardShortcut of keyboardShortcuts ) { keyboardShortcut( event ); diff --git a/packages/patterns/src/components/pattern-overrides-controls.js b/packages/patterns/src/components/pattern-overrides-controls.js index 1cfe953b4a455..f25a418064734 100644 --- a/packages/patterns/src/components/pattern-overrides-controls.js +++ b/packages/patterns/src/components/pattern-overrides-controls.js @@ -85,7 +85,9 @@ function PatternOverridesControls( { attributes, name, setAttributes } ) { } // Avoid overwriting other (e.g. meta) bindings. - if ( isConnectedToOtherSources ) return null; + if ( isConnectedToOtherSources ) { + return null; + } const hasName = !! attributes.metadata?.name; const allowOverrides = diff --git a/packages/rich-text/src/component/use-anchor-ref.js b/packages/rich-text/src/component/use-anchor-ref.js index d1de79d04928c..023b42641fa29 100644 --- a/packages/rich-text/src/component/use-anchor-ref.js +++ b/packages/rich-text/src/component/use-anchor-ref.js @@ -40,7 +40,9 @@ export function useAnchorRef( { ref, value, settings = {} } ) { const activeFormat = name ? getActiveFormat( value, name ) : undefined; return useMemo( () => { - if ( ! ref.current ) return; + if ( ! ref.current ) { + return; + } const { ownerDocument: { defaultView }, } = ref.current; diff --git a/packages/rich-text/src/component/use-anchor.js b/packages/rich-text/src/component/use-anchor.js index cc7d0e2573ad6..412c31bf5b707 100644 --- a/packages/rich-text/src/component/use-anchor.js +++ b/packages/rich-text/src/component/use-anchor.js @@ -41,9 +41,15 @@ function getFormatElement( range, editableContentElement, tagName, className ) { element = element.parentElement; } - if ( ! element ) return; - if ( element === editableContentElement ) return; - if ( ! editableContentElement.contains( element ) ) return; + if ( ! element ) { + return; + } + if ( element === editableContentElement ) { + return; + } + if ( ! editableContentElement.contains( element ) ) { + return; + } const selector = tagName + ( className ? '.' + className : '' ); @@ -100,18 +106,26 @@ function createVirtualAnchorElement( range, editableContentElement ) { * @return {HTMLElement|VirtualAnchorElement|undefined} The anchor. */ function getAnchor( editableContentElement, tagName, className ) { - if ( ! editableContentElement ) return; + if ( ! editableContentElement ) { + return; + } const { ownerDocument } = editableContentElement; const { defaultView } = ownerDocument; const selection = defaultView.getSelection(); - if ( ! selection ) return; - if ( ! selection.rangeCount ) return; + if ( ! selection ) { + return; + } + if ( ! selection.rangeCount ) { + return; + } const range = selection.getRangeAt( 0 ); - if ( ! range || ! range.startContainer ) return; + if ( ! range || ! range.startContainer ) { + return; + } const formatElement = getFormatElement( range, @@ -120,7 +134,9 @@ function getAnchor( editableContentElement, tagName, className ) { className ); - if ( formatElement ) return formatElement; + if ( formatElement ) { + return formatElement; + } return createVirtualAnchorElement( range, editableContentElement ); } @@ -145,7 +161,9 @@ export function useAnchor( { editableContentElement, settings = {} } ) { const wasActive = usePrevious( isActive ); useLayoutEffect( () => { - if ( ! editableContentElement ) return; + if ( ! editableContentElement ) { + return; + } function callback() { setAnchor( diff --git a/packages/rich-text/src/component/use-default-style.js b/packages/rich-text/src/component/use-default-style.js index 43908ae4f10a8..a4c8449076e88 100644 --- a/packages/rich-text/src/component/use-default-style.js +++ b/packages/rich-text/src/component/use-default-style.js @@ -33,7 +33,9 @@ const minWidth = '1px'; export function useDefaultStyle() { return useCallback( ( element ) => { - if ( ! element ) return; + if ( ! element ) { + return; + } element.style.whiteSpace = whiteSpace; element.style.minWidth = minWidth; }, [] ); diff --git a/packages/rich-text/src/component/use-select-object.js b/packages/rich-text/src/component/use-select-object.js index e5db313494f48..fe5512f18d26d 100644 --- a/packages/rich-text/src/component/use-select-object.js +++ b/packages/rich-text/src/component/use-select-object.js @@ -22,7 +22,9 @@ export function useSelectObject() { // If it's already selected, do nothing and let default behavior // happen. This means it's "click-through". - if ( selection.containsNode( target ) ) return; + if ( selection.containsNode( target ) ) { + return; + } const range = ownerDocument.createRange(); // If the target is within a non editable element, select the non diff --git a/packages/rich-text/src/component/use-selection-change-compat.js b/packages/rich-text/src/component/use-selection-change-compat.js index d067d5ec70ff7..74dddc10722c5 100644 --- a/packages/rich-text/src/component/use-selection-change-compat.js +++ b/packages/rich-text/src/component/use-selection-change-compat.js @@ -43,7 +43,9 @@ export function useSelectionChangeCompat() { function onUp() { onCancel(); - if ( isRangeEqual( range, getRange() ) ) return; + if ( isRangeEqual( range, getRange() ) ) { + return; + } ownerDocument.dispatchEvent( new Event( 'selectionchange' ) ); } diff --git a/packages/rich-text/src/create.js b/packages/rich-text/src/create.js index 8ac79799b22ef..0b0a269509e7e 100644 --- a/packages/rich-text/src/create.js +++ b/packages/rich-text/src/create.js @@ -532,7 +532,9 @@ function createFromElement( { element, range, isEditableTree } ) { continue; } - if ( format ) delete format.formatType; + if ( format ) { + delete format.formatType; + } const value = createFromElement( { element: node, diff --git a/packages/rich-text/src/to-tree.js b/packages/rich-text/src/to-tree.js index c380570db561d..131174460a74b 100644 --- a/packages/rich-text/src/to-tree.js +++ b/packages/rich-text/src/to-tree.js @@ -223,7 +223,9 @@ export function toTree( { if ( character === OBJECT_REPLACEMENT_CHARACTER ) { const replacement = replacements[ i ]; - if ( ! replacement ) continue; + if ( ! replacement ) { + continue; + } const { type, attributes, innerHTML } = replacement; const formatType = getFormatType( type ); diff --git a/packages/scripts/config/jest-environment-puppeteer/global.js b/packages/scripts/config/jest-environment-puppeteer/global.js index 1be79ffd89c66..76cd7bb512699 100644 --- a/packages/scripts/config/jest-environment-puppeteer/global.js +++ b/packages/scripts/config/jest-environment-puppeteer/global.js @@ -45,7 +45,9 @@ async function setup( jestConfig = {} ) { // If we are in watch mode, - only setupServer() once. if ( jestConfig.watch || jestConfig.watchAll ) { - if ( didAlreadyRunInWatchMode ) return; + if ( didAlreadyRunInWatchMode ) { + return; + } didAlreadyRunInWatchMode = true; } diff --git a/packages/scripts/config/jest-github-actions-reporter/index.js b/packages/scripts/config/jest-github-actions-reporter/index.js index 9a8f292beb80c..8496373c38971 100644 --- a/packages/scripts/config/jest-github-actions-reporter/index.js +++ b/packages/scripts/config/jest-github-actions-reporter/index.js @@ -35,7 +35,9 @@ class GithubActionsReporter { } function getMessages( results ) { - if ( ! results ) return []; + if ( ! results ) { + return []; + } return results.reduce( flatMap( ( { testFilePath, testResults } ) => diff --git a/packages/url/src/get-path-and-query-string.js b/packages/url/src/get-path-and-query-string.js index 0256a809da659..f858846b07802 100644 --- a/packages/url/src/get-path-and-query-string.js +++ b/packages/url/src/get-path-and-query-string.js @@ -20,7 +20,11 @@ export function getPathAndQueryString( url ) { const path = getPath( url ); const queryString = getQueryString( url ); let value = '/'; - if ( path ) value += path; - if ( queryString ) value += `?${ queryString }`; + if ( path ) { + value += path; + } + if ( queryString ) { + value += `?${ queryString }`; + } return value; } diff --git a/test/e2e/specs/editor/blocks/quote.spec.js b/test/e2e/specs/editor/blocks/quote.spec.js index 6a83ed52df675..d5457ad10bbd0 100644 --- a/test/e2e/specs/editor/blocks/quote.spec.js +++ b/test/e2e/specs/editor/blocks/quote.spec.js @@ -344,7 +344,9 @@ test.describe( 'Quote', () => { await pageUtils.pressKeys( 'Shift+ArrowUp' ); let error; page.on( 'console', ( msg ) => { - if ( msg.type() === 'error' ) error = msg.text(); + if ( msg.type() === 'error' ) { + error = msg.text(); + } } ); await page.keyboard.press( 'Backspace' ); expect( error ).toBeUndefined(); diff --git a/test/e2e/specs/editor/plugins/plugins-api-error-boundary.spec.js b/test/e2e/specs/editor/plugins/plugins-api-error-boundary.spec.js index 25f528be8a008..99423a4c247db 100644 --- a/test/e2e/specs/editor/plugins/plugins-api-error-boundary.spec.js +++ b/test/e2e/specs/editor/plugins/plugins-api-error-boundary.spec.js @@ -22,8 +22,9 @@ test.describe( 'Plugins API Error Boundary', () => { } ) => { let hasError = false; page.on( 'console', ( msg ) => { - if ( msg.type() === 'error' && msg.text().includes( 'Whoops!' ) ) + if ( msg.type() === 'error' && msg.text().includes( 'Whoops!' ) ) { hasError = true; + } } ); await admin.createNewPost(); diff --git a/test/e2e/specs/editor/various/patterns.spec.js b/test/e2e/specs/editor/various/patterns.spec.js index ef00e19c3cace..fc1754330b3f5 100644 --- a/test/e2e/specs/editor/various/patterns.spec.js +++ b/test/e2e/specs/editor/various/patterns.spec.js @@ -499,7 +499,9 @@ test.describe( 'Synced pattern', () => { let hasError = false; page.on( 'console', ( msg ) => { - if ( msg.type() === 'error' ) hasError = true; + if ( msg.type() === 'error' ) { + hasError = true; + } } ); // Need to reload the page to make pattern available in the store. diff --git a/test/e2e/specs/interactivity/fixtures/interactivity-utils.ts b/test/e2e/specs/interactivity/fixtures/interactivity-utils.ts index 94bb383a142cc..fd850a6e39fae 100644 --- a/test/e2e/specs/interactivity/fixtures/interactivity-utils.ts +++ b/test/e2e/specs/interactivity/fixtures/interactivity-utils.ts @@ -46,7 +46,9 @@ export default class InteractivityUtils { ? `${ name } ${ JSON.stringify( attributes ) }` : name; - if ( ! alias ) alias = block; + if ( ! alias ) { + alias = block; + } const payload = { content: ``, diff --git a/test/performance/utils.js b/test/performance/utils.js index e14ff71436d73..72a851a4ffabc 100644 --- a/test/performance/utils.js +++ b/test/performance/utils.js @@ -4,19 +4,25 @@ import { existsSync, readFileSync, unlinkSync } from 'fs'; export function sum( array ) { - if ( ! array || ! array.length ) return undefined; + if ( ! array || ! array.length ) { + return undefined; + } return array.reduce( ( a, b ) => a + b, 0 ); } export function average( array ) { - if ( ! array || ! array.length ) return undefined; + if ( ! array || ! array.length ) { + return undefined; + } return sum( array ) / array.length; } export function median( array ) { - if ( ! array || ! array.length ) return undefined; + if ( ! array || ! array.length ) { + return undefined; + } const numbers = [ ...array ].sort( ( a, b ) => a - b ); const middleIndex = Math.floor( numbers.length / 2 ); @@ -28,13 +34,17 @@ export function median( array ) { } export function minimum( array ) { - if ( ! array || ! array.length ) return undefined; + if ( ! array || ! array.length ) { + return undefined; + } return Math.min( ...array ); } export function maximum( array ) { - if ( ! array || ! array.length ) return undefined; + if ( ! array || ! array.length ) { + return undefined; + } return Math.max( ...array ); }