diff --git a/.eslintrc.js b/.eslintrc.js index d5deabd83e0c52..13c7e260e9bd9b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -81,6 +81,7 @@ const restrictedImports = [ 'flowRight', 'forEach', 'fromPairs', + 'groupBy', 'has', 'identity', 'includes', diff --git a/bin/plugin/commands/changelog.js b/bin/plugin/commands/changelog.js index e6fb8c7054b16e..b8d37968781dc3 100644 --- a/bin/plugin/commands/changelog.js +++ b/bin/plugin/commands/changelog.js @@ -1,7 +1,6 @@ /** * External dependencies */ -const { groupBy } = require( 'lodash' ); const Octokit = require( '@octokit/rest' ); const { sprintf } = require( 'sprintf-js' ); const semver = require( 'semver' ); @@ -711,9 +710,19 @@ async function fetchAllPullRequests( octokit, settings ) { function getChangelog( pullRequests ) { let changelog = '## Changelog\n\n'; - const groupedPullRequests = groupBy( - skipCreatedByBots( pullRequests ), - getIssueType + const groupedPullRequests = skipCreatedByBots( pullRequests ).reduce( + ( + /** @type {Record} */ acc, + pr + ) => { + const issueType = getIssueType( pr ); + if ( ! acc[ issueType ] ) { + acc[ issueType ] = []; + } + acc[ issueType ].push( pr ); + return acc; + }, + {} ); const sortedGroups = Object.keys( groupedPullRequests ).sort( sortGroup ); @@ -732,7 +741,20 @@ function getChangelog( pullRequests ) { changelog += '### ' + group + '\n\n'; // Group PRs within this section into "Features". - const featureGroups = groupBy( groupPullRequests, getIssueFeature ); + const featureGroups = groupPullRequests.reduce( + ( + /** @type {Record} */ acc, + pr + ) => { + const issueFeature = getIssueFeature( pr ); + if ( ! acc[ issueFeature ] ) { + acc[ issueFeature ] = []; + } + acc[ issueFeature ].push( pr ); + return acc; + }, + {} + ); const featuredGroupNames = sortFeatureGroups( featureGroups ); diff --git a/packages/block-editor/src/components/inserter/block-types-tab.js b/packages/block-editor/src/components/inserter/block-types-tab.js index 1263b14707c995..60e1ff4beb6d54 100644 --- a/packages/block-editor/src/components/inserter/block-types-tab.js +++ b/packages/block-editor/src/components/inserter/block-types-tab.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { groupBy } from 'lodash'; - /** * WordPress dependencies */ @@ -59,7 +54,15 @@ export function BlockTypesTab( { itemList.filter( ( item ) => item.category && item.category !== 'reusable' ), - ( itemList ) => groupBy( itemList, 'category' ) + ( itemList ) => + itemList.reduce( ( acc, item ) => { + const { category } = item; + if ( ! acc[ category ] ) { + acc[ category ] = []; + } + acc[ category ].push( item ); + return acc; + }, {} ) )( items ); }, [ items ] ); diff --git a/packages/editor/src/components/entities-saved-states/index.js b/packages/editor/src/components/entities-saved-states/index.js index 364e6ae694797c..fda61faeeb7bc6 100644 --- a/packages/editor/src/components/entities-saved-states/index.js +++ b/packages/editor/src/components/entities-saved-states/index.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { groupBy } from 'lodash'; - /** * WordPress dependencies */ @@ -83,7 +78,14 @@ export default function EntitiesSavedStates( { close } ) { useDispatch( noticesStore ); // To group entities by type. - const partitionedSavables = groupBy( dirtyEntityRecords, 'name' ); + const partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => { + const { name } = record; + if ( ! acc[ name ] ) { + acc[ name ] = []; + } + acc[ name ].push( record ); + return acc; + }, {} ); // Sort entity groups. const {