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

CHORE: Update @wordpress/scripts and @wordpress/jest-preset-default to latest #1045

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ module.exports = {
}
}
],
rules: {
"@wordpress/dependency-group": 'off'
}
};
4 changes: 2 additions & 2 deletions assets/src/blocks/event-attendees/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ export class EventAttendeesEditor extends Component {
* @param {boolean} showGravatar
*/
toggleShowGravatar = ( showGravatar ) => {
this.props.setAttributes( { showGravatar: showGravatar } );
this.props.setAttributes( { showGravatar } );
};

/**
* Sets whether to show block on archive pages in attributes.
* @param {boolean} displayOnArchives
*/
toggleDisplayOnArchives = ( displayOnArchives ) => {
this.props.setAttributes( { displayOnArchives: displayOnArchives } );
this.props.setAttributes( { displayOnArchives } );
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ function* createRelations(
) {
relationName = pluralModelName( relationName );
const singularRelationName = singularModelName( relationName );
const pluralRelationName = pluralModelName( relationName );

try {
assertArrayHasEntitiesForModel( relationEntities, singularRelationName );
Expand All @@ -98,6 +97,7 @@ function* createRelations(
return;
}
const relationIds = getIdsFromBaseEntityArray( relationEntities );
const pluralRelationName = pluralModelName( relationName );
yield dispatch(
REDUCER_KEY,
'receiveEntitiesAndResolve',
Expand Down
16 changes: 10 additions & 6 deletions assets/src/data/eventespresso/core/resolvers/relations.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export function* getRelatedEntities( entity, relationModelName ) {
}
const modelName = entity.modelName.toLowerCase();
const pluralRelationName = pluralModelName( relationModelName );
const singularRelationName = singularModelName( relationModelName );
const relationResourceProperty = pluralRelationName + 'Resource';
const relationEndpoint = entity[ relationResourceProperty ] ?
stripBaseRouteFromUrl(
Expand All @@ -73,6 +72,7 @@ export function* getRelatedEntities( entity, relationModelName ) {
);
return DEFAULT_EMPTY_ARRAY;
}

yield dispatch(
SCHEMA_REDUCER_KEY,
'receiveRelationEndpointForModelEntity',
Expand Down Expand Up @@ -104,6 +104,8 @@ export function* getRelatedEntities( entity, relationModelName ) {
return relationEntities;
}

const singularRelationName = singularModelName( relationModelName );

const factory = yield resolveSelect(
SCHEMA_REDUCER_KEY,
'getFactoryForModel',
Expand Down Expand Up @@ -208,18 +210,13 @@ export function* getRelatedEntitiesForIds(
return DEFAULT_EMPTY_ARRAY;
}
const relationType = relationSchema.relation_type;
const relationPrimaryKey = getPrimaryKey(
singularModelName( relationName )
);
const modelPrimaryKey = getPrimaryKey( singularModelName( modelName ) );
const singularRelationName = singularModelName( relationName );

const factory = yield resolveSelect(
SCHEMA_REDUCER_KEY,
'getFactoryForModel',
singularRelationName
);
let hasSetMap = ImmutableMap();
const response = yield fetch( {
path: getRelationRequestUrl(
modelName,
Expand All @@ -233,6 +230,13 @@ export function* getRelatedEntitiesForIds(
if ( ! response.length ) {
return DEFAULT_EMPTY_ARRAY;
}

const relationPrimaryKey = getPrimaryKey(
singularModelName( relationName )
);
const modelPrimaryKey = getPrimaryKey( singularModelName( modelName ) );
let hasSetMap = ImmutableMap();

if ( hasJoinTable ) {
while ( response.length > 0 ) {
const record = response.pop();
Expand Down
2 changes: 1 addition & 1 deletion assets/src/data/eventespresso/core/selectors/relations.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ export const getRelatedEntitiesForIds = createSelector(
* }
*/
const lookupRelationsQueuedForModel = ( state, modelName, type = 'add' ) => {
const forIndexLookup = pluralModelName( modelName );
const forAddLookup = singularModelName( modelName );
if ( state.dirty.relations.hasIn( [ type, forAddLookup ] ) ) {
return state.dirty.relations.getIn( [ type, forAddLookup ] ).toJS();
}
const forIndexLookup = pluralModelName( modelName );
if ( state.dirty.relations.hasIn( [ 'index', forIndexLookup ] ) ) {
let relations = Map();
state.dirty.relations.getIn( [ 'index', forIndexLookup ] ).forEach(
Expand Down
2 changes: 1 addition & 1 deletion assets/src/data/eventespresso/schema/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ export const getRelationPrimaryKeyString = createSelector(
) => {
modelName = singularModelName( modelName );
relationName = pluralModelName( relationName );
const singularRelationName = singularModelName( relationName );
const relationType = getRelationType( state, modelName, relationName );
if ( relationType === '' ) {
return '';
}
const singularRelationName = singularModelName( relationName );
const relationPrimaryKey = getPrimaryKey( singularRelationName );
return relationType === 'EE_Belongs_To_Relation' ?
relationPrimaryKey :
Expand Down
32 changes: 9 additions & 23 deletions assets/src/data/model/entity-factory/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export const assertValidSchemaFieldProperties = (
if ( isUndefined( schema[ fieldName ] ) ) {
throw new TypeError(
sprintf(
'The given "%s" fieldName does not have a defined schema ' +
'for the model "%s"',
'The given "%s" fieldName does not have a defined schema for the model "%s"',
fieldName,
modelName,
),
Expand All @@ -92,8 +91,7 @@ export const assertValidSchemaFieldProperties = (
if ( isUndefined( schema[ fieldName ].properties ) ) {
throw new InvalidSchema(
sprintf(
'The schema for the field %s on the model %s is of type ' +
'"object" but does not have a properties property.',
'The schema for the field %s on the model %s is of type "object" but does not have a properties property.',
fieldName,
modelName
)
Expand All @@ -102,9 +100,7 @@ export const assertValidSchemaFieldProperties = (
if ( isUndefined( schema[ fieldName ].properties.raw ) ) {
throw new InvalidSchema(
sprintf(
'The schema for the field %s on the model %s is of type ' +
'"object" but does not have a raw property in it\'s ' +
'"properties" property.',
'The schema for the field %s on the model %s is of type "object" but does not have a raw property in it\'s "properties" property.',
fieldName,
modelName
)
Expand All @@ -113,9 +109,7 @@ export const assertValidSchemaFieldProperties = (
if ( isUndefined( schema[ fieldName ].properties.raw.type ) ) {
throw new InvalidSchema(
sprintf(
'The schema for the field %s on the model %s is of type ' +
'"object" and has a properties.raw property, however there' +
'is no "type" defined for the raw property.',
'The schema for the field %s on the model %s is of type "object" and has a properties.raw property, however there is no "type" defined for the raw property.',
fieldName,
modelName
),
Expand Down Expand Up @@ -179,9 +173,7 @@ export const assertValidValueForPreparedField = (
if ( ! isValid ) {
throw new TypeError(
sprintf(
'The given "%1$s" field is not valid for the defined ' +
'schema. It\'s `raw` property Value (%2$s) is not ' +
'the correct expected type (%3$s).',
'The given "%1$s" field is not valid for the defined schema. It\'s `raw` property Value (%2$s) is not the correct expected type (%3$s).',
fieldName,
fieldValue,
schema[ fieldName ].properties.raw.type,
Expand All @@ -192,8 +184,7 @@ export const assertValidValueForPreparedField = (
if ( ! isValid ) {
throw new TypeError(
sprintf(
'The given "%1$s" field\'s Value (%2$s) is not valid for' +
' the defined schema type (%3$s).',
'The given "%1$s" field\'s Value (%2$s) is not valid for the defined schema type (%3$s).',
fieldName,
fieldValue,
schema[ fieldName ].type,
Expand Down Expand Up @@ -241,9 +232,7 @@ export const assertValidFieldAndValueAgainstSchema = (
if ( isUndefined( fieldValue[ validationType ] ) ) {
throw new TypeError(
sprintf(
'The given "%1$s" value is not valid for the defined ' +
'schema. It must be an object and it must have a ' +
'`%2$s` key.',
'The given "%1$s" value is not valid for the defined schema. It must be an object and it must have a `%2$s` key.',
fieldName,
validationType,
),
Expand All @@ -262,9 +251,7 @@ export const assertValidFieldAndValueAgainstSchema = (
if ( ! isValid ) {
throw new TypeError(
sprintf(
'The given "%1$s" value is not valid for the defined ' +
'schema. It\'s `%2$s` property value (%3$s) is not ' +
'the correct expected type (%4$s).',
'The given "%1$s" value is not valid for the defined schema. It\'s `%2$s` property value (%3$s) is not the correct expected type (%4$s).',
fieldName,
validationType,
fieldValue,
Expand All @@ -276,8 +263,7 @@ export const assertValidFieldAndValueAgainstSchema = (
if ( ! isValid ) {
throw new TypeError(
sprintf(
'The given "%1$s" field\'s value (%2$s) is not valid for' +
' the defined schema type (%3$s).',
'The given "%1$s" field\'s value (%2$s) is not valid for the defined schema type (%3$s).',
fieldName,
fieldValue,
schema[ fieldName ].type,
Expand Down
2 changes: 1 addition & 1 deletion assets/src/data/model/entity-factory/base-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const createEntityFactory = ( modelName, schema, fieldPrefixes = [] ) => {
* is for from any given factory.
* @type string
*/
modelName: modelName,
modelName,
/**
* This is the class definition for the Entity. Typically this is
* retrieved for the ability to do instanceof checks.
Expand Down
4 changes: 1 addition & 3 deletions assets/src/data/model/entity-factory/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ export const isShallowValidValueForField = (
if ( isEnum && ! isValid ) {
throw new TypeError(
sprintf(
'The given "%s" fieldName is not valid for the defined ' +
'schema. It must be a "%s" and it must be one of "%s". ' +
'The fieldValue given was "%s"',
'The given "%s" fieldName is not valid for the defined schema. It must be a "%s" and it must be one of "%s". The fieldValue given was "%s"',
fieldName,
schema[ fieldName ].enum.join(),
fieldValue
Expand Down
2 changes: 2 additions & 0 deletions assets/src/higher-order-components/test/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ describe( 'withMoney()', () => {
};

const getWrappedTestComponent = ( testProps, testMap = [] ) => {
// false positive
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
const Wrapped = getEnhancedComponent( testMap );
return <Wrapped { ...testProps } />;
};
Expand Down
2 changes: 1 addition & 1 deletion assets/src/vo/test/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe( 'Currency Value Object', () => {
( property ) => {
describe( property + ' property validation', () => {
it( 'throws TypeError for missing property', () => {
delete( testConfig[ property ] );
delete testConfig[ property ];
expect( getTestObject ).toThrow( TypeError );
} );
it( 'throws Type Error for invalid property', () => {
Expand Down
Loading