Update lint dependencies, fix lints, tweak some scripts and eslint configs to get everything passing
This commit is contained in:
parent
db874b35a2
commit
19e35b1a54
|
@ -238,7 +238,7 @@
|
|||
"packages": [
|
||||
"**"
|
||||
],
|
||||
"pinVersion": "14.7.0"
|
||||
"pinVersion": "20.3.0"
|
||||
},
|
||||
{
|
||||
"dependencies": [
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
"@woocommerce/eslint-plugin": "workspace:*",
|
||||
"@woocommerce/monorepo-utils": "workspace:*",
|
||||
"@wordpress/data": "wp-6.0",
|
||||
"@wordpress/eslint-plugin": "14.7.0",
|
||||
"@wordpress/eslint-plugin": "20.3.0",
|
||||
"@wordpress/prettier-config": "2.17.0",
|
||||
"babel-loader": "^8.3.0",
|
||||
"chalk": "^4.1.2",
|
||||
|
@ -53,7 +53,7 @@
|
|||
"moment": "^2.29.4",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"postcss-loader": "^4.3.0",
|
||||
"prettier": "npm:wp-prettier@^2.8.5",
|
||||
"prettier": "npm:wp-prettier@^3.0.3",
|
||||
"regenerator-runtime": "^0.13.11",
|
||||
"request": "^2.88.2",
|
||||
"rimraf": "5.0.5",
|
||||
|
|
|
@ -94,7 +94,7 @@ export abstract class BasePage {
|
|||
if ( checkbox ) {
|
||||
const checkboxStatus = await (
|
||||
await checkbox.getProperty( 'checked' )
|
||||
).jsonValue();
|
||||
).jsonValue();
|
||||
|
||||
if ( checkboxStatus !== true ) {
|
||||
await checkbox.click();
|
||||
|
@ -129,7 +129,7 @@ export abstract class BasePage {
|
|||
): Promise< void > {
|
||||
const checkboxStatus = await (
|
||||
await checkbox.getProperty( 'checked' )
|
||||
).jsonValue();
|
||||
).jsonValue();
|
||||
|
||||
if ( checkboxStatus !== checked ) {
|
||||
await checkbox.click();
|
||||
|
|
|
@ -62,7 +62,7 @@ export const testAdminAnalyticsOverview = () => {
|
|||
await analyticsPage.getEllipsisMenuItems(
|
||||
section.title
|
||||
)
|
||||
).map( ( item ) => item.title );
|
||||
).map( ( item ) => item.title );
|
||||
if ( index === 0 ) {
|
||||
expect( menuItems ).toContain( 'Move down' );
|
||||
expect( menuItems ).not.toContain( 'Move up' );
|
||||
|
|
|
@ -89,7 +89,7 @@ const getInputValue = async ( selector: string ): Promise< unknown > => {
|
|||
if ( field ) {
|
||||
const fieldValue = await (
|
||||
await field.getProperty( 'value' )
|
||||
).jsonValue();
|
||||
).jsonValue();
|
||||
|
||||
return fieldValue;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ const getAttribute = async (
|
|||
if ( field ) {
|
||||
const fieldValue = await (
|
||||
await field.getProperty( attribute )
|
||||
).jsonValue();
|
||||
).jsonValue();
|
||||
|
||||
return fieldValue;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ const { coupon, order } = require( '../../data' );
|
|||
*
|
||||
* @group api
|
||||
* @group coupons
|
||||
*
|
||||
*/
|
||||
describe( 'Coupons API tests', () => {
|
||||
let couponId;
|
||||
|
@ -90,9 +89,8 @@ describe( 'Coupons API tests', () => {
|
|||
const batchCreatePayload = {
|
||||
create: expectedCoupons,
|
||||
};
|
||||
const batchCreateResponse = await couponsApi.batch.coupons(
|
||||
batchCreatePayload
|
||||
);
|
||||
const batchCreateResponse =
|
||||
await couponsApi.batch.coupons( batchCreatePayload );
|
||||
expect( batchCreateResponse.status ).toEqual(
|
||||
couponsApi.batch.responseCode
|
||||
);
|
||||
|
@ -127,9 +125,8 @@ describe( 'Coupons API tests', () => {
|
|||
},
|
||||
],
|
||||
};
|
||||
const batchUpdateResponse = await couponsApi.batch.coupons(
|
||||
batchUpdatePayload
|
||||
);
|
||||
const batchUpdateResponse =
|
||||
await couponsApi.batch.coupons( batchUpdatePayload );
|
||||
|
||||
// Verify the response code and the number of coupons that were updated.
|
||||
const updatedCoupons = batchUpdateResponse.body.update;
|
||||
|
@ -153,9 +150,8 @@ describe( 'Coupons API tests', () => {
|
|||
const batchDeletePayload = {
|
||||
delete: couponIdsToDelete,
|
||||
};
|
||||
const batchDeleteResponse = await couponsApi.batch.coupons(
|
||||
batchDeletePayload
|
||||
);
|
||||
const batchDeleteResponse =
|
||||
await couponsApi.batch.coupons( batchDeletePayload );
|
||||
|
||||
// Verify that the response shows the 2 coupons.
|
||||
const deletedCouponIds = batchDeleteResponse.body.delete.map(
|
||||
|
@ -238,9 +234,8 @@ describe( 'Coupons API tests', () => {
|
|||
it( 'can limit result set to matching code', async () => {
|
||||
const matchingCoupon = allCoupons[ 1 ];
|
||||
const payload = { code: matchingCoupon.code };
|
||||
const { status, body } = await couponsApi.listAll.coupons(
|
||||
payload
|
||||
);
|
||||
const { status, body } =
|
||||
await couponsApi.listAll.coupons( payload );
|
||||
|
||||
expect( status ).toEqual( couponsApi.listAll.responseCode );
|
||||
expect( body ).toHaveLength( 1 );
|
||||
|
@ -253,9 +248,8 @@ describe( 'Coupons API tests', () => {
|
|||
page: 1,
|
||||
per_page: pageSize,
|
||||
};
|
||||
const { status, body } = await couponsApi.listAll.coupons(
|
||||
payload
|
||||
);
|
||||
const { status, body } =
|
||||
await couponsApi.listAll.coupons( payload );
|
||||
|
||||
expect( status ).toEqual( couponsApi.listAll.responseCode );
|
||||
expect( body ).toHaveLength( pageSize );
|
||||
|
@ -269,9 +263,8 @@ describe( 'Coupons API tests', () => {
|
|||
search: matchingString,
|
||||
};
|
||||
|
||||
const { status, body } = await couponsApi.listAll.coupons(
|
||||
payload
|
||||
);
|
||||
const { status, body } =
|
||||
await couponsApi.listAll.coupons( payload );
|
||||
|
||||
expect( status ).toEqual( couponsApi.listAll.responseCode );
|
||||
expect( body ).toHaveLength( 1 );
|
||||
|
@ -289,9 +282,8 @@ describe( 'Coupons API tests', () => {
|
|||
|
||||
beforeAll( async () => {
|
||||
// Create a coupon
|
||||
const createCouponResponse = await couponsApi.create.coupon(
|
||||
testCoupon
|
||||
);
|
||||
const createCouponResponse =
|
||||
await couponsApi.create.coupon( testCoupon );
|
||||
testCoupon.id = createCouponResponse.body.id;
|
||||
} );
|
||||
|
||||
|
@ -306,9 +298,8 @@ describe( 'Coupons API tests', () => {
|
|||
...order,
|
||||
coupon_lines: [ { code: testCoupon.code } ],
|
||||
};
|
||||
const { status, body } = await ordersApi.create.order(
|
||||
orderWithCoupon
|
||||
);
|
||||
const { status, body } =
|
||||
await ordersApi.create.order( orderWithCoupon );
|
||||
orderId = body.id;
|
||||
|
||||
expect( status ).toEqual( ordersApi.create.responseCode );
|
||||
|
|
|
@ -4,7 +4,6 @@ const { getRequest } = require( '../../utils/request' );
|
|||
* Tests to verify connection to the API.
|
||||
*
|
||||
* @group hello
|
||||
*
|
||||
*/
|
||||
describe( 'Test API connectivity', () => {
|
||||
it( 'can access a non-authenticated endpoint', async () => {
|
||||
|
|
|
@ -87,29 +87,25 @@ const createTaxRates = async () => {
|
|||
*/
|
||||
const createProducts = async () => {
|
||||
// Create a simple product
|
||||
const { body: createdSimpleProduct } = await productsApi.create.product(
|
||||
simpleProduct
|
||||
);
|
||||
const { body: createdSimpleProduct } =
|
||||
await productsApi.create.product( simpleProduct );
|
||||
simpleProduct.id = createdSimpleProduct.id;
|
||||
|
||||
// Create a variable product with 1 variation
|
||||
const { body: createdVariableProduct } = await productsApi.create.product(
|
||||
variableProduct
|
||||
);
|
||||
const { body: createdVariableProduct } =
|
||||
await productsApi.create.product( variableProduct );
|
||||
variableProduct.id = createdVariableProduct.id;
|
||||
await variationsApi.create.variation( variableProduct.id, variation );
|
||||
|
||||
// Create a grouped product using the simple product created earlier.
|
||||
groupedProduct.grouped_products = [ simpleProduct.id ];
|
||||
const { body: createdGroupedProduct } = await productsApi.create.product(
|
||||
groupedProduct
|
||||
);
|
||||
const { body: createdGroupedProduct } =
|
||||
await productsApi.create.product( groupedProduct );
|
||||
groupedProduct.id = createdGroupedProduct.id;
|
||||
|
||||
// Create an external product
|
||||
const { body: createdExternalProduct } = await productsApi.create.product(
|
||||
externalProduct
|
||||
);
|
||||
const { body: createdExternalProduct } =
|
||||
await productsApi.create.product( externalProduct );
|
||||
externalProduct.id = createdExternalProduct.id;
|
||||
};
|
||||
|
||||
|
@ -139,7 +135,6 @@ const expectedExternalProductTaxTotal = '0.00';
|
|||
*
|
||||
* @group api
|
||||
* @group orders
|
||||
*
|
||||
*/
|
||||
describe( 'Orders API test', () => {
|
||||
beforeAll( async () => {
|
||||
|
|
|
@ -49,7 +49,6 @@ const searchParams = [
|
|||
*
|
||||
* @group api
|
||||
* @group orders
|
||||
*
|
||||
*/
|
||||
describe( 'Order Search API tests', () => {
|
||||
beforeAll( async () => {
|
||||
|
|
|
@ -60,7 +60,6 @@ const simpleProduct = {
|
|||
*
|
||||
* @group api
|
||||
* @group orders
|
||||
*
|
||||
*/
|
||||
describe( 'Orders API tests: CRUD', () => {
|
||||
let orderId;
|
||||
|
@ -72,9 +71,8 @@ describe( 'Orders API tests: CRUD', () => {
|
|||
...order,
|
||||
status: null,
|
||||
};
|
||||
const { body, status } = await ordersApi.create.order(
|
||||
requestPayload
|
||||
);
|
||||
const { body, status } =
|
||||
await ordersApi.create.order( requestPayload );
|
||||
// Save the order ID. It will be used by the retrieve, update, and delete tests.
|
||||
orderId = body.id;
|
||||
|
||||
|
@ -91,9 +89,8 @@ describe( 'Orders API tests: CRUD', () => {
|
|||
...order,
|
||||
status: expectedStatus,
|
||||
};
|
||||
const { status, body } = await ordersApi.create.order(
|
||||
requestPayload
|
||||
);
|
||||
const { status, body } =
|
||||
await ordersApi.create.order( requestPayload );
|
||||
|
||||
expect( status ).toEqual( ordersApi.create.responseCode );
|
||||
expect( typeof body.id ).toEqual( 'number' );
|
||||
|
|
|
@ -40,7 +40,6 @@ const updatedCustomerShipping = {
|
|||
*
|
||||
* @group api
|
||||
* @group orders
|
||||
*
|
||||
*/
|
||||
describe( 'Orders API tests', () => {
|
||||
let orderId, sampleData;
|
||||
|
|
|
@ -15,15 +15,13 @@ const { productsApi } = require( '../../endpoints/products' );
|
|||
*
|
||||
* @group api
|
||||
* @group products
|
||||
*
|
||||
*/
|
||||
describe( 'Products API tests: CRUD', () => {
|
||||
let productId;
|
||||
|
||||
it( 'can add a simple product', async () => {
|
||||
const { status, body } = await productsApi.create.product(
|
||||
simpleProduct
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.create.product( simpleProduct );
|
||||
productId = body.id;
|
||||
|
||||
expect( status ).toEqual( productsApi.create.responseCode );
|
||||
|
@ -37,9 +35,8 @@ describe( 'Products API tests: CRUD', () => {
|
|||
} );
|
||||
|
||||
it( 'can add a virtual product', async () => {
|
||||
const { status, body } = await productsApi.create.product(
|
||||
virtualProduct
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.create.product( virtualProduct );
|
||||
const virtualProductId = body.id;
|
||||
|
||||
expect( status ).toEqual( productsApi.create.responseCode );
|
||||
|
@ -54,9 +51,8 @@ describe( 'Products API tests: CRUD', () => {
|
|||
} );
|
||||
|
||||
it( 'can add a variable product', async () => {
|
||||
const { status, body } = await productsApi.create.product(
|
||||
variableProduct
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.create.product( variableProduct );
|
||||
const variableProductId = body.id;
|
||||
|
||||
expect( status ).toEqual( productsApi.create.responseCode );
|
||||
|
@ -69,9 +65,8 @@ describe( 'Products API tests: CRUD', () => {
|
|||
} );
|
||||
|
||||
it( 'can view a single product', async () => {
|
||||
const { status, body } = await productsApi.retrieve.product(
|
||||
productId
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.retrieve.product( productId );
|
||||
|
||||
expect( status ).toEqual( productsApi.retrieve.responseCode );
|
||||
expect( body.id ).toEqual( productId );
|
||||
|
@ -114,9 +109,8 @@ describe( 'Products API tests: CRUD', () => {
|
|||
it( 'can batch create products', async () => {
|
||||
// Send request to batch create products
|
||||
const batchCreatePayload = batch( 'create', expectedProducts );
|
||||
const { status, body } = await productsApi.batch.products(
|
||||
batchCreatePayload
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.batch.products( batchCreatePayload );
|
||||
const actualBatchCreatedProducts = body.create;
|
||||
|
||||
expect( status ).toEqual( productsApi.batch.responseCode );
|
||||
|
@ -143,9 +137,8 @@ describe( 'Products API tests: CRUD', () => {
|
|||
expectedProducts[ i ].regular_price = newRegularPrice;
|
||||
}
|
||||
const batchUpdatePayload = batch( 'update', expectedProducts );
|
||||
const { status, body } = await productsApi.batch.products(
|
||||
batchUpdatePayload
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.batch.products( batchUpdatePayload );
|
||||
const actualUpdatedProducts = body.update;
|
||||
|
||||
expect( status ).toEqual( productsApi.batch.responseCode );
|
||||
|
@ -167,9 +160,8 @@ describe( 'Products API tests: CRUD', () => {
|
|||
// Send request to batch delete the products created earlier
|
||||
const idsToDelete = expectedProducts.map( ( { id } ) => id );
|
||||
const batchDeletePayload = batch( 'delete', idsToDelete );
|
||||
const { status, body } = await productsApi.batch.products(
|
||||
batchDeletePayload
|
||||
);
|
||||
const { status, body } =
|
||||
await productsApi.batch.products( batchDeletePayload );
|
||||
const actualBatchDeletedProducts = body.delete;
|
||||
|
||||
expect( status ).toEqual( productsApi.batch.responseCode );
|
||||
|
|
|
@ -8,7 +8,6 @@ const { refund } = require( '../../data' );
|
|||
*
|
||||
* @group api
|
||||
* @group refunds
|
||||
*
|
||||
*/
|
||||
describe( 'Refunds API tests', () => {
|
||||
let expectedRefund;
|
||||
|
@ -21,9 +20,8 @@ describe( 'Refunds API tests', () => {
|
|||
name: 'Simple Product for Refunds API tests',
|
||||
regular_price: '100',
|
||||
};
|
||||
const createProductResponse = await productsApi.create.product(
|
||||
product
|
||||
);
|
||||
const createProductResponse =
|
||||
await productsApi.create.product( product );
|
||||
productId = createProductResponse.body.id;
|
||||
|
||||
// Create an order with a product line item, and save its Order ID
|
||||
|
|
|
@ -20,7 +20,6 @@ const shippingMethods = [
|
|||
*
|
||||
* @group api
|
||||
* @group shipping-methods
|
||||
*
|
||||
*/
|
||||
describe( 'Shipping methods API tests', () => {
|
||||
it.each( shippingMethods )(
|
||||
|
|
|
@ -11,7 +11,6 @@ const shippingZone = getShippingZoneExample();
|
|||
*
|
||||
* @group api
|
||||
* @group shipping-zones
|
||||
*
|
||||
*/
|
||||
describe( 'Shipping zones API tests', () => {
|
||||
it( 'cannot delete the default shipping zone "Locations not covered by your other zones"', async () => {
|
||||
|
@ -54,9 +53,8 @@ describe( 'Shipping zones API tests', () => {
|
|||
} );
|
||||
|
||||
it( 'can create a shipping zone', async () => {
|
||||
const { status, body } = await shippingZonesApi.create.shippingZone(
|
||||
shippingZone
|
||||
);
|
||||
const { status, body } =
|
||||
await shippingZonesApi.create.shippingZone( shippingZone );
|
||||
|
||||
expect( status ).toEqual( shippingZonesApi.create.responseCode );
|
||||
expect( typeof body.id ).toEqual( 'number' );
|
||||
|
@ -79,9 +77,8 @@ describe( 'Shipping zones API tests', () => {
|
|||
const param = {
|
||||
_fields: 'id',
|
||||
};
|
||||
const { status, body } = await shippingZonesApi.listAll.shippingZones(
|
||||
param
|
||||
);
|
||||
const { status, body } =
|
||||
await shippingZonesApi.listAll.shippingZones( param );
|
||||
|
||||
expect( body ).toHaveLength( 2 ); // the test shipping zone, and the default 'Locations not covered by your other zones'
|
||||
expect( status ).toEqual( shippingZonesApi.listAll.responseCode );
|
||||
|
|
|
@ -24,7 +24,7 @@ export interface ModelRepositoryParams<
|
|||
// @ts-ignore
|
||||
ListParams = never,
|
||||
// @ts-ignore
|
||||
UpdateParams extends keyof T = never
|
||||
UpdateParams extends keyof T = never,
|
||||
> {
|
||||
// Since TypeScript's type system is structural we need to add something to this type to prevent
|
||||
// it from matching with everything else (since it is an empty interface).
|
||||
|
@ -35,28 +35,28 @@ export interface ModelRepositoryParams<
|
|||
* These helpers will extract information about a model from its repository params to be used in the repository.
|
||||
*/
|
||||
export type ModelClass< T extends ModelRepositoryParams > = [ T ] extends [
|
||||
ModelRepositoryParams< infer X >
|
||||
ModelRepositoryParams< infer X >,
|
||||
]
|
||||
? X
|
||||
: never;
|
||||
export type ParentID< T extends ModelRepositoryParams > = [ T ] extends [
|
||||
ModelRepositoryParams< any, infer X >
|
||||
ModelRepositoryParams< any, infer X >,
|
||||
]
|
||||
? X
|
||||
: never;
|
||||
export type HasParent< T extends ModelRepositoryParams, P, C > = [
|
||||
ParentID< T >
|
||||
ParentID< T >,
|
||||
] extends [ never ]
|
||||
? C
|
||||
: P;
|
||||
type ListParams< T extends ModelRepositoryParams > = [ T ] extends [
|
||||
ModelRepositoryParams< any, any, infer X >
|
||||
ModelRepositoryParams< any, any, infer X >,
|
||||
]
|
||||
? X
|
||||
: never;
|
||||
type PickUpdateParams< T, K extends keyof T > = { [ P in K ]?: T[ P ] };
|
||||
type UpdateParams< T extends ModelRepositoryParams > = [ T ] extends [
|
||||
ModelRepositoryParams< infer C, any, any, infer X >
|
||||
ModelRepositoryParams< infer C, any, any, infer X >,
|
||||
]
|
||||
? [ X ] extends [ keyof C ]
|
||||
? PickUpdateParams< C, X >
|
||||
|
|
|
@ -48,7 +48,7 @@ export function createMetaDataTransformer(): ModelTransformer< MetaData > {
|
|||
* @return {string} The URL to make the request to.
|
||||
*/
|
||||
type BuildURLFn< T extends 'list' | 'general' = 'general' > = [ T ] extends [
|
||||
'list'
|
||||
'list',
|
||||
]
|
||||
? () => string
|
||||
: ( id: ModelID ) => string;
|
||||
|
@ -64,7 +64,7 @@ type BuildURLFn< T extends 'list' | 'general' = 'general' > = [ T ] extends [
|
|||
*/
|
||||
type BuildURLWithParentFn<
|
||||
P extends ModelRepositoryParams,
|
||||
T extends 'list' | 'general' = 'general'
|
||||
T extends 'list' | 'general' = 'general',
|
||||
> = [ T ] extends [ 'list' ]
|
||||
? ( parent: ParentID< P > ) => string
|
||||
: ( parent: ParentID< P >, id: ModelID ) => string;
|
||||
|
|
|
@ -19,7 +19,9 @@ export const useLayoutTemplate = ( layoutTemplateId: string | null ) => {
|
|||
const [ isEntityRegistered, setIsEntityRegistered ] = useState( false );
|
||||
|
||||
useEffect( () => {
|
||||
if ( ! layoutTemplateId ) return;
|
||||
if ( ! layoutTemplateId ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const layoutTemplateEntity = select( 'core' ).getEntityConfig(
|
||||
'root',
|
||||
|
|
|
@ -37,7 +37,7 @@ function defaultUseEvaluationContext( context: Record< string, unknown > ) {
|
|||
|
||||
function getEdit<
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
T extends Record< string, object > = Record< string, object >
|
||||
T extends Record< string, object > = Record< string, object >,
|
||||
>(
|
||||
edit: ComponentType< BlockEditProps< T > >,
|
||||
useEvaluationContext: UseEvaluationContext
|
||||
|
@ -91,7 +91,7 @@ function getEdit<
|
|||
|
||||
function augmentAttributes<
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
T extends Record< string, any > = Record< string, any >
|
||||
T extends Record< string, any > = Record< string, any >,
|
||||
>( attributes: T ) {
|
||||
// Note: If you modify this function, also update the server-side
|
||||
// Automattic\WooCommerce\Admin\Features\ProductBlockEditor\BlockRegistry::augment_attributes() function.
|
||||
|
@ -130,7 +130,7 @@ function augmentAttributes<
|
|||
*/
|
||||
export function registerWooBlockType<
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
T extends Record< string, any > = Record< string, any >
|
||||
T extends Record< string, any > = Record< string, any >,
|
||||
>(
|
||||
block: BlockRepresentation< T >,
|
||||
useEvaluationContext?: UseEvaluationContext
|
||||
|
|
|
@ -33,7 +33,6 @@ export const getColor = ( orderedKeys, colorScheme ) => ( key ) => {
|
|||
* ];
|
||||
* return colorScales[ idx ] || false;
|
||||
* });
|
||||
*
|
||||
*/
|
||||
const color = applyFilters(
|
||||
'woocommerce_admin_chart_item_color',
|
||||
|
|
|
@ -262,8 +262,9 @@ export const DateTimePickerControl = forwardRef(
|
|||
|
||||
const maybeForceTime = useCallback(
|
||||
( momentDate: Moment ) => {
|
||||
if ( ! isDateOnlyPicker || ! momentDate.isValid() )
|
||||
if ( ! isDateOnlyPicker || ! momentDate.isValid() ) {
|
||||
return momentDate;
|
||||
}
|
||||
|
||||
// We want to set to the start/end of the local time, so
|
||||
// we need to put our Moment instance into "local" mode
|
||||
|
|
|
@ -25,19 +25,22 @@ export default function useAsyncFilter< T >( {
|
|||
const handleInputChange = useCallback(
|
||||
function handleInputChangeCallback( value?: string ) {
|
||||
if ( typeof filter === 'function' ) {
|
||||
if ( typeof onFilterStart === 'function' )
|
||||
if ( typeof onFilterStart === 'function' ) {
|
||||
onFilterStart( value );
|
||||
}
|
||||
|
||||
setIsFetching( true );
|
||||
|
||||
filter( value )
|
||||
.then( ( filteredItems ) => {
|
||||
if ( typeof onFilterEnd === 'function' )
|
||||
if ( typeof onFilterEnd === 'function' ) {
|
||||
onFilterEnd( filteredItems, value );
|
||||
}
|
||||
} )
|
||||
.catch( ( error: Error ) => {
|
||||
if ( typeof onFilterError === 'function' )
|
||||
if ( typeof onFilterError === 'function' ) {
|
||||
onFilterError( error, value );
|
||||
}
|
||||
} )
|
||||
.finally( () => {
|
||||
setIsFetching( false );
|
||||
|
|
|
@ -74,7 +74,9 @@ export const SelectTreeMenu = ( {
|
|||
}, [ isOpen, scrollIntoViewOnOpen ] );
|
||||
|
||||
const shouldItemBeExpanded = ( item: LinkedTree ): boolean => {
|
||||
if ( ! props.createValue || ! item.children?.length ) return false;
|
||||
if ( ! props.createValue || ! item.children?.length ) {
|
||||
return false;
|
||||
}
|
||||
return item.children.some( ( child ) => {
|
||||
if (
|
||||
new RegExp(
|
||||
|
|
|
@ -445,7 +445,9 @@ export const SelectTree = function SelectTree( {
|
|||
props.createValue || ''
|
||||
) }
|
||||
onChange={ ( value ) => {
|
||||
if ( onInputChange ) onInputChange( value );
|
||||
if ( onInputChange ) {
|
||||
onInputChange( value );
|
||||
}
|
||||
const item = items.find(
|
||||
( i ) => i.label === escapeHTML( value )
|
||||
);
|
||||
|
|
|
@ -58,11 +58,15 @@ function getNextFocusableElement(
|
|||
code: 'ArrowDown' | 'ArrowUp'
|
||||
): HTMLLabelElement | null {
|
||||
const headingsNodeList = getAllHeadings( currentHeading );
|
||||
if ( ! headingsNodeList ) return null;
|
||||
if ( ! headingsNodeList ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let currentHeadingIndex = 0;
|
||||
for ( const heading of headingsNodeList.values() ) {
|
||||
if ( heading === currentHeading ) break;
|
||||
if ( heading === currentHeading ) {
|
||||
break;
|
||||
}
|
||||
currentHeadingIndex++;
|
||||
}
|
||||
if (
|
||||
|
@ -84,7 +88,9 @@ function getFirstFocusableElement(
|
|||
currentHeading: HTMLDivElement
|
||||
): HTMLLabelElement | null {
|
||||
const headingsNodeList = getAllHeadings( currentHeading );
|
||||
if ( ! headingsNodeList ) return null;
|
||||
if ( ! headingsNodeList ) {
|
||||
return null;
|
||||
}
|
||||
return headingsNodeList
|
||||
.item( 0 )
|
||||
.querySelector< HTMLLabelElement >(
|
||||
|
@ -96,7 +102,9 @@ function getLastFocusableElement(
|
|||
currentHeading: HTMLDivElement
|
||||
): HTMLLabelElement | null {
|
||||
const headingsNodeList = getAllHeadings( currentHeading );
|
||||
if ( ! headingsNodeList ) return null;
|
||||
if ( ! headingsNodeList ) {
|
||||
return null;
|
||||
}
|
||||
return headingsNodeList
|
||||
.item( headingsNodeList.length - 1 )
|
||||
.querySelector< HTMLLabelElement >(
|
||||
|
|
|
@ -65,7 +65,9 @@ function hasSelectedSibblingChildren(
|
|||
) {
|
||||
return children.some( ( child ) => {
|
||||
const isChildSelected = child.data.value in selectedItems;
|
||||
if ( ! isChildSelected ) return false;
|
||||
if ( ! isChildSelected ) {
|
||||
return false;
|
||||
}
|
||||
return ! values.some(
|
||||
( childValue ) => childValue.value === child.data.value
|
||||
);
|
||||
|
@ -134,7 +136,9 @@ export function useSelection( {
|
|||
}
|
||||
|
||||
function onSelectChildren( value: Item | Item[] ) {
|
||||
if ( typeof onSelect !== 'function' ) return;
|
||||
if ( typeof onSelect !== 'function' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( multiple && ! shouldNotRecursivelySelect ) {
|
||||
value = [ item.data, ...( value as Item[] ) ];
|
||||
|
@ -144,7 +148,9 @@ export function useSelection( {
|
|||
}
|
||||
|
||||
function onRemoveChildren( value: Item | Item[] ) {
|
||||
if ( typeof onRemove !== 'function' ) return;
|
||||
if ( typeof onRemove !== 'function' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
multiple &&
|
||||
|
|
|
@ -11,7 +11,9 @@ const shouldItemBeExpanded = (
|
|||
item: LinkedTree,
|
||||
createValue: string | undefined
|
||||
): boolean => {
|
||||
if ( ! createValue || ! item.children?.length ) return false;
|
||||
if ( ! createValue || ! item.children?.length ) {
|
||||
return false;
|
||||
}
|
||||
return item.children.some( ( child ) => {
|
||||
if ( new RegExp( createValue || '', 'ig' ).test( child.data.label ) ) {
|
||||
return true;
|
||||
|
|
|
@ -39,7 +39,9 @@ export const SimpleTree: React.FC = () => {
|
|||
};
|
||||
|
||||
function shouldItemBeExpanded( item: LinkedTree, filter: string ) {
|
||||
if ( ! filter || ! item.children?.length ) return false;
|
||||
if ( ! filter || ! item.children?.length ) {
|
||||
return false;
|
||||
}
|
||||
return item.children.some( ( child ) => {
|
||||
if ( new RegExp( filter, 'ig' ).test( child.data.label ) ) {
|
||||
return true;
|
||||
|
@ -212,8 +214,12 @@ function getFirstMatchingItem(
|
|||
text: string,
|
||||
memo: Record< string, string >
|
||||
) {
|
||||
if ( ! text ) return false;
|
||||
if ( memo[ text ] === item.data.value ) return true;
|
||||
if ( ! text ) {
|
||||
return false;
|
||||
}
|
||||
if ( memo[ text ] === item.data.value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const matcher = new RegExp( text, 'ig' );
|
||||
if ( matcher.test( item.data.label ) ) {
|
||||
|
|
|
@ -411,7 +411,7 @@ function FormComponent< Values extends Record< string, any > >(
|
|||
|
||||
const Form = forwardRef( FormComponent ) as <
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
Values extends Record< string, any >
|
||||
Values extends Record< string, any >,
|
||||
>(
|
||||
props: PropsWithChildren< FormProps< Values > > & {
|
||||
ref?: React.ForwardedRef< FormRef< Values > >;
|
||||
|
|
|
@ -145,7 +145,9 @@ const PhoneNumberInput: React.FC< Props > = ( {
|
|||
initialSelectedItem: countryKey,
|
||||
itemToString: ( item ) => countries[ item || '' ].name,
|
||||
onSelectedItemChange: ( { selectedItem } ) => {
|
||||
if ( selectedItem ) handleSelect( selectedItem );
|
||||
if ( selectedItem ) {
|
||||
handleSelect( selectedItem );
|
||||
}
|
||||
},
|
||||
stateReducer: ( state, { changes } ) => {
|
||||
if ( state.isOpen === true && changes.isOpen === false ) {
|
||||
|
|
|
@ -50,7 +50,9 @@ export const guessCountryKey = (
|
|||
// Match each digit against countryCodes until a match is found
|
||||
for ( let i = number.length; i > 0; i-- ) {
|
||||
const match = countryCodes[ number.substring( 0, i ) ];
|
||||
if ( match ) return match[ 0 ];
|
||||
if ( match ) {
|
||||
return match[ 0 ];
|
||||
}
|
||||
}
|
||||
return 'US';
|
||||
};
|
||||
|
@ -100,7 +102,9 @@ const pushOrAdd = (
|
|||
value: string
|
||||
) => {
|
||||
if ( acc[ key ] ) {
|
||||
if ( ! acc[ key ].includes( value ) ) acc[ key ].push( value );
|
||||
if ( ! acc[ key ].includes( value ) ) {
|
||||
acc[ key ].push( value );
|
||||
}
|
||||
} else {
|
||||
acc[ key ] = [ value ];
|
||||
}
|
||||
|
@ -117,17 +121,24 @@ export const parseData = ( data: DataType ) => ( {
|
|||
} ) ),
|
||||
countryCodes: Object.values( data )
|
||||
.sort( ( a, b ) => ( a.priority > b.priority ? 1 : -1 ) )
|
||||
.reduce( ( acc, { code, alpha2, start } ) => {
|
||||
pushOrAdd( acc, code, alpha2 );
|
||||
if ( start ) {
|
||||
for ( const str of start ) {
|
||||
for ( let i = 1; i <= str.length; i++ ) {
|
||||
pushOrAdd( acc, code + str.substring( 0, i ), alpha2 );
|
||||
.reduce(
|
||||
( acc, { code, alpha2, start } ) => {
|
||||
pushOrAdd( acc, code, alpha2 );
|
||||
if ( start ) {
|
||||
for ( const str of start ) {
|
||||
for ( let i = 1; i <= str.length; i++ ) {
|
||||
pushOrAdd(
|
||||
acc,
|
||||
code + str.substring( 0, i ),
|
||||
alpha2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, {} as Record< string, string[] > ),
|
||||
return acc;
|
||||
},
|
||||
{} as Record< string, string[] >
|
||||
),
|
||||
} );
|
||||
|
||||
export type Country = ReturnType< typeof parseData >[ 'countries' ][ 0 ];
|
||||
|
|
|
@ -49,7 +49,7 @@ export type AutoCompleter = {
|
|||
key: string;
|
||||
label: JSX.Element;
|
||||
value: unknown;
|
||||
}
|
||||
},
|
||||
];
|
||||
/* A function to add regex expression to the filter the results, passed the search query. */
|
||||
getSearchExpression?: ( query: string ) => string;
|
||||
|
|
|
@ -27,7 +27,8 @@ const TableCardExample = () => {
|
|||
query: {
|
||||
[ param ]: value,
|
||||
},
|
||||
} ) }
|
||||
} )
|
||||
}
|
||||
query={ query }
|
||||
rowsPerPage={ 7 }
|
||||
totalRows={ 10 }
|
||||
|
@ -75,7 +76,8 @@ const TableCardWithActionsExample = () => {
|
|||
query: {
|
||||
[ param ]: value,
|
||||
},
|
||||
} ) }
|
||||
} )
|
||||
}
|
||||
query={ query }
|
||||
rowsPerPage={ 7 }
|
||||
totalRows={ 10 }
|
||||
|
|
|
@ -63,7 +63,9 @@ const Control = forwardRef(
|
|||
*/
|
||||
const handleKeydown = ( event ) => {
|
||||
if ( BACKSPACE === event.key ) {
|
||||
if ( value ) return;
|
||||
if ( value ) {
|
||||
return;
|
||||
}
|
||||
onTagsChange( tags.slice( 0, -1 ) );
|
||||
event.preventDefault();
|
||||
}
|
||||
|
|
|
@ -181,7 +181,9 @@ const TreeSelectControl = ( {
|
|||
const highlightOptionLabel = ( optionLabel, matchPosition ) => {
|
||||
const matchLength = matchPosition + filter.length;
|
||||
|
||||
if ( ! isSearching ) return optionLabel;
|
||||
if ( ! isSearching ) {
|
||||
return optionLabel;
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
|
@ -373,7 +375,9 @@ const TreeSelectControl = ( {
|
|||
* @param {Event} event The key down event
|
||||
*/
|
||||
const onKeyDown = ( event ) => {
|
||||
if ( disabled ) return;
|
||||
if ( disabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ESCAPE === event.key ) {
|
||||
setTreeVisible( false );
|
||||
|
|
|
@ -57,8 +57,12 @@ const Options = ( {
|
|||
const isRoot = option.value === ROOT_VALUE;
|
||||
const { hasChildren, checked, partialChecked, expanded } = option;
|
||||
|
||||
if ( ! option?.value ) return null;
|
||||
if ( ! isRoot && ! option?.isVisible ) return null;
|
||||
if ( ! option?.value ) {
|
||||
return null;
|
||||
}
|
||||
if ( ! isRoot && ! option?.isVisible ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -106,7 +106,7 @@ describe( 'CustomerEffortScore', () => {
|
|||
unknown,
|
||||
{
|
||||
actions: [ { onClick: () => void } ];
|
||||
}
|
||||
},
|
||||
]
|
||||
) => {
|
||||
// We're only interested in the 3rd argument.
|
||||
|
|
|
@ -170,11 +170,12 @@ export const createSelectors = ( {
|
|||
const sanitizedArgs = maybeReplaceIdQuery( args, namespace );
|
||||
const actionName = getGenericActionName( action, resourceName );
|
||||
const requestId = getRequestIdentifier( actionName, ...sanitizedArgs );
|
||||
if ( action )
|
||||
if ( action ) {
|
||||
return (
|
||||
state.requesting.hasOwnProperty( requestId ) &&
|
||||
! state.requesting[ requestId ]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const isRequesting = (
|
||||
|
|
|
@ -50,7 +50,7 @@ export type CrudActions<
|
|||
ResourceName,
|
||||
ItemType,
|
||||
MutableProperties,
|
||||
RequiredFields extends keyof MutableProperties | undefined = undefined
|
||||
RequiredFields extends keyof MutableProperties | undefined = undefined,
|
||||
> = MapActions<
|
||||
{
|
||||
create: (
|
||||
|
@ -79,7 +79,7 @@ export type CrudSelectors<
|
|||
PluralResourceName,
|
||||
ItemType,
|
||||
ItemQueryType,
|
||||
MutableProperties
|
||||
MutableProperties,
|
||||
> = MapSelectors<
|
||||
{
|
||||
'': WPDataSelector< typeof getItem >;
|
||||
|
|
|
@ -16,12 +16,18 @@ export const debounce = < T extends ( ...args: any[] ) => any >(
|
|||
|
||||
const debounced = ( ( ...args: Parameters< T > ) => {
|
||||
latestArgs = args;
|
||||
if ( timeout ) clearTimeout( timeout );
|
||||
if ( timeout ) {
|
||||
clearTimeout( timeout );
|
||||
}
|
||||
timeout = setTimeout( () => {
|
||||
timeout = null;
|
||||
if ( ! immediate && latestArgs ) func( ...latestArgs );
|
||||
if ( ! immediate && latestArgs ) {
|
||||
func( ...latestArgs );
|
||||
}
|
||||
}, wait );
|
||||
if ( immediate && ! timeout ) func( ...args );
|
||||
if ( immediate && ! timeout ) {
|
||||
func( ...args );
|
||||
}
|
||||
} ) as DebouncedFunction< T >;
|
||||
|
||||
debounced.flush = () => {
|
||||
|
|
|
@ -36,7 +36,10 @@ const resolveSelect =
|
|||
controls && controls.resolveSelect ? controls.resolveSelect : select;
|
||||
|
||||
class PluginError extends Error {
|
||||
constructor( message: string, public data: unknown ) {
|
||||
constructor(
|
||||
message: string,
|
||||
public data: unknown
|
||||
) {
|
||||
super( message );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ export type PartialProduct = Partial< Product > & Pick< Product, 'id' >;
|
|||
|
||||
export type ProductQuery<
|
||||
Status = ProductStatus,
|
||||
Type = ProductType
|
||||
Type = ProductType,
|
||||
> = BaseQueryParams< keyof Product > & {
|
||||
orderby?:
|
||||
| 'date'
|
||||
|
|
|
@ -42,7 +42,8 @@ export type WoocommerceMeta = {
|
|||
};
|
||||
|
||||
export type WCUser<
|
||||
T extends keyof schema.Schema.BaseUser< 'view' > = schema.Schema.ViewKeys.User
|
||||
T extends
|
||||
keyof schema.Schema.BaseUser< 'view' > = schema.Schema.ViewKeys.User,
|
||||
> = Pick<
|
||||
schema.Schema.BaseUser< 'view' >,
|
||||
schema.Schema.ViewKeys.User | T
|
||||
|
|
|
@ -144,7 +144,7 @@ export const useUserPreferences = () => {
|
|||
} );
|
||||
|
||||
const updateUserPreferences = <
|
||||
T extends Record< string, unknown > = UserPreferences
|
||||
T extends Record< string, unknown > = UserPreferences,
|
||||
>(
|
||||
userPrefs: UserPreferences | T
|
||||
) => {
|
||||
|
|
|
@ -364,7 +364,7 @@ const getDateParamsFromQueryMemoized = memoize<
|
|||
string | undefined,
|
||||
string | undefined,
|
||||
string | undefined,
|
||||
string
|
||||
string,
|
||||
]
|
||||
) => DateParams
|
||||
>(
|
||||
|
@ -468,7 +468,7 @@ const getCurrentDatesMemoized = memoize<
|
|||
moment.Moment,
|
||||
moment.Moment,
|
||||
moment.Moment,
|
||||
moment.Moment
|
||||
moment.Moment,
|
||||
]
|
||||
) => {
|
||||
primary: DataPickerOptions;
|
||||
|
|
|
@ -81,7 +81,9 @@ describe( 'toMoment', () => {
|
|||
|
||||
it( 'should handle isoFormat dates', () => {
|
||||
const myMoment = toMoment( 'YYYY', '2018-04-15' );
|
||||
if ( myMoment === null ) fail( 'myMoment should not be null' );
|
||||
if ( myMoment === null ) {
|
||||
fail( 'myMoment should not be null' );
|
||||
}
|
||||
|
||||
expect( moment.isMoment( myMoment ) ).toBe( true );
|
||||
expect( myMoment.isValid() ).toBe( true );
|
||||
|
@ -89,7 +91,9 @@ describe( 'toMoment', () => {
|
|||
|
||||
it( 'should handle local formats', () => {
|
||||
const longDate = toMoment( 'MMMM D, YYYY', 'April 15, 2018' );
|
||||
if ( longDate === null ) fail( 'longDate should not be null' );
|
||||
if ( longDate === null ) {
|
||||
fail( 'longDate should not be null' );
|
||||
}
|
||||
|
||||
expect( moment.isMoment( longDate ) ).toBe( true );
|
||||
expect( longDate.isValid() ).toBe( true );
|
||||
|
@ -98,7 +102,9 @@ describe( 'toMoment', () => {
|
|||
expect( longDate.year() ).toBe( 2018 );
|
||||
|
||||
const shortDate = toMoment( 'DD/MM/YYYY', '15/04/2018' );
|
||||
if ( shortDate === null ) fail( 'shortDate should not be null' );
|
||||
if ( shortDate === null ) {
|
||||
fail( 'shortDate should not be null' );
|
||||
}
|
||||
|
||||
expect( moment.isMoment( shortDate ) ).toBe( true );
|
||||
expect( shortDate.isValid() ).toBe( true );
|
||||
|
|
|
@ -147,9 +147,8 @@ const runEditOrderTest = () => {
|
|||
it( 'can add downloadable product permissions to order with product', async () => {
|
||||
// Create new downloadable product
|
||||
const newProductName = 'TDP 002';
|
||||
const newProductId = await createSimpleDownloadableProduct(
|
||||
newProductName
|
||||
);
|
||||
const newProductId =
|
||||
await createSimpleDownloadableProduct( newProductName );
|
||||
|
||||
// Open order we created
|
||||
await merchant.goToOrder( orderId );
|
||||
|
|
|
@ -224,9 +224,8 @@ const runCreateOrderTest = () => {
|
|||
'#wc-backbone-modal-dialog + .select2-container .select2-search__field',
|
||||
name
|
||||
);
|
||||
const firstResult = await page.waitForSelector(
|
||||
'li[data-selected]'
|
||||
);
|
||||
const firstResult =
|
||||
await page.waitForSelector( 'li[data-selected]' );
|
||||
await firstResult.click();
|
||||
await expect( page ).toMatchElement(
|
||||
'.wc-backbone-modal-content tr:nth-last-child(2) .wc-product-search option',
|
||||
|
|
|
@ -80,8 +80,12 @@ const runPageLoadTest = () => {
|
|||
)
|
||||
);
|
||||
|
||||
if ( resType === 'script' ) hasChunks.js = true;
|
||||
if ( resType === 'stylesheet' ) hasChunks.css = true;
|
||||
if ( resType === 'script' ) {
|
||||
hasChunks.js = true;
|
||||
}
|
||||
if ( resType === 'stylesheet' ) {
|
||||
hasChunks.css = true;
|
||||
}
|
||||
}
|
||||
} );
|
||||
await Promise.all( [
|
||||
|
|
|
@ -315,7 +315,7 @@ const runAddVariableProductTest = () => {
|
|||
);
|
||||
const isChecked = await (
|
||||
await chkbox.getProperty( 'checked' )
|
||||
).jsonValue();
|
||||
).jsonValue();
|
||||
expect( isChecked ).toEqual( false );
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ const runAddVariableProductTest = () => {
|
|||
);
|
||||
const isChecked = await (
|
||||
await chkbox.getProperty( 'checked' )
|
||||
).jsonValue();
|
||||
).jsonValue();
|
||||
expect( isChecked ).toEqual( true );
|
||||
}
|
||||
} );
|
||||
|
|
|
@ -31,6 +31,7 @@ module.exports = {
|
|||
camelcase: 'off',
|
||||
'no-use-before-define': 'off',
|
||||
'jsdoc/require-param': 'off',
|
||||
'@typescript-eslint/method-signature-style': 'off',
|
||||
// Making use of typescript no-shadow instead, fixes issues with enum.
|
||||
'no-shadow': 'off',
|
||||
'@wordpress/no-unsafe-wp-apis': 'warn',
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
"@wordpress/eslint-plugin": "20.3.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-testing-library": "^5.11.1",
|
||||
"prettier": "npm:wp-prettier@^2.8.5"
|
||||
"prettier": "npm:wp-prettier@^3.0.3"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
|
|
@ -12,7 +12,7 @@ import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|||
import { CSSTransition } from 'react-transition-group';
|
||||
|
||||
export type VerticalCSSTransitionProps<
|
||||
Ref extends HTMLElement | undefined = undefined
|
||||
Ref extends HTMLElement | undefined = undefined,
|
||||
> = CSSTransitionProps< Ref > & {
|
||||
defaultStyle?: React.CSSProperties;
|
||||
};
|
||||
|
|
|
@ -11,10 +11,13 @@ import { info } from './log';
|
|||
|
||||
const { writeFile } = promises;
|
||||
function getUniqueItems( arr: string[] ) {
|
||||
const uniqueObject = arr.reduce( ( unique, item ) => {
|
||||
unique[ item ] = true;
|
||||
return unique;
|
||||
}, {} as Record< string, boolean > );
|
||||
const uniqueObject = arr.reduce(
|
||||
( unique, item ) => {
|
||||
unique[ item ] = true;
|
||||
return unique;
|
||||
},
|
||||
{} as Record< string, boolean >
|
||||
);
|
||||
|
||||
return Object.keys( uniqueObject );
|
||||
}
|
||||
|
@ -35,10 +38,13 @@ const updateConfig = async ( { modules }: { modules: string[] } ) => {
|
|||
const cwd = join( process.cwd() );
|
||||
const config = getPluginConfig();
|
||||
|
||||
const uniqueModules = modules.reduce( ( unique, module ) => {
|
||||
unique[ module ] = true;
|
||||
return unique;
|
||||
}, {} as Record< string, boolean > );
|
||||
const uniqueModules = modules.reduce(
|
||||
( unique, module ) => {
|
||||
unique[ module ] = true;
|
||||
return unique;
|
||||
},
|
||||
{} as Record< string, boolean >
|
||||
);
|
||||
|
||||
config.modules = Object.keys( uniqueModules );
|
||||
|
||||
|
|
|
@ -126,10 +126,9 @@ function buildPackage( packagePath ) {
|
|||
|
||||
let packageName;
|
||||
try {
|
||||
packageName = require( path.resolve(
|
||||
PACKAGE_DIR,
|
||||
'package.json'
|
||||
) ).name;
|
||||
packageName = require(
|
||||
path.resolve( PACKAGE_DIR, 'package.json' )
|
||||
).name;
|
||||
} catch ( e ) {
|
||||
packageName = PACKAGE_DIR.split( path.sep ).pop();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
"devDependencies": {
|
||||
"@babel/core": "7.12.9",
|
||||
"@woocommerce/eslint-plugin": "workspace:*",
|
||||
"prettier": "npm:wp-prettier@^3.0.3",
|
||||
"chalk": "^4.1.2",
|
||||
"eslint": "^8.55.0",
|
||||
"glob": "^10.3.10",
|
||||
|
|
|
@ -40,7 +40,6 @@ const DEFAULT_NOTICES: [] = [];
|
|||
* announced to screen readers. Defaults to
|
||||
* `true`.
|
||||
* @property {WPNoticeAction[]} actions User actions to present with notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,9 @@ export function TabBlockEdit( {
|
|||
const [ canRenderChildren, setCanRenderChildren ] = useState( false );
|
||||
|
||||
useEffect( () => {
|
||||
if ( ! context.selectedTab ) return;
|
||||
if ( ! context.selectedTab ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isSelectedInContext = context.selectedTab === id;
|
||||
|
||||
|
|
|
@ -58,7 +58,9 @@ export function Edit( {
|
|||
} = useValidation< Product >(
|
||||
property,
|
||||
async function validator() {
|
||||
if ( ! inputRef.current ) return;
|
||||
if ( ! inputRef.current ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const input = inputRef.current;
|
||||
|
||||
|
@ -141,7 +143,9 @@ export function Edit( {
|
|||
);
|
||||
|
||||
function getSuffix() {
|
||||
if ( ! suffix || ! value || ! inputRef.current ) return;
|
||||
if ( ! suffix || ! value || ! inputRef.current ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isValidUrl =
|
||||
inputRef.current.type === 'url' &&
|
||||
|
|
|
@ -50,7 +50,9 @@ export const EditDownloadsModal: React.FC< EditDownloadsModalProps > = ( {
|
|||
};
|
||||
|
||||
const isImage = ( filename = '' ) => {
|
||||
if ( ! filename ) return;
|
||||
if ( ! filename ) {
|
||||
return;
|
||||
}
|
||||
const imageExtensions = [ 'jpg', 'jpeg', 'png', 'gif', 'webp' ];
|
||||
const fileExtension = (
|
||||
filename.split( '.' ).pop() || ''
|
||||
|
|
|
@ -104,7 +104,9 @@ export function DownloadBlockEdit( {
|
|||
}
|
||||
|
||||
function handleFileUpload( files: MediaItem | MediaItem[] ) {
|
||||
if ( ! Array.isArray( files ) ) return;
|
||||
if ( ! Array.isArray( files ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newFiles = files.filter(
|
||||
( file ) =>
|
||||
|
|
|
@ -133,7 +133,9 @@ export function ProductDetailsSectionDescriptionBlockEdit( {
|
|||
[ productId ]
|
||||
);
|
||||
|
||||
if ( ! rootClientId ) return;
|
||||
if ( ! rootClientId ) {
|
||||
return;
|
||||
}
|
||||
|
||||
function menuItemClickHandler(
|
||||
productTemplate: ProductTemplate,
|
||||
|
@ -203,7 +205,9 @@ export function ProductDetailsSectionDescriptionBlockEdit( {
|
|||
}
|
||||
|
||||
function resolveIcon( iconId?: string | null, alt?: string ) {
|
||||
if ( ! iconId ) return undefined;
|
||||
if ( ! iconId ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { Icon } = icons;
|
||||
let icon: JSX.Element;
|
||||
|
@ -211,7 +215,9 @@ export function ProductDetailsSectionDescriptionBlockEdit( {
|
|||
if ( /^https?:\/\//.test( iconId ) ) {
|
||||
icon = <img src={ iconId } alt={ alt } />;
|
||||
} else {
|
||||
if ( ! ( iconId in icons || iconId in wooIcons ) ) return undefined;
|
||||
if ( ! ( iconId in icons || iconId in wooIcons ) ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
icon = icons[ iconId as never ] || wooIcons[ iconId as never ];
|
||||
}
|
||||
|
@ -257,7 +263,9 @@ export function ProductDetailsSectionDescriptionBlockEdit( {
|
|||
|
||||
async function handleModalChangeClick() {
|
||||
try {
|
||||
if ( isSaving ) return;
|
||||
if ( isSaving ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { id: productTemplateId, productData } =
|
||||
unsupportedProductTemplate as ProductTemplate;
|
||||
|
@ -475,7 +483,9 @@ export function ProductDetailsSectionDescriptionBlockEdit( {
|
|||
variant="secondary"
|
||||
aria-disabled={ isSaving }
|
||||
onClick={ () => {
|
||||
if ( isSaving ) return;
|
||||
if ( isSaving ) {
|
||||
return;
|
||||
}
|
||||
setUnsupportedProductTemplate( undefined );
|
||||
} }
|
||||
>
|
||||
|
|
|
@ -57,7 +57,9 @@ export function ProductListBlockEdit( {
|
|||
|
||||
useEffect(
|
||||
function loadGroupedProducts() {
|
||||
if ( preventFetch ) return;
|
||||
if ( preventFetch ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( groupedProductIds.length ) {
|
||||
setIsLoading( false );
|
||||
|
|
|
@ -224,8 +224,7 @@ export function AddNewShippingClassModal( {
|
|||
...current,
|
||||
[ name ]: value === '' ? undefined : value,
|
||||
};
|
||||
},
|
||||
{} )
|
||||
}, {} )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,9 @@ export const AttributeControl: React.FC< AttributeControlProps > = ( {
|
|||
);
|
||||
|
||||
function renderEmptyState() {
|
||||
if ( value.length ) return null;
|
||||
if ( value.length ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( renderCustomEmptyState ) {
|
||||
return renderCustomEmptyState( {
|
||||
|
@ -224,7 +226,9 @@ export const AttributeControl: React.FC< AttributeControlProps > = ( {
|
|||
}
|
||||
|
||||
function renderSectionActions() {
|
||||
if ( renderCustomEmptyState && value.length === 0 ) return null;
|
||||
if ( renderCustomEmptyState && value.length === 0 ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SectionActions>
|
||||
|
|
|
@ -118,10 +118,11 @@ export const EditAttributeModal: React.FC< EditAttributeModalProps > = ( {
|
|||
currentAttributeTermsCount + addedTermsCount || 1;
|
||||
|
||||
const remainedTermsCount =
|
||||
attribute.terms?.filter( ( currentTerm ) =>
|
||||
editableAttribute?.terms?.some(
|
||||
( editedTerm ) => currentTerm.id === editedTerm.id
|
||||
)
|
||||
attribute.terms?.filter(
|
||||
( currentTerm ) =>
|
||||
editableAttribute?.terms?.some(
|
||||
( editedTerm ) => currentTerm.id === editedTerm.id
|
||||
)
|
||||
)?.length ?? 0;
|
||||
|
||||
return {
|
||||
|
|
|
@ -175,7 +175,7 @@ describe( 'AttributeControl', () => {
|
|||
} );
|
||||
(
|
||||
await screen.findAllByLabelText( 'Remove attribute' )
|
||||
)[ 0 ].click();
|
||||
)[ 0 ].click();
|
||||
expect( globalThis.confirm ).toHaveBeenCalled();
|
||||
} );
|
||||
|
||||
|
@ -194,7 +194,7 @@ describe( 'AttributeControl', () => {
|
|||
|
||||
(
|
||||
await screen.findAllByLabelText( 'Remove attribute' )
|
||||
)[ 0 ].click();
|
||||
)[ 0 ].click();
|
||||
|
||||
expect( globalThis.confirm ).toHaveBeenCalled();
|
||||
expect( onChange ).toHaveBeenCalledWith( [ attributeList[ 1 ] ] );
|
||||
|
@ -213,7 +213,7 @@ describe( 'AttributeControl', () => {
|
|||
} );
|
||||
(
|
||||
await screen.findAllByLabelText( 'Remove attribute' )
|
||||
)[ 0 ].click();
|
||||
)[ 0 ].click();
|
||||
expect( globalThis.confirm ).toHaveBeenCalled();
|
||||
expect( onChange ).not.toHaveBeenCalled();
|
||||
} );
|
||||
|
@ -242,7 +242,7 @@ describe( 'AttributeControl', () => {
|
|||
|
||||
(
|
||||
await screen.findAllByLabelText( 'Remove attribute' )
|
||||
)[ 0 ].click();
|
||||
)[ 0 ].click();
|
||||
|
||||
expect( onChange ).toHaveBeenCalledWith( [
|
||||
{ ...attributeList[ 1 ], position: 0 },
|
||||
|
|
|
@ -144,7 +144,9 @@ export function usePreview( {
|
|||
target: '_blank',
|
||||
...props,
|
||||
ref( element: HTMLAnchorElement ) {
|
||||
if ( typeof props.ref === 'function' ) props.ref( element );
|
||||
if ( typeof props.ref === 'function' ) {
|
||||
props.ref( element );
|
||||
}
|
||||
anchorRef.current = element;
|
||||
},
|
||||
'aria-disabled': ariaDisabled,
|
||||
|
|
|
@ -110,8 +110,9 @@ export const NumberControl: React.FC< NumberProps > = forwardRef(
|
|||
|
||||
function incrementValue() {
|
||||
const newValue = parseFloat( value || '0' ) + increment;
|
||||
if ( newValue >= min && newValue <= max )
|
||||
if ( newValue >= min && newValue <= max ) {
|
||||
onChange( String( newValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
useEffect( () => {
|
||||
|
|
|
@ -26,7 +26,9 @@ export function PostPublishSection( { postType }: PostPublishSectionProps ) {
|
|||
|
||||
const productURL = getProductURL( isScheduled );
|
||||
|
||||
if ( ! productURL ) return null;
|
||||
if ( ! productURL ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const CopyButton = ( { text, onCopy, children }: CopyButtonProps ) => {
|
||||
const ref = useCopyToClipboard(
|
||||
|
|
|
@ -64,13 +64,13 @@ export function useVariations( { productId }: UseVariationsProps ) {
|
|||
setIsLoading( true );
|
||||
setGetVariationsError( undefined );
|
||||
|
||||
const data = await getProductVariations< ProductVariation[] >(
|
||||
requestParams
|
||||
);
|
||||
const data =
|
||||
await getProductVariations< ProductVariation[] >(
|
||||
requestParams
|
||||
);
|
||||
|
||||
const total = await getProductVariationsTotalCount< number >(
|
||||
requestParams
|
||||
);
|
||||
const total =
|
||||
await getProductVariationsTotalCount< number >( requestParams );
|
||||
|
||||
setVariations( data );
|
||||
setTotalCount( total );
|
||||
|
@ -267,7 +267,9 @@ export function useVariations( { productId }: UseVariationsProps ) {
|
|||
id: variationId,
|
||||
...variation
|
||||
}: PartialProductVariation ) {
|
||||
if ( isUpdating[ variationId ] ) return;
|
||||
if ( isUpdating[ variationId ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
setVariations( ( current ) =>
|
||||
current.map( ( currentVariation ) => {
|
||||
|
@ -307,7 +309,9 @@ export function useVariations( { productId }: UseVariationsProps ) {
|
|||
}
|
||||
|
||||
async function onDelete( variationId: number ) {
|
||||
if ( isUpdating[ variationId ] ) return;
|
||||
if ( isUpdating[ variationId ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { deleteProductVariation, invalidateResolutionForStore } =
|
||||
dispatch( EXPERIMENTAL_PRODUCT_VARIATIONS_STORE_NAME );
|
||||
|
|
|
@ -100,7 +100,9 @@ export function VariationStockStatusForm( {
|
|||
}
|
||||
|
||||
function renderTrackInventoryToggleHelp() {
|
||||
if ( isLoadingManageStockOption || canManageStock ) return undefined;
|
||||
if ( isLoadingManageStockOption || canManageStock ) {
|
||||
return undefined;
|
||||
}
|
||||
return createInterpolateElement(
|
||||
/* translators: <Link>: Learn more link opening tag. </Link>: Learn more link closing tag.*/
|
||||
__(
|
||||
|
|
|
@ -70,9 +70,10 @@ export function VariationsFilter( {
|
|||
search: searchText,
|
||||
};
|
||||
|
||||
const terms = await getProductAttributeTerms<
|
||||
ProductAttributeTerm[]
|
||||
>( sharedRequestArgs );
|
||||
const terms =
|
||||
await getProductAttributeTerms< ProductAttributeTerm[] >(
|
||||
sharedRequestArgs
|
||||
);
|
||||
|
||||
const totalTerms =
|
||||
await getProductAttributeTermsTotalCount< number >(
|
||||
|
@ -109,7 +110,9 @@ export function VariationsFilter( {
|
|||
}
|
||||
|
||||
async function handleScroll( event: UIEvent< HTMLDivElement > ) {
|
||||
if ( isLoading || options.length >= totalOptions ) return;
|
||||
if ( isLoading || options.length >= totalOptions ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollableElement = event.currentTarget;
|
||||
|
||||
|
|
|
@ -216,7 +216,9 @@ export function VariationsTableRow( {
|
|||
}
|
||||
|
||||
function renderPriceCellContent() {
|
||||
if ( ! variation.regular_price ) return null;
|
||||
if ( ! variation.regular_price ) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Dropdown
|
||||
contentClassName="woocommerce-product-variations__pricing-actions-menu"
|
||||
|
@ -266,7 +268,9 @@ export function VariationsTableRow( {
|
|||
}
|
||||
|
||||
function renderStockCellContent() {
|
||||
if ( ! variation.regular_price ) return null;
|
||||
if ( ! variation.regular_price ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
|
|
|
@ -12,7 +12,7 @@ import { ValidationContextProps } from './types';
|
|||
export const ValidationContext = createContext< ValidationContextProps< any > >(
|
||||
{
|
||||
errors: {},
|
||||
getFieldByValidatorId: () => ( {} as Promise< HTMLElement > ),
|
||||
getFieldByValidatorId: () => ( {} ) as Promise< HTMLElement >,
|
||||
registerValidator: () => () => {},
|
||||
unRegisterValidator: () => () => {},
|
||||
validateField: () => Promise.resolve( undefined ),
|
||||
|
|
|
@ -12,7 +12,7 @@ import { preventLeavingProductForm } from '../utils/prevent-leaving-product-form
|
|||
import { useProductEdits } from './use-product-edits';
|
||||
|
||||
export function useConfirmUnsavedProductChanges(
|
||||
productType = <string>'product'
|
||||
productType = < string >'product'
|
||||
) {
|
||||
const productId = useEntityId( 'postType', productType );
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import type { Metadata } from '../../types';
|
|||
import { disjoinMetas } from './utils';
|
||||
|
||||
export function useCustomFields<
|
||||
T extends Metadata< string > = Metadata< string >
|
||||
T extends Metadata< string > = Metadata< string >,
|
||||
>() {
|
||||
const [ metas, setMetas ] = useEntityProp< T[] >(
|
||||
'postType',
|
||||
|
|
|
@ -64,7 +64,9 @@ export function useDraggable< T >( { onSort }: DraggableProps< T > ) {
|
|||
|
||||
dropIndexRef.current = index;
|
||||
|
||||
if ( dragIndexRef.current === dropIndexRef.current ) return;
|
||||
if ( dragIndexRef.current === dropIndexRef.current ) {
|
||||
return;
|
||||
}
|
||||
if ( dragIndexRef.current < dropIndexRef.current ) {
|
||||
draggable?.classList.add( 'is-dragging-after' );
|
||||
} else {
|
||||
|
|
|
@ -54,11 +54,15 @@ export const useNumberInputProps = ( {
|
|||
|
||||
if ( event.code === 'ArrowUp' ) {
|
||||
event.preventDefault();
|
||||
if ( amount + step <= max ) onChange( String( amount + step ) );
|
||||
if ( amount + step <= max ) {
|
||||
onChange( String( amount + step ) );
|
||||
}
|
||||
}
|
||||
if ( event.code === 'ArrowDown' ) {
|
||||
event.preventDefault();
|
||||
if ( amount - step >= min ) onChange( String( amount - step ) );
|
||||
if ( amount - step >= min ) {
|
||||
onChange( String( amount - step ) );
|
||||
}
|
||||
}
|
||||
if ( onKeyDown ) {
|
||||
onKeyDown( event );
|
||||
|
|
|
@ -21,7 +21,7 @@ function filterProductEdits( edits: EntityEdits ) {
|
|||
return edits;
|
||||
}
|
||||
|
||||
export function useProductEdits( productType = <string>'product' ) {
|
||||
export function useProductEdits( productType = < string >'product' ) {
|
||||
const productId = useEntityId( 'postType', productType );
|
||||
|
||||
const { edits } = useSelect(
|
||||
|
|
|
@ -154,7 +154,9 @@ export function useProductHelper() {
|
|||
productId: number,
|
||||
variationsOrder?: { [ page: number ]: { [ id: number ]: number } }
|
||||
) {
|
||||
if ( ! variationsOrder ) return undefined;
|
||||
if ( ! variationsOrder ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return batchUpdateProductVariations<
|
||||
Promise< { update: ProductVariation[] } >
|
||||
|
|
|
@ -51,10 +51,13 @@ function useProductMetadata( options?: Options ) {
|
|||
);
|
||||
|
||||
return {
|
||||
metadata: meta_data.reduce( function ( acc, cur ) {
|
||||
acc[ cur.key ] = cur.value;
|
||||
return acc;
|
||||
}, {} as Record< string, string | undefined > ),
|
||||
metadata: meta_data.reduce(
|
||||
function ( acc, cur ) {
|
||||
acc[ cur.key ] = cur.value;
|
||||
return acc;
|
||||
},
|
||||
{} as Record< string, string | undefined >
|
||||
),
|
||||
update: ( entries: Metadata< string >[] ) =>
|
||||
editEntityRecord( 'postType', postType, id, {
|
||||
meta_data: [
|
||||
|
|
|
@ -13,7 +13,9 @@ export function useProductURL( productType: string ) {
|
|||
|
||||
const getProductURL = useCallback(
|
||||
( isPreview: boolean ) => {
|
||||
if ( ! permalink ) return undefined;
|
||||
if ( ! permalink ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const productURL = new URL( permalink );
|
||||
if ( isPreview ) {
|
||||
|
|
|
@ -106,9 +106,8 @@ export function useProductVariationsHelper() {
|
|||
( attr ) => attr.variation
|
||||
);
|
||||
|
||||
const defaultVariationValues = await getDefaultVariationValues(
|
||||
productId
|
||||
);
|
||||
const defaultVariationValues =
|
||||
await getDefaultVariationValues( productId );
|
||||
|
||||
await Promise.all(
|
||||
variations.map( ( variationId ) =>
|
||||
|
@ -187,8 +186,7 @@ export function useProductVariationsHelper() {
|
|||
navigateTo( { url } );
|
||||
}
|
||||
} );
|
||||
},
|
||||
[] );
|
||||
}, [] );
|
||||
|
||||
return {
|
||||
generateProductVariations,
|
||||
|
|
|
@ -27,8 +27,9 @@ function sort(
|
|||
currentPage: number,
|
||||
{ variationsOrder }: ProductVariationsOrder
|
||||
) {
|
||||
if ( ! variationsOrder || ! variationsOrder[ currentPage ] )
|
||||
if ( ! variationsOrder || ! variationsOrder[ currentPage ] ) {
|
||||
return variations;
|
||||
}
|
||||
|
||||
const currentPageVariationsOrder = variationsOrder[ currentPage ];
|
||||
|
||||
|
@ -36,8 +37,9 @@ function sort(
|
|||
if (
|
||||
! currentPageVariationsOrder[ a.id ] ||
|
||||
! currentPageVariationsOrder[ b.id ]
|
||||
)
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
return (
|
||||
currentPageVariationsOrder[ a.id ] -
|
||||
currentPageVariationsOrder[ b.id ]
|
||||
|
|
|
@ -23,7 +23,7 @@ interface BlockRepresentation< T extends Record< string, object > > {
|
|||
*/
|
||||
export function initBlock<
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
T extends Record< string, any > = Record< string, any >
|
||||
T extends Record< string, any > = Record< string, any >,
|
||||
>( block: BlockRepresentation< T > ): Block< T > | undefined {
|
||||
deprecated( 'initBlock()', {
|
||||
alternative: 'registerProductEditorBlockType()',
|
||||
|
|
|
@ -7,8 +7,8 @@ export const isProductEditor = () => {
|
|||
const query: { page?: string; path?: string } = getQuery();
|
||||
return (
|
||||
query?.page === 'wc-admin' &&
|
||||
[ '/add-product', '/product/' ].some( ( path ) =>
|
||||
query?.path?.startsWith( path )
|
||||
[ '/add-product', '/product/' ].some(
|
||||
( path ) => query?.path?.startsWith( path )
|
||||
)
|
||||
);
|
||||
};
|
||||
|
|
|
@ -13,7 +13,9 @@ export interface Image {
|
|||
* Converts an uploaded image into an Image object.
|
||||
*/
|
||||
export function mapUploadImageToImage( upload: UploadImage ): Image | null {
|
||||
if ( ! upload.id ) return null;
|
||||
if ( ! upload.id ) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
id: upload.id,
|
||||
name: upload.title,
|
||||
|
|
|
@ -48,7 +48,7 @@ function augmentUsesContext( usesContext?: string[] ) {
|
|||
|
||||
export function registerProductEditorBlockType<
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
T extends Record< string, any > = Record< string, any >
|
||||
T extends Record< string, any > = Record< string, any >,
|
||||
>( block: BlockRepresentation< T > ): Block< T > | undefined {
|
||||
const { metadata, settings, name } = block;
|
||||
|
||||
|
|
|
@ -353,7 +353,6 @@ export class RemoteLogger {
|
|||
* @param {boolean} shouldSendError Whether the error should be sent.
|
||||
* @param {Error} error The error object.
|
||||
* @param {TraceKit.StackFrame[]} stackFrames The stack frames of the error.
|
||||
*
|
||||
*/
|
||||
return applyFilters(
|
||||
REMOTE_LOGGING_SHOULD_SEND_ERROR_FILTER,
|
||||
|
@ -402,7 +401,6 @@ function canLog( _logger: RemoteLogger | null ): _logger is RemoteLogger {
|
|||
* This function should be called once at the start of the application.
|
||||
*
|
||||
* @param config - Configuration object for the RemoteLogger.
|
||||
*
|
||||
*/
|
||||
export function init( config: RemoteLoggerConfig ) {
|
||||
if ( ! window.wcSettings?.isRemoteLoggingEnabled ) {
|
||||
|
@ -433,7 +431,6 @@ export function init( config: RemoteLoggerConfig ) {
|
|||
* @param severity - The severity of the log.
|
||||
* @param message - The message to log.
|
||||
* @param extraData - Optional additional data to include in the log.
|
||||
*
|
||||
*/
|
||||
export async function log(
|
||||
severity: Exclude< LogData[ 'severity' ], undefined >,
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"@wordpress/scripts": "^19.2.4",
|
||||
"babel-jest": "~27.5.1",
|
||||
"eslint": "^8.55.0",
|
||||
"prettier": "npm:wp-prettier@^2.8.5",
|
||||
"prettier": "npm:wp-prettier@^3.0.3",
|
||||
"ts-loader": "^9.5.1",
|
||||
"typescript": "^5.3.3",
|
||||
"uglify-js": "^3.17.4",
|
||||
|
|
|
@ -23,9 +23,8 @@ export const useProductSlug = (): UseProductSlugHook => {
|
|||
if ( editSlugBox ) {
|
||||
editSlugBox.innerHTML = responseData;
|
||||
|
||||
const newSlug = document.getElementById(
|
||||
'editable-post-name-full'
|
||||
)?.innerText;
|
||||
const newSlug = document.getElementById( 'editable-post-name-full' )
|
||||
?.innerText;
|
||||
if ( newSlug && slugInputRef.current ) {
|
||||
slugInputRef.current.value = newSlug;
|
||||
slugInputRef.current.setAttribute( 'value', newSlug );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import { recordEvent } from '@woocommerce/tracks';
|
||||
|
||||
export const recordTracksFactory = <
|
||||
T = Record< string, string | number | null >
|
||||
T = Record< string, string | number | null >,
|
||||
>(
|
||||
feature: string,
|
||||
propertiesCallback: () => Record< string, string | number | null >
|
||||
|
|
|
@ -55,29 +55,29 @@ export class ReportChart extends Component {
|
|||
|
||||
getItemChartData() {
|
||||
const { primaryData, selectedChart } = this.props;
|
||||
const chartData = primaryData.data.intervals.map( function (
|
||||
interval
|
||||
) {
|
||||
const intervalData = {};
|
||||
interval.subtotals.segments.forEach( function ( segment ) {
|
||||
if ( segment.segment_label ) {
|
||||
const label = intervalData[ segment.segment_label ]
|
||||
? segment.segment_label +
|
||||
' (#' +
|
||||
segment.segment_id +
|
||||
')'
|
||||
: segment.segment_label;
|
||||
intervalData[ segment.segment_id ] = {
|
||||
label,
|
||||
value: segment.subtotals[ selectedChart.key ] || 0,
|
||||
};
|
||||
}
|
||||
} );
|
||||
return {
|
||||
date: formatDate( 'Y-m-d\\TH:i:s', interval.date_start ),
|
||||
...intervalData,
|
||||
};
|
||||
} );
|
||||
const chartData = primaryData.data.intervals.map(
|
||||
function ( interval ) {
|
||||
const intervalData = {};
|
||||
interval.subtotals.segments.forEach( function ( segment ) {
|
||||
if ( segment.segment_label ) {
|
||||
const label = intervalData[ segment.segment_label ]
|
||||
? segment.segment_label +
|
||||
' (#' +
|
||||
segment.segment_id +
|
||||
')'
|
||||
: segment.segment_label;
|
||||
intervalData[ segment.segment_id ] = {
|
||||
label,
|
||||
value: segment.subtotals[ selectedChart.key ] || 0,
|
||||
};
|
||||
}
|
||||
} );
|
||||
return {
|
||||
date: formatDate( 'Y-m-d\\TH:i:s', interval.date_start ),
|
||||
...intervalData,
|
||||
};
|
||||
}
|
||||
);
|
||||
return chartData;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,9 +172,10 @@ export const advancedFilters = applyFilters(
|
|||
component: 'Search',
|
||||
type: 'countries',
|
||||
getLabels: async ( value ) => {
|
||||
const countries = await resolveSelect(
|
||||
COUNTRIES_STORE_NAME
|
||||
).getCountries();
|
||||
const countries =
|
||||
await resolveSelect(
|
||||
COUNTRIES_STORE_NAME
|
||||
).getCountries();
|
||||
|
||||
const allLabels = countries.map( ( country ) => ( {
|
||||
key: country.code,
|
||||
|
|
|
@ -27,8 +27,12 @@ describe( 'PluginCard', () => {
|
|||
const description = queryByText( 'Plugin description' );
|
||||
expect( title ).toBeInTheDocument();
|
||||
expect( description ).toBeInTheDocument();
|
||||
if ( title ) fireEvent.click( title );
|
||||
if ( description ) fireEvent.click( description );
|
||||
if ( title ) {
|
||||
fireEvent.click( title );
|
||||
}
|
||||
if ( description ) {
|
||||
fireEvent.click( description );
|
||||
}
|
||||
expect( onChange ).toHaveBeenCalledTimes( 2 );
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -236,9 +236,8 @@ const handleOnboardingProfileOption = assign( {
|
|||
} );
|
||||
|
||||
const getCurrentUserEmail = fromPromise( async () => {
|
||||
const currentUser: WCUser< 'email' > = await resolveSelect(
|
||||
USER_STORE_NAME
|
||||
).getCurrentUser();
|
||||
const currentUser: WCUser< 'email' > =
|
||||
await resolveSelect( USER_STORE_NAME ).getCurrentUser();
|
||||
return currentUser?.email;
|
||||
} );
|
||||
|
||||
|
@ -363,9 +362,8 @@ const updateBusinessLocation = ( countryAndState: string ) => {
|
|||
};
|
||||
|
||||
const updateStoreCurrency = async ( countryAndState: string ) => {
|
||||
const { general: settings = {} } = await resolveSelect(
|
||||
SETTINGS_STORE_NAME
|
||||
).getSettings( 'general' );
|
||||
const { general: settings = {} } =
|
||||
await resolveSelect( SETTINGS_STORE_NAME ).getSettings( 'general' );
|
||||
|
||||
const countryCode = getCountryCode( countryAndState ) as string;
|
||||
const { currencySymbols = {}, localeInfo = {} } = getAdminSetting(
|
||||
|
|
|
@ -22,7 +22,7 @@ export const useEditorBlocks = (
|
|||
const [ blocks, onInput, onChange ]: [
|
||||
BlockInstance[] | undefined,
|
||||
ChangeHandler,
|
||||
ChangeHandler
|
||||
ChangeHandler,
|
||||
] = useEntityBlockEditor( 'postType', templateType, {
|
||||
id: templateId,
|
||||
} );
|
||||
|
|
|
@ -52,7 +52,9 @@ export const useHomeTemplates = () => {
|
|||
);
|
||||
|
||||
const homeTemplates = useMemo( () => {
|
||||
if ( isLoading ) return {};
|
||||
if ( isLoading ) {
|
||||
return {};
|
||||
}
|
||||
const recommendedTemplates = HOMEPAGE_TEMPLATES;
|
||||
|
||||
return Object.entries( recommendedTemplates ).reduce(
|
||||
|
|
|
@ -37,7 +37,7 @@ export const OptInSubscribe = () => {
|
|||
( font: {
|
||||
custom: Array< FontFamily >;
|
||||
theme: Array< FontFamily >;
|
||||
} ) => void
|
||||
} ) => void,
|
||||
] = useGlobalSetting( 'typography.fontFamilies' );
|
||||
|
||||
const {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue