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 _.repeat() #42070

Merged
merged 2 commits into from
Jun 30, 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 @@ -110,6 +110,7 @@ module.exports = {
'partialRight',
'random',
'reject',
'repeat',
'reverse',
'size',
'stubFalse',
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Internal

- `TextHighlight`: Convert to TypeScript ([#41698](https://github.com/WordPress/gutenberg/pull/41698)).
- `TreeSelect`: Refactor away from `_.repeat()` ([#42070](https://github.com/WordPress/gutenberg/pull/42070/)).

## 19.14.0 (2022-06-29)

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { unescape as unescapeString, repeat, flatMap, compact } from 'lodash';
import { unescape as unescapeString, flatMap, compact } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -18,7 +18,7 @@ function getSelectOptions( tree: Tree[], level = 0 ): SelectOptions {
{
value: treeNode.id,
label:
repeat( '\u00A0', level * 3 ) + unescapeString( treeNode.name ),
'\u00A0'.repeat( level * 3 ) + unescapeString( treeNode.name ),
},
...getSelectOptions( treeNode.children || [], level + 1 ),
] );
Expand Down
3 changes: 1 addition & 2 deletions packages/editor/src/components/page-attributes/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
get,
unescape as unescapeString,
debounce,
repeat,
find,
deburr,
} from 'lodash';
Expand Down Expand Up @@ -98,7 +97,7 @@ export function PageAttributesParent() {
{
value: treeNode.id,
label:
repeat( '— ', level ) + unescapeString( treeNode.name ),
'— '.repeat( level ) + unescapeString( treeNode.name ),
rawName: treeNode.name,
},
...getOptionsFromTree( treeNode.children || [], level + 1 ),
Expand Down