Skip to content

Commit d26888e

Browse files
committed
Autofix eslint curly all violation
1 parent 7e16cf6 commit d26888e

File tree

152 files changed

+878
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+878
-307
lines changed

bin/api-docs/gen-theme-reference.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,13 @@ const formatType = ( prop ) => {
241241
const types = [];
242242

243243
propTypes.forEach( ( item ) => {
244-
if ( item.type ) types.push( item.type );
244+
if ( item.type ) {
245+
types.push( item.type );
246+
}
245247
// refComplete is always an object
246-
if ( item.$ref && item.$ref === '#/definitions/refComplete' )
248+
if ( item.$ref && item.$ref === '#/definitions/refComplete' ) {
247249
types.push( 'object' );
250+
}
248251
} );
249252

250253
type = [ ...new Set( types ) ].join( ', ' );

bin/plugin/commands/performance.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function sanitizeBranchName( branch ) {
6363
* @return {number|undefined} Median value or undefined if array empty.
6464
*/
6565
function median( array ) {
66-
if ( ! array || ! array.length ) return undefined;
66+
if ( ! array || ! array.length ) {
67+
return undefined;
68+
}
6769

6870
const numbers = [ ...array ].sort( ( a, b ) => a - b );
6971
const middleIndex = Math.floor( numbers.length / 2 );

packages/block-editor/src/components/alignment-control/ui.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ function AlignmentUI( {
4545
);
4646

4747
function setIcon() {
48-
if ( activeAlignment ) return activeAlignment.icon;
48+
if ( activeAlignment ) {
49+
return activeAlignment.icon;
50+
}
4951
return isRTL() ? alignRight : alignLeft;
5052
}
5153

packages/block-editor/src/components/block-mover/index.native.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export const BlockMover = ( {
9090
const option = blockPageMoverOptions.find(
9191
( el ) => el.value === value
9292
);
93-
if ( option && option.onSelect ) option.onSelect();
93+
if ( option && option.onSelect ) {
94+
option.onSelect();
95+
}
9496
};
9597

9698
const onLongPressMoveUp = useCallback(

packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ export function BlockSettingsDropdown( {
218218
* @param {KeyboardEvent} event
219219
*/
220220
onKeyDown( event ) {
221-
if ( event.defaultPrevented ) return;
221+
if ( event.defaultPrevented ) {
222+
return;
223+
}
222224

223225
if (
224226
isMatch( 'core/block-editor/remove', event ) &&

packages/block-editor/src/components/block-switcher/pattern-transformations-menu.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ function PatternTransformationsMenu( {
3434
} ) {
3535
const [ showTransforms, setShowTransforms ] = useState( false );
3636
const patterns = useTransformedPatterns( statePatterns, blocks );
37-
if ( ! patterns.length ) return null;
37+
if ( ! patterns.length ) {
38+
return null;
39+
}
3840

3941
return (
4042
<MenuGroup className="block-editor-block-switcher__pattern__transforms__menugroup">

packages/block-editor/src/components/block-switcher/use-transformed-patterns.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export const getPatternTransformedBlocks = (
6262
selectedBlock.name,
6363
consumedBlocks
6464
);
65-
if ( ! match ) continue;
65+
if ( ! match ) {
66+
continue;
67+
}
6668
isMatch = true;
6769
consumedBlocks.add( match.clientId );
6870
// We update (mutate) the matching pattern block.
@@ -71,7 +73,9 @@ export const getPatternTransformedBlocks = (
7173
break;
7274
}
7375
// Bail eary if a selected block has not been matched.
74-
if ( ! isMatch ) return;
76+
if ( ! isMatch ) {
77+
return;
78+
}
7579
}
7680
return _patternBlocks;
7781
};

packages/block-editor/src/components/block-switcher/utils.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@ export const getMatchingBlockByName = (
2222
) => {
2323
const { clientId, name, innerBlocks = [] } = block;
2424
// Check if block has been consumed already.
25-
if ( consumedBlocks.has( clientId ) ) return;
26-
if ( name === selectedBlockName ) return block;
25+
if ( consumedBlocks.has( clientId ) ) {
26+
return;
27+
}
28+
if ( name === selectedBlockName ) {
29+
return block;
30+
}
2731
// Try to find a matching block from InnerBlocks recursively.
2832
for ( const innerBlock of innerBlocks ) {
2933
const match = getMatchingBlockByName(
3034
innerBlock,
3135
selectedBlockName,
3236
consumedBlocks
3337
);
34-
if ( match ) return match;
38+
if ( match ) {
39+
return match;
40+
}
3541
}
3642
};
3743

@@ -47,11 +53,14 @@ export const getMatchingBlockByName = (
4753
*/
4854
export const getRetainedBlockAttributes = ( name, attributes ) => {
4955
const contentAttributes = getBlockAttributesNamesByRole( name, 'content' );
50-
if ( ! contentAttributes?.length ) return attributes;
56+
if ( ! contentAttributes?.length ) {
57+
return attributes;
58+
}
5159

5260
return contentAttributes.reduce( ( _accumulator, attribute ) => {
53-
if ( attributes[ attribute ] )
61+
if ( attributes[ attribute ] ) {
5462
_accumulator[ attribute ] = attributes[ attribute ];
63+
}
5564
return _accumulator;
5665
}, {} );
5766
};

packages/block-editor/src/components/block-tools/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ export default function BlockTools( {
8585
} = unlock( useDispatch( blockEditorStore ) );
8686

8787
function onKeyDown( event ) {
88-
if ( event.defaultPrevented ) return;
88+
if ( event.defaultPrevented ) {
89+
return;
90+
}
8991

9092
if ( isMatch( 'core/block-editor/move-up', event ) ) {
9193
const clientIds = getSelectedBlockClientIds();

packages/block-editor/src/components/block-variation-transforms/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
180180
};
181181

182182
// Skip rendering if there are no variations
183-
if ( ! variations?.length ) return null;
183+
if ( ! variations?.length ) {
184+
return null;
185+
}
184186

185187
const baseClass = 'block-editor-block-variation-transforms';
186188

packages/block-editor/src/components/floating-toolbar/index.native.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ const FloatingToolbar = ( {
4747
}, [ showFloatingToolbar ] );
4848

4949
useEffect( () => {
50-
if ( showFloatingToolbar )
50+
if ( showFloatingToolbar ) {
5151
setPreviousSelection( { clientId: selectedClientId, parentId } );
52+
}
5253
}, [ selectedClientId ] );
5354

5455
const translationRange =
@@ -115,7 +116,9 @@ export default compose( [
115116

116117
const selectedClientId = getSelectedBlockClientId();
117118

118-
if ( ! selectedClientId ) return;
119+
if ( ! selectedClientId ) {
120+
return;
121+
}
119122

120123
const rootBlockId = getBlockHierarchyRootClientId( selectedClientId );
121124

packages/block-editor/src/components/global-styles/color-panel.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,9 @@ export default function ColorPanel( {
587587
].filter( Boolean );
588588

589589
elements.forEach( ( { name, label, showPanel } ) => {
590-
if ( ! showPanel ) return;
590+
if ( ! showPanel ) {
591+
return;
592+
}
591593

592594
const elementBackgroundColor = decodeValue(
593595
inheritedValue?.elements?.[ name ]?.color?.background

packages/block-editor/src/components/inserter/menu.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ function InserterMenu(
271271
__nextHasNoMarginBottom
272272
className="block-editor-inserter__search"
273273
onChange={ ( value ) => {
274-
if ( hoveredItem ) setHoveredItem( null );
274+
if ( hoveredItem ) {
275+
setHoveredItem( null );
276+
}
275277
setFilterValue( value );
276278
} }
277279
value={ filterValue }

packages/block-editor/src/components/line-height-control/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const LineHeightControl = ( {
2828

2929
const adjustNextValue = ( nextValue, wasTypedOrPasted ) => {
3030
// Set the next value without modification if lineHeight has been defined.
31-
if ( isDefined ) return nextValue;
31+
if ( isDefined ) {
32+
return nextValue;
33+
}
3234

3335
/**
3436
* The following logic handles the initial spin up/down action
@@ -47,7 +49,9 @@ const LineHeightControl = ( {
4749
case '0': {
4850
// This means the user explicitly input '0', rather than using the
4951
// spin down action from an undefined value state.
50-
if ( wasTypedOrPasted ) return nextValue;
52+
if ( wasTypedOrPasted ) {
53+
return nextValue;
54+
}
5155
// Decrement by spin value.
5256
return BASE_DEFAULT_VALUE - spin;
5357
}

packages/block-editor/src/components/link-control/search-item.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ function SearchItemIcon( { isURL, suggestion } ) {
6363
function addLeadingSlash( url ) {
6464
const trimmedURL = url?.trim();
6565

66-
if ( ! trimmedURL?.length ) return url;
66+
if ( ! trimmedURL?.length ) {
67+
return url;
68+
}
6769

6870
return url?.replace( /^\/?/, '/' );
6971
}
7072

7173
function removeTrailingSlash( url ) {
7274
const trimmedURL = url?.trim();
7375

74-
if ( ! trimmedURL?.length ) return url;
76+
if ( ! trimmedURL?.length ) {
77+
return url;
78+
}
7579

7680
return url?.replace( /\/$/, '' );
7781
}
@@ -95,7 +99,9 @@ const defaultTo = ( d ) => ( v ) => {
9599
* @return {string} the processed url to display.
96100
*/
97101
function getURLForDisplay( url ) {
98-
if ( ! url ) return url;
102+
if ( ! url ) {
103+
return url;
104+
}
99105

100106
return pipe(
101107
safeDecodeURI,

packages/block-editor/src/components/list-view/utils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export function focusListItem( focusClientId, treeGridElement ) {
7474
const row = treeGridElement?.querySelector(
7575
`[role=row][data-block="${ focusClientId }"]`
7676
);
77-
if ( ! row ) return null;
77+
if ( ! row ) {
78+
return null;
79+
}
7880
// Focus the first focusable in the row, which is the ListViewBlockSelectButton.
7981
return focus.focusable.find( row )[ 0 ];
8082
};

packages/block-editor/src/components/navigable-toolbar/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ function useToolbarFocus( {
165165
}
166166
return () => {
167167
window.cancelAnimationFrame( raf );
168-
if ( ! onIndexChange || ! navigableToolbarRef ) return;
168+
if ( ! onIndexChange || ! navigableToolbarRef ) {
169+
return;
170+
}
169171
// When the toolbar element is unmounted and onIndexChange is passed, we
170172
// pass the focused toolbar item index so it can be hydrated later.
171173
const items = getAllFocusableToolbarItemsIn( navigableToolbarRef );

packages/block-editor/src/components/provider/use-block-sync.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ export default function useBlockSync( {
198198
// the subscription is triggering for a block (`clientId !== null`)
199199
// and its block name can't be found because it's not on the list.
200200
// (`getBlockName( clientId ) === null`).
201-
if ( clientId !== null && getBlockName( clientId ) === null )
201+
if ( clientId !== null && getBlockName( clientId ) === null ) {
202202
return;
203+
}
203204

204205
// When RESET_BLOCKS on parent blocks get called, the controlled blocks
205206
// can reset to uncontrolled, in these situations, it means we need to populate

packages/block-editor/src/components/rich-text/multiline.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,19 @@ function RichTextMultiline(
8484
const newValues = values.slice();
8585
let offset = 0;
8686
if ( forward ) {
87-
if ( ! newValues[ index + 1 ] ) return;
87+
if ( ! newValues[ index + 1 ] ) {
88+
return;
89+
}
8890
newValues.splice(
8991
index,
9092
2,
9193
newValues[ index ] + newValues[ index + 1 ]
9294
);
9395
offset = newValues[ index ].length - 1;
9496
} else {
95-
if ( ! newValues[ index - 1 ] ) return;
97+
if ( ! newValues[ index - 1 ] ) {
98+
return;
99+
}
96100
newValues.splice(
97101
index - 1,
98102
2,

packages/block-editor/src/components/rich-text/use-format-types.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const interactiveContentTags = new Set( [
2929
] );
3030

3131
function prefixSelectKeys( selected, prefix ) {
32-
if ( typeof selected !== 'object' ) return { [ prefix ]: selected };
32+
if ( typeof selected !== 'object' ) {
33+
return { [ prefix ]: selected };
34+
}
3335
return Object.fromEntries(
3436
Object.entries( selected ).map( ( [ key, value ] ) => [
3537
`${ prefix }.${ key }`,
@@ -39,7 +41,9 @@ function prefixSelectKeys( selected, prefix ) {
3941
}
4042

4143
function getPrefixedSelectKeys( selected, prefix ) {
42-
if ( selected[ prefix ] ) return selected[ prefix ];
44+
if ( selected[ prefix ] ) {
45+
return selected[ prefix ];
46+
}
4347
return Object.keys( selected )
4448
.filter( ( key ) => key.startsWith( prefix + '.' ) )
4549
.reduce( ( accumulator, key ) => {

packages/block-editor/src/components/use-block-display-information/index.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ function getPositionTypeLabel( attributes ) {
6868
export default function useBlockDisplayInformation( clientId ) {
6969
return useSelect(
7070
( select ) => {
71-
if ( ! clientId ) return null;
71+
if ( ! clientId ) {
72+
return null;
73+
}
7274
const { getBlockName, getBlockAttributes } =
7375
select( blockEditorStore );
7476
const { getBlockType, getActiveBlockVariation } =
7577
select( blocksStore );
7678
const blockName = getBlockName( clientId );
7779
const blockType = getBlockType( blockName );
78-
if ( ! blockType ) return null;
80+
if ( ! blockType ) {
81+
return null;
82+
}
7983
const attributes = getBlockAttributes( clientId );
8084
const match = getActiveBlockVariation( blockName, attributes );
8185
const isSynced =
@@ -95,7 +99,9 @@ export default function useBlockDisplayInformation( clientId ) {
9599
positionType: attributes?.style?.position?.type,
96100
name: attributes?.metadata?.name,
97101
};
98-
if ( ! match ) return blockTypeInfo;
102+
if ( ! match ) {
103+
return blockTypeInfo;
104+
}
99105

100106
return {
101107
isSynced,

packages/block-editor/src/components/use-on-block-drop/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ export default function useOnBlockDrop(
252252
initialPosition = 0,
253253
clientIdsToReplace = []
254254
) => {
255-
if ( ! Array.isArray( blocks ) ) blocks = [ blocks ];
255+
if ( ! Array.isArray( blocks ) ) {
256+
blocks = [ blocks ];
257+
}
256258

257259
const clientIds = getBlockOrder( targetRootClientId );
258260
const clientId = clientIds[ targetBlockIndex ];

packages/block-editor/src/components/writing-flow/use-drag-selection.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import { store as blockEditorStore } from '../../store';
1818
function setContentEditableWrapper( node, value ) {
1919
node.contentEditable = value;
2020
// Firefox doesn't automatically move focus.
21-
if ( value ) node.focus();
21+
if ( value ) {
22+
node.focus();
23+
}
2224
}
2325

2426
/**

packages/block-editor/src/components/writing-flow/use-tab-nav.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ export default function useTabNav() {
118118
// do it again here because after clearing block selection,
119119
// focus land on the writing flow container and pressing Tab
120120
// will no longer send focus through the focus capture element.
121-
if ( event.target === node ) setNavigationMode( true );
121+
if ( event.target === node ) {
122+
setNavigationMode( true );
123+
}
122124
return;
123125
}
124126

0 commit comments

Comments
 (0)