Skip to content
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 away from _.flowRight() #44188

Merged
merged 2 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = {
'flatMap',
'flatten',
'flattenDeep',
'flowRight',
'forEach',
'fromPairs',
'has',
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@babel/runtime": "^7.16.0",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/blocks": "file:../blocks",
"@wordpress/compose": "file:../compose",
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/element": "file:../element",
Expand Down
5 changes: 3 additions & 2 deletions packages/core-data/src/queried-data/reducer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* External dependencies
*/
import { map, flowRight, omit, filter, mapValues } from 'lodash';
import { map, omit, filter, mapValues } from 'lodash';

/**
* WordPress dependencies
*/
import { combineReducers } from '@wordpress/data';
import { compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down Expand Up @@ -172,7 +173,7 @@ export function itemIsComplete( state = {}, action ) {
*
* @return {Object} Next state.
*/
const receiveQueries = flowRight( [
const receiveQueries = compose( [
// Limit to matching action type so we don't attempt to replace action on
// an unhandled action.
ifMatchingAction( ( action ) => 'query' in action ),
Expand Down
5 changes: 3 additions & 2 deletions packages/core-data/src/reducer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/**
* External dependencies
*/
import { map, groupBy, flowRight, isEqual, get } from 'lodash';
import { map, groupBy, isEqual, get } from 'lodash';

/**
* WordPress dependencies
*/
import { compose } from '@wordpress/compose';
import { combineReducers } from '@wordpress/data';
import isShallowEqual from '@wordpress/is-shallow-equal';

Expand Down Expand Up @@ -197,7 +198,7 @@ export function themeGlobalStyleVariations( state = {}, action ) {
* @return {AnyFunction} Reducer.
*/
function entity( entityConfig ) {
return flowRight( [
return compose( [
// Limit to matching action type so we don't attempt to replace action on
// an unhandled action.
ifMatchingAction(
Expand Down
5 changes: 3 additions & 2 deletions packages/data/src/redux-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* External dependencies
*/
import { createStore, applyMiddleware } from 'redux';
import { flowRight, get, mapValues } from 'lodash';
import { get, mapValues } from 'lodash';
import combineReducers from 'turbo-combine-reducers';
import EquivalentKeyMap from 'equivalent-key-map';

/**
* WordPress dependencies
*/
import createReduxRoutineMiddleware from '@wordpress/redux-routine';
import { compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down Expand Up @@ -268,7 +269,7 @@ function instantiateReduxStore( key, options, registry, thunkArgs ) {
return createStore(
enhancedReducer,
{ root: initialState },
flowRight( enhancers )
compose( enhancers )
);
}

Expand Down