From d35f8b0a6be8a87920f6b500015974fda792198d Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:36:07 +0300 Subject: [PATCH] Lodash: Refactor away from _.flatten() (#41733) --- .eslintrc.js | 1 + packages/edit-post/src/store/selectors.js | 4 ++-- packages/editor/src/components/page-attributes/parent.js | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b8326cf5d2521..c6510b20b2beb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -85,6 +85,7 @@ module.exports = { 'dropRight', 'each', 'findIndex', + 'flatten', 'isArray', 'isFinite', 'isFunction', diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js index 3a512ee08b1bf..74d42691114c9 100644 --- a/packages/edit-post/src/store/selectors.js +++ b/packages/edit-post/src/store/selectors.js @@ -2,7 +2,7 @@ * External dependencies */ import createSelector from 'rememo'; -import { includes, some, flatten, values } from 'lodash'; +import { includes, some, values } from 'lodash'; /** * WordPress dependencies @@ -410,7 +410,7 @@ export function getMetaBoxesPerLocation( state, location ) { */ export const getAllMetaBoxes = createSelector( ( state ) => { - return flatten( values( state.metaBoxes.locations ) ); + return values( state.metaBoxes.locations ).flat(); }, ( state ) => [ state.metaBoxes.locations ] ); diff --git a/packages/editor/src/components/page-attributes/parent.js b/packages/editor/src/components/page-attributes/parent.js index f81bb4ae3ff0f..9d298d8639371 100644 --- a/packages/editor/src/components/page-attributes/parent.js +++ b/packages/editor/src/components/page-attributes/parent.js @@ -7,7 +7,6 @@ import { debounce, repeat, find, - flatten, deburr, } from 'lodash'; @@ -111,7 +110,7 @@ export function PageAttributesParent() { return priorityA >= priorityB ? 1 : -1; } ); - return flatten( sortedNodes ); + return sortedNodes.flat(); }; let tree = pageItems.map( ( item ) => ( {