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 _.stubTrue and _.stubFalse #41625

Merged
merged 1 commit into from
Jun 10, 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { omit, stubFalse, castArray } from 'lodash';
import { omit, castArray } from 'lodash';

/**
* Internal dependencies
Expand All @@ -11,6 +11,15 @@ import { validateBlock } from '../validation';
import { getBlockAttributes } from './get-block-attributes';
import { applyBuiltInValidationFixes } from './apply-built-in-validation-fixes';

/**
* Function that takes no arguments and always returns false.
*
* @return {boolean} Always returns false.
*/
function stubFalse() {
return false;
}

/**
* Given a block object, returns a new copy of the block with any applicable
* deprecated migrations applied, or the original block if it was both valid
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/api/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { Tokenizer } from 'simple-html-tokenizer';
import { identity, xor, fromPairs, isEqual, includes, stubTrue } from 'lodash';
import { identity, xor, fromPairs, isEqual, includes } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -418,7 +418,7 @@ export const isEqualAttributesOfName = {
// For each boolean attribute, mere presence of attribute in both is enough
// to assume equivalence.
...fromPairs(
BOOLEAN_ATTRIBUTES.map( ( attribute ) => [ attribute, stubTrue ] )
BOOLEAN_ATTRIBUTES.map( ( attribute ) => [ attribute, () => true ] )
),
};

Expand Down