Skip to content

Commit

Permalink
Lodash: Refactor away from _.dropRight() (#41654)
Browse files Browse the repository at this point in the history
* Lodash: Refactor away from _.dropRight()

* Restrict import
  • Loading branch information
tyxla authored Jun 13, 2022
1 parent 2224d4f commit 2b026ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module.exports = {
importNames: [
'concat',
'differenceWith',
'dropRight',
'findIndex',
'isArray',
'isUndefined',
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { dropRight, get, times } from 'lodash';
import { get, times } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -199,9 +199,9 @@ const ColumnsEditContainerWrapper = withDispatch(
];
} else {
// The removed column will be the last of the inner blocks.
innerBlocks = dropRight(
innerBlocks,
previousColumns - newColumns
innerBlocks = innerBlocks.slice(
0,
-( previousColumns - newColumns )
);

if ( hasExplicitWidths ) {
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/columns/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { View, Dimensions } from 'react-native';
import { dropRight, times, map, compact, delay } from 'lodash';
import { times, map, compact, delay } from 'lodash';
/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -394,9 +394,9 @@ const ColumnsEditContainerWrapper = withDispatch(
];
} else {
// The removed column will be the last of the inner blocks.
innerBlocks = dropRight(
innerBlocks,
previousColumns - newColumns
innerBlocks = innerBlocks.slice(
0,
-( previousColumns - newColumns )
);

if ( hasExplicitWidths ) {
Expand Down

0 comments on commit 2b026ec

Please sign in to comment.