-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lodash: Refactor some _.isEmpty()
instances
#47353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isEmpty } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -39,7 +34,7 @@ export default function ImageSizeControl( { | |
|
||
return ( | ||
<> | ||
{ ! isEmpty( imageSizeOptions ) && ( | ||
{ imageSizeOptions && imageSizeOptions.length > 0 && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<SelectControl | ||
__nextHasNoMarginBottom | ||
label={ __( 'Image size' ) } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isEmpty } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -135,7 +130,7 @@ function InserterSearchResults( { | |
); | ||
|
||
const hasItems = | ||
! isEmpty( filteredBlockTypes ) || ! isEmpty( filteredBlockPatterns ); | ||
filteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already used as arrays in this component, so checking the length is enough. |
||
|
||
const blocksUI = !! filteredBlockTypes.length && ( | ||
<InserterPanel | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isEmpty } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -211,5 +206,5 @@ export function isValuesDefined( values ) { | |
if ( values === undefined || values === null ) { | ||
return false; | ||
} | ||
return ! isEmpty( Object.values( values ).filter( ( value ) => !! value ) ); | ||
return Object.values( values ).filter( ( value ) => !! value ).length > 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isEmpty } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -41,7 +36,7 @@ export const settings = { | |
} | ||
|
||
if ( context === 'accessibility' ) { | ||
return isEmpty( content ) | ||
return ! content || content.length === 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
? sprintf( | ||
/* translators: accessibility text. %s: heading level. */ | ||
__( 'Level %s. Empty.' ), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isEmpty } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -35,7 +30,7 @@ export const settings = { | |
__experimentalLabel( attributes, { context } ) { | ||
if ( context === 'accessibility' ) { | ||
const { content } = attributes; | ||
return isEmpty( content ) ? __( 'Empty' ) : content; | ||
return ! content || content.length === 0 ? __( 'Empty' ) : content; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above for heading's |
||
} | ||
}, | ||
transforms, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fontFamilies
is being used as an array a few lines below already, so making sure it's not nullish and then checking for the array length is a safe bet.