+ const backgroundImageStyle = getBackgroundImageStyles( {
+ focalPoint,
+ imageFit,
+ isImgElement,
+ isRepeated,
+ url: backgroundImageSrc,
+ } );
+
+ const overlayStyle = {
+ background: overlayGradient,
+ backgroundColor: overlayColor,
+ };
+
+ return (
+ <>
+
+
- { backgroundImageSrc &&
- ( isImgElement ? (
-
{
- setBackgroundImageSize( {
- height:
- e.currentTarget?.naturalHeight,
- width:
- e.currentTarget?.naturalWidth,
- } );
- } }
- />
- ) : (
-
- ) ) }
-
- { ! isEmpty( product?.variation ) && (
-
- ) }
- { showDesc && (
+ className={ `${ className }__wrapper` }
+ style={ wrapperStyle }
+ >
- ) }
- { showPrice && (
-
{
+ setBackgroundImageSize( {
+ height: e.currentTarget
+ ?.naturalHeight,
+ width: e.currentTarget
+ ?.naturalWidth,
+ } );
+ } }
+ />
+ ) : (
+
+ ) ) }
+
- ) }
-
- { renderButton() }
+ { ! isEmpty( product?.variation ) && (
+
+ ) }
+ { showDesc && (
+
+ ) }
+ { showPrice && (
+
+ ) }
+
+ { renderButton() }
+
-
- >
- );
- };
+ >
+ );
+ };
+
+ if ( isEditingImage ) {
+ return (
+
+ );
+ }
- if ( isEditingImage ) {
return (
-
+ <>
+
+ { item ? renderItem() : renderNoItem() }
+ >
);
- }
-
- return (
- <>
-
- { item ? renderItem() : renderNoItem() }
- >
- );
-};
+ };
diff --git a/assets/js/blocks/featured-items/with-update-button-attributes.tsx b/assets/js/blocks/featured-items/with-update-button-attributes.tsx
index 94ff7dcef64..9a58bc975d6 100644
--- a/assets/js/blocks/featured-items/with-update-button-attributes.tsx
+++ b/assets/js/blocks/featured-items/with-update-button-attributes.tsx
@@ -36,55 +36,55 @@ type WithUpdateButtonProps< T extends EditorBlock< T > > =
| ( T & WithUpdateButtonCategoryProps< T > )
| ( T & WithUpdateButtonProductProps< T > );
-export const withUpdateButtonAttributes = < T extends EditorBlock< T > >(
- Component: ComponentType< T >
-) => ( props: WithUpdateButtonProps< T > ) => {
- const [ doUrlUpdate, setDoUrlUpdate ] = useState( false );
- const { attributes, category, clientId, product } = props;
- const item = category || product;
+export const withUpdateButtonAttributes =
+ < T extends EditorBlock< T > >( Component: ComponentType< T > ) =>
+ ( props: WithUpdateButtonProps< T > ) => {
+ const [ doUrlUpdate, setDoUrlUpdate ] = useState( false );
+ const { attributes, category, clientId, product } = props;
+ const item = category || product;
- const { editMode } = attributes;
- const permalink =
- ( item as WP_REST_API_Category )?.link ||
- ( item as ProductResponseItem )?.permalink;
+ const { editMode } = attributes;
+ const permalink =
+ ( item as WP_REST_API_Category )?.link ||
+ ( item as ProductResponseItem )?.permalink;
- const Block = useSelect( ( select ) => {
- return select( 'core/block-editor' ).getBlock( clientId );
- } );
- const InnerButton = Block?.innerBlocks[ 0 ];
- const buttonBlockId = InnerButton?.clientId || '';
- const currentButtonAttributes = useMemo(
- () => InnerButton?.attributes || {},
- [ InnerButton ]
- );
- const { url } = currentButtonAttributes;
+ const Block = useSelect( ( select ) => {
+ return select( 'core/block-editor' ).getBlock( clientId );
+ } );
+ const InnerButton = Block?.innerBlocks[ 0 ];
+ const buttonBlockId = InnerButton?.clientId || '';
+ const currentButtonAttributes = useMemo(
+ () => InnerButton?.attributes || {},
+ [ InnerButton ]
+ );
+ const { url } = currentButtonAttributes;
- const { updateBlockAttributes } = useDispatch( 'core/block-editor' );
+ const { updateBlockAttributes } = useDispatch( 'core/block-editor' );
- useEffect( () => {
- if (
- doUrlUpdate &&
- buttonBlockId &&
- ! editMode &&
- permalink &&
- url &&
- permalink !== url
- ) {
- updateBlockAttributes( buttonBlockId, {
- url: permalink,
- } );
- setDoUrlUpdate( false );
- }
- }, [
- buttonBlockId,
- doUrlUpdate,
- editMode,
- permalink,
- updateBlockAttributes,
- url,
- ] );
+ useEffect( () => {
+ if (
+ doUrlUpdate &&
+ buttonBlockId &&
+ ! editMode &&
+ permalink &&
+ url &&
+ permalink !== url
+ ) {
+ updateBlockAttributes( buttonBlockId, {
+ url: permalink,
+ } );
+ setDoUrlUpdate( false );
+ }
+ }, [
+ buttonBlockId,
+ doUrlUpdate,
+ editMode,
+ permalink,
+ updateBlockAttributes,
+ url,
+ ] );
- const triggerUrlUpdate = () => setDoUrlUpdate( true );
+ const triggerUrlUpdate = () => setDoUrlUpdate( true );
- return
;
-};
+ return
;
+ };
diff --git a/assets/js/blocks/mini-cart/block.tsx b/assets/js/blocks/mini-cart/block.tsx
index 8fb3025523f..9c73f54ea0f 100644
--- a/assets/js/blocks/mini-cart/block.tsx
+++ b/assets/js/blocks/mini-cart/block.tsx
@@ -67,9 +67,8 @@ const MiniCartBlock = ( {
const [ isOpen, setIsOpen ] = useState< boolean >( isInitiallyOpen );
// We already rendered the HTML drawer placeholder, so we want to skip the
// slide in animation.
- const [ skipSlideIn, setSkipSlideIn ] = useState< boolean >(
- isInitiallyOpen
- );
+ const [ skipSlideIn, setSkipSlideIn ] =
+ useState< boolean >( isInitiallyOpen );
const [ contentsNode, setContentsNode ] = useState< HTMLDivElement | null >(
null
);
@@ -154,11 +153,12 @@ const MiniCartBlock = ( {
isBoolean
);
- const preFetchedCartTotals = getSettingWithCoercion< CartResponseTotals | null >(
- 'cartTotals',
- null,
- isCartResponseTotals
- );
+ const preFetchedCartTotals =
+ getSettingWithCoercion< CartResponseTotals | null >(
+ 'cartTotals',
+ null,
+ isCartResponseTotals
+ );
const preFetchedCartItemsCount = getSettingWithCoercion< number >(
'cartItemsCount',
diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx
index 2c8c3db875f..d991483cacd 100644
--- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx
+++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/edit.tsx
@@ -20,11 +20,11 @@ export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
const allowedBlocks = getAllowedBlocks( innerBlockAreas.FILLED_MINI_CART );
const { currentView } = useEditorContext();
- const defaultTemplate = ( [
+ const defaultTemplate = [
[ 'woocommerce/mini-cart-title-block', {} ],
[ 'woocommerce/mini-cart-items-block', {} ],
[ 'woocommerce/mini-cart-footer-block', {} ],
- ].filter( Boolean ) as unknown ) as TemplateArray;
+ ].filter( Boolean ) as unknown as TemplateArray;
useForcedLayout( {
clientId,
diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx
index dd7b4fcdb91..6005b8e74f3 100644
--- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx
+++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/edit.tsx
@@ -14,9 +14,9 @@ export const Edit = (): JSX.Element => {
className: 'wc-block-mini-cart__items',
} );
- const defaultTemplate = ( [
+ const defaultTemplate = [
[ 'woocommerce/mini-cart-products-table-block', {} ],
- ].filter( Boolean ) as unknown ) as TemplateArray;
+ ].filter( Boolean ) as unknown as TemplateArray;
return (
diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts
index d29a13b2d83..79aa25254e3 100644
--- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts
+++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/register-components.ts
@@ -21,63 +21,70 @@ __webpack_public_path__ = WC_BLOCKS_BUILD_URL;
registerCheckoutBlock( {
metadata: filledMiniCartMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/filled-cart" */ './filled-mini-cart-contents-block/frontend'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/filled-cart" */ './filled-mini-cart-contents-block/frontend'
+ )
),
} );
registerCheckoutBlock( {
metadata: emptyMiniCartContentsMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/empty-cart" */ './empty-mini-cart-contents-block/frontend'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/empty-cart" */ './empty-mini-cart-contents-block/frontend'
+ )
),
} );
registerCheckoutBlock( {
metadata: miniCartTitleMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/title" */ './mini-cart-title-block/block'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/title" */ './mini-cart-title-block/block'
+ )
),
} );
registerCheckoutBlock( {
metadata: miniCartItemsMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/items" */ './mini-cart-items-block/frontend'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/items" */ './mini-cart-items-block/frontend'
+ )
),
} );
registerCheckoutBlock( {
metadata: miniCartProductsTableMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/products-table" */ './mini-cart-products-table-block/block'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/products-table" */ './mini-cart-products-table-block/block'
+ )
),
} );
registerCheckoutBlock( {
metadata: miniCartFooterMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/footer" */ './mini-cart-footer-block/block'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/footer" */ './mini-cart-footer-block/block'
+ )
),
} );
registerCheckoutBlock( {
metadata: miniCartShoppingButtonMetadata,
- component: lazy( () =>
- import(
- /* webpackChunkName: "mini-cart-contents-block/shopping-button" */ './mini-cart-shopping-button-block/block'
- )
+ component: lazy(
+ () =>
+ import(
+ /* webpackChunkName: "mini-cart-contents-block/shopping-button" */ './mini-cart-shopping-button-block/block'
+ )
),
} );
diff --git a/assets/js/blocks/price-filter/block.tsx b/assets/js/blocks/price-filter/block.tsx
index 750b5b273e6..7568ff3ac3c 100644
--- a/assets/js/blocks/price-filter/block.tsx
+++ b/assets/js/blocks/price-filter/block.tsx
@@ -100,9 +100,8 @@ const PriceFilterBlock = ( {
* Important: Only used on the PHP rendered Block pages to track
* the price filter defaults coming from the URL
*/
- const [ hasSetPhpFilterDefaults, setHasSetPhpFilterDefaults ] = useState(
- false
- );
+ const [ hasSetPhpFilterDefaults, setHasSetPhpFilterDefaults ] =
+ useState( false );
const minPriceParam = getUrlParameter( 'min_price' );
const maxPriceParam = getUrlParameter( 'max_price' );
@@ -315,7 +314,8 @@ const PriceFilterBlock = ( {
return null;
}
- const TagName = `h${ attributes.headingLevel }` as keyof JSX.IntrinsicElements;
+ const TagName =
+ `h${ attributes.headingLevel }` as keyof JSX.IntrinsicElements;
return (
<>
diff --git a/assets/js/blocks/price-filter/edit.tsx b/assets/js/blocks/price-filter/edit.tsx
index f58e6f422a7..df830023625 100644
--- a/assets/js/blocks/price-filter/edit.tsx
+++ b/assets/js/blocks/price-filter/edit.tsx
@@ -32,12 +32,8 @@ export default function ( {
attributes,
setAttributes,
}: BlockEditProps< Attributes > ) {
- const {
- heading,
- headingLevel,
- showInputFields,
- showFilterButton,
- } = attributes;
+ const { heading, headingLevel, showInputFields, showFilterButton } =
+ attributes;
const blockProps = useBlockProps();
diff --git a/assets/js/blocks/product-categories/block.js b/assets/js/blocks/product-categories/block.js
index 725ab502324..854d1565734 100644
--- a/assets/js/blocks/product-categories/block.js
+++ b/assets/js/blocks/product-categories/block.js
@@ -43,13 +43,8 @@ const EmptyPlaceholder = () => (
*/
const ProductCategoriesBlock = ( { attributes, setAttributes, name } ) => {
const getInspectorControls = () => {
- const {
- hasCount,
- hasImage,
- hasEmpty,
- isDropdown,
- isHierarchical,
- } = attributes;
+ const { hasCount, hasImage, hasEmpty, isDropdown, isHierarchical } =
+ attributes;
return (
diff --git a/assets/js/blocks/product-categories/index.js b/assets/js/blocks/product-categories/index.js
index 270524f0a02..9715d879d34 100644
--- a/assets/js/blocks/product-categories/index.js
+++ b/assets/js/blocks/product-categories/index.js
@@ -156,12 +156,8 @@ registerBlockType( 'woocommerce/product-categories', {
return attributes;
},
save( props ) {
- const {
- hasCount,
- hasEmpty,
- isDropdown,
- isHierarchical,
- } = props.attributes;
+ const { hasCount, hasEmpty, isDropdown, isHierarchical } =
+ props.attributes;
const data = {};
if ( hasCount ) {
data[ 'data-has-count' ] = true;
diff --git a/assets/js/blocks/stock-filter/block.tsx b/assets/js/blocks/stock-filter/block.tsx
index 633e2cbdd81..00344a3ac61 100644
--- a/assets/js/blocks/stock-filter/block.tsx
+++ b/assets/js/blocks/stock-filter/block.tsx
@@ -56,9 +56,8 @@ const StockStatusFilterBlock = ( {
isBoolean
);
- const [ hasSetPhpFilterDefaults, setHasSetPhpFilterDefaults ] = useState(
- false
- );
+ const [ hasSetPhpFilterDefaults, setHasSetPhpFilterDefaults ] =
+ useState( false );
const { outofstock, ...otherStockStatusOptions } = getSetting(
'stockStatusOptions',
@@ -86,18 +85,14 @@ const StockStatusFilterBlock = ( {
);
const [ queryState ] = useQueryStateByContext();
- const [
- productStockStatusQuery,
- setProductStockStatusQuery,
- ] = useQueryStateByKey( 'stock_status', [] );
+ const [ productStockStatusQuery, setProductStockStatusQuery ] =
+ useQueryStateByKey( 'stock_status', [] );
- const {
- results: filteredCounts,
- isLoading: filteredCountsLoading,
- } = useCollectionData( {
- queryStock: true,
- queryState,
- } );
+ const { results: filteredCounts, isLoading: filteredCountsLoading } =
+ useCollectionData( {
+ queryStock: true,
+ queryState,
+ } );
/**
* Get count data about a given status by slug.
@@ -354,7 +349,8 @@ const StockStatusFilterBlock = ( {
return null;
}
- const TagName = `h${ blockAttributes.headingLevel }` as keyof JSX.IntrinsicElements;
+ const TagName =
+ `h${ blockAttributes.headingLevel }` as keyof JSX.IntrinsicElements;
const isLoading =
! blockAttributes.isPreview && ! STOCK_STATUS_OPTIONS.current;
const isDisabled = ! blockAttributes.isPreview && filteredCountsLoading;
diff --git a/assets/js/blocks/stock-filter/edit.tsx b/assets/js/blocks/stock-filter/edit.tsx
index e754763f39a..05bdf6dd6b1 100644
--- a/assets/js/blocks/stock-filter/edit.tsx
+++ b/assets/js/blocks/stock-filter/edit.tsx
@@ -25,13 +25,8 @@ const Edit = ( {
attributes,
setAttributes,
}: BlockEditProps< Attributes > ) => {
- const {
- className,
- heading,
- headingLevel,
- showCounts,
- showFilterButton,
- } = attributes;
+ const { className, heading, headingLevel, showCounts, showFilterButton } =
+ attributes;
const blockProps = useBlockProps( {
className: classnames( 'wc-block-stock-filter', className ),
diff --git a/assets/js/data/cart/actions.ts b/assets/js/data/cart/actions.ts
index 05ac2b2ee5c..2b5afb94816 100644
--- a/assets/js/data/cart/actions.ts
+++ b/assets/js/data/cart/actions.ts
@@ -33,9 +33,9 @@ import { ReturnOrGeneratorYieldUnion } from '../mapped-types';
export const receiveCart = (
response: CartResponse
): { type: string; response: Cart } => {
- const cart = ( mapKeys( response, ( _, key ) =>
+ const cart = mapKeys( response, ( _, key ) =>
camelCase( key )
- ) as unknown ) as Cart;
+ ) as unknown as Cart;
return {
type: types.RECEIVE_CART,
response: cart,
@@ -55,9 +55,9 @@ export const receiveCart = (
export const receiveCartContents = (
response: CartResponse
): { type: string; response: Partial< Cart > } => {
- const cart = ( mapKeys( response, ( _, key ) =>
+ const cart = mapKeys( response, ( _, key ) =>
camelCase( key )
- ) as unknown ) as Cart;
+ ) as unknown as Cart;
const { shippingAddress, billingAddress, ...cartWithoutAddress } = cart;
return {
type: types.RECEIVE_CART,
diff --git a/assets/js/data/cart/index.ts b/assets/js/data/cart/index.ts
index a4bc7a8b98b..a17a1d490c3 100644
--- a/assets/js/data/cart/index.ts
+++ b/assets/js/data/cart/index.ts
@@ -34,9 +34,9 @@ declare module '@wordpress/data' {
function dispatch(
key: typeof CART_STORE_KEY
): DispatchFromMap< typeof actions >;
- function select(
- key: typeof CART_STORE_KEY
- ): SelectFromMap< typeof selectors > & {
+ function select( key: typeof CART_STORE_KEY ): SelectFromMap<
+ typeof selectors
+ > & {
hasFinishedResolution: ( selector: string ) => boolean;
};
}
diff --git a/assets/js/data/cart/test/selectors.js b/assets/js/data/cart/test/selectors.js
index 66d6bfa54fa..f38bcd567ef 100644
--- a/assets/js/data/cart/test/selectors.js
+++ b/assets/js/data/cart/test/selectors.js
@@ -45,12 +45,10 @@ const state = {
images: [
{
id: 48,
- src:
- 'http://local.wordpress.test/wp-content/uploads/2019/12/album-1.jpg',
+ src: 'http://local.wordpress.test/wp-content/uploads/2019/12/album-1.jpg',
thumbnail:
'http://local.wordpress.test/wp-content/uploads/2019/12/album-1-324x324.jpg',
- srcset:
- 'http://local.wordpress.test/wp-content/uploads/2019/12/album-1.jpg 800w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-324x324.jpg 324w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-100x100.jpg 100w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-416x416.jpg 416w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-300x300.jpg 300w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-150x150.jpg 150w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-768x768.jpg 768w',
+ srcset: 'http://local.wordpress.test/wp-content/uploads/2019/12/album-1.jpg 800w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-324x324.jpg 324w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-100x100.jpg 100w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-416x416.jpg 416w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-300x300.jpg 300w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-150x150.jpg 150w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-768x768.jpg 768w',
sizes: '(max-width: 800px) 100vw, 800px',
name: 'album-1.jpg',
alt: '',
@@ -85,12 +83,10 @@ const state = {
images: [
{
id: 40,
- src:
- 'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2.jpg',
+ src: 'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2.jpg',
thumbnail:
'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-324x324.jpg',
- srcset:
- 'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2.jpg 801w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-324x324.jpg 324w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-100x100.jpg 100w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-416x416.jpg 416w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-300x300.jpg 300w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-150x150.jpg 150w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-768x768.jpg 768w',
+ srcset: 'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2.jpg 801w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-324x324.jpg 324w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-100x100.jpg 100w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-416x416.jpg 416w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-300x300.jpg 300w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-150x150.jpg 150w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-768x768.jpg 768w',
sizes: '(max-width: 801px) 100vw, 801px',
name: 'beanie-2.jpg',
alt: '',
diff --git a/assets/js/data/collections/resolvers.js b/assets/js/data/collections/resolvers.js
index 86b6109bdc0..5a1a37f6689 100644
--- a/assets/js/data/collections/resolvers.js
+++ b/assets/js/data/collections/resolvers.js
@@ -54,10 +54,8 @@ export function* getCollection( namespace, resourceName, query, ids ) {
}
try {
- const {
- response = DEFAULT_EMPTY_ARRAY,
- headers,
- } = yield apiFetchWithHeaders( { path: route + queryString } );
+ const { response = DEFAULT_EMPTY_ARRAY, headers } =
+ yield apiFetchWithHeaders( { path: route + queryString } );
if ( headers && headers.get && headers.has( 'last-modified' ) ) {
// Do any invalidation before the collection is received to prevent
diff --git a/assets/js/data/constants.ts b/assets/js/data/constants.ts
index 339cf2557a7..996dbbd8105 100644
--- a/assets/js/data/constants.ts
+++ b/assets/js/data/constants.ts
@@ -5,12 +5,12 @@
*/
export const API_BLOCK_NAMESPACE = 'wc/blocks';
-export const EMPTY_CART_COUPONS: [ ] = [];
-export const EMPTY_CART_ITEMS: [ ] = [];
-export const EMPTY_CART_FEES: [ ] = [];
-export const EMPTY_CART_ITEM_ERRORS: [ ] = [];
-export const EMPTY_CART_ERRORS: [ ] = [];
-export const EMPTY_SHIPPING_RATES: [ ] = [];
-export const EMPTY_PAYMENT_REQUIREMENTS: [ ] = [];
+export const EMPTY_CART_COUPONS: [] = [];
+export const EMPTY_CART_ITEMS: [] = [];
+export const EMPTY_CART_FEES: [] = [];
+export const EMPTY_CART_ITEM_ERRORS: [] = [];
+export const EMPTY_CART_ERRORS: [] = [];
+export const EMPTY_SHIPPING_RATES: [] = [];
+export const EMPTY_PAYMENT_REQUIREMENTS: [] = [];
export const EMPTY_EXTENSIONS: Record< string, unknown > = {};
-export const EMPTY_TAX_LINES: [ ] = [];
+export const EMPTY_TAX_LINES: [] = [];
diff --git a/assets/js/data/default-states.ts b/assets/js/data/default-states.ts
index 29ff0e7fe79..8fe8ec2b698 100644
--- a/assets/js/data/default-states.ts
+++ b/assets/js/data/default-states.ts
@@ -27,8 +27,8 @@ export interface CartState {
errors: Array< ResponseError >;
}
-export const EMPTY_PENDING_QUANTITY: [ ] = [];
-export const EMPTY_PENDING_DELETE: [ ] = [];
+export const EMPTY_PENDING_QUANTITY: [] = [];
+export const EMPTY_PENDING_DELETE: [] = [];
export const defaultCartState: CartState = {
cartItemsPendingQuantity: EMPTY_PENDING_QUANTITY,
diff --git a/assets/js/data/mapped-types.ts b/assets/js/data/mapped-types.ts
index ec447656341..01c711c8653 100644
--- a/assets/js/data/mapped-types.ts
+++ b/assets/js/data/mapped-types.ts
@@ -62,19 +62,17 @@ export type TailParameters< F extends Function > = F extends (
/**
* Obtain the type finally returned by the generator when it's done iterating.
*/
-export type GeneratorReturnType<
- T extends ( ...args: any[] ) => Generator
-> = T extends ( ...args: any ) => Generator< any, infer R, any > ? R : never;
+export type GeneratorReturnType< T extends ( ...args: any[] ) => Generator > =
+ T extends ( ...args: any ) => Generator< any, infer R, any > ? R : never;
/**
* Usually we use ReturnType of all the action creators to deduce all the actions.
* This works until one of the action creators is a generator and doesn't actually "Return" an action.
* This type helper allows for actions to be both functions and generators
*/
-export type ReturnOrGeneratorYieldUnion<
- T extends ( ...args: any ) => any
-> = T extends ( ...args: any ) => infer Return
- ? Return extends Generator< infer T, infer U, any >
- ? T | U
- : Return
- : never;
+export type ReturnOrGeneratorYieldUnion< T extends ( ...args: any ) => any > =
+ T extends ( ...args: any ) => infer Return
+ ? Return extends Generator< infer T, infer U, any >
+ ? T | U
+ : Return
+ : never;
diff --git a/assets/js/data/schema/selectors.js b/assets/js/data/schema/selectors.js
index 9d85b64b60b..92f45285582 100644
--- a/assets/js/data/schema/selectors.js
+++ b/assets/js/data/schema/selectors.js
@@ -32,47 +32,49 @@ import { STORE_KEY } from './constants';
* @return {string} The route if it is available.
*/
export const getRoute = createRegistrySelector(
- ( select ) => ( state, namespace, resourceName, ids = [] ) => {
- const hasResolved = select(
- STORE_KEY
- ).hasFinishedResolution( 'getRoutes', [ namespace ] );
- state = state.routes;
- let error = '';
- if ( ! state[ namespace ] ) {
- error = sprintf(
- 'There is no route for the given namespace (%s) in the store',
- namespace
+ ( select ) =>
+ ( state, namespace, resourceName, ids = [] ) => {
+ const hasResolved = select( STORE_KEY ).hasFinishedResolution(
+ 'getRoutes',
+ [ namespace ]
);
- } else if ( ! state[ namespace ][ resourceName ] ) {
- error = sprintf(
- 'There is no route for the given resource name (%s) in the store',
- resourceName
- );
- }
- if ( error !== '' ) {
- if ( hasResolved ) {
- throw new Error( error );
- }
- return '';
- }
- const route = getRouteFromResourceEntries(
- state[ namespace ][ resourceName ],
- ids
- );
- if ( route === '' ) {
- if ( hasResolved ) {
- throw new Error(
- sprintf(
- 'While there is a route for the given namespace (%1$s) and resource name (%2$s), there is no route utilizing the number of ids you included in the select arguments. The available routes are: (%3$s)',
- namespace,
- resourceName,
- JSON.stringify( state[ namespace ][ resourceName ] )
- )
+ state = state.routes;
+ let error = '';
+ if ( ! state[ namespace ] ) {
+ error = sprintf(
+ 'There is no route for the given namespace (%s) in the store',
+ namespace
);
+ } else if ( ! state[ namespace ][ resourceName ] ) {
+ error = sprintf(
+ 'There is no route for the given resource name (%s) in the store',
+ resourceName
+ );
+ }
+ if ( error !== '' ) {
+ if ( hasResolved ) {
+ throw new Error( error );
+ }
+ return '';
}
+ const route = getRouteFromResourceEntries(
+ state[ namespace ][ resourceName ],
+ ids
+ );
+ if ( route === '' ) {
+ if ( hasResolved ) {
+ throw new Error(
+ sprintf(
+ 'While there is a route for the given namespace (%1$s) and resource name (%2$s), there is no route utilizing the number of ids you included in the select arguments. The available routes are: (%3$s)',
+ namespace,
+ resourceName,
+ JSON.stringify( state[ namespace ][ resourceName ] )
+ )
+ );
+ }
+ }
+ return route;
}
- return route;
- }
);
/**
@@ -85,9 +87,10 @@ export const getRoute = createRegistrySelector(
*/
export const getRoutes = createRegistrySelector(
( select ) => ( state, namespace ) => {
- const hasResolved = select(
- STORE_KEY
- ).hasFinishedResolution( 'getRoutes', [ namespace ] );
+ const hasResolved = select( STORE_KEY ).hasFinishedResolution(
+ 'getRoutes',
+ [ namespace ]
+ );
const routes = state.routes[ namespace ];
if ( ! routes ) {
if ( hasResolved ) {
diff --git a/assets/js/data/schema/test/selectors.js b/assets/js/data/schema/test/selectors.js
index ded81504bfe..0e7bc205cff 100644
--- a/assets/js/data/schema/test/selectors.js
+++ b/assets/js/data/schema/test/selectors.js
@@ -34,9 +34,11 @@ const testState = deepFreeze( {
} );
describe( 'getRoute', () => {
- const invokeTest = ( namespace, resourceName, ids = [] ) => () => {
- return getRoute( testState, namespace, resourceName, ids );
- };
+ const invokeTest =
+ ( namespace, resourceName, ids = [] ) =>
+ () => {
+ return getRoute( testState, namespace, resourceName, ids );
+ };
describe( 'with throwing errors', () => {
beforeEach( () => mockHasFinishedResolution.mockReturnValue( true ) );
it( 'throws an error if there is no route for the given namespace', () => {
@@ -78,10 +80,11 @@ describe( 'getRoute', () => {
} );
test( 'when there is a route with placeholders', () => {
expect(
- invokeTest( 'wc/blocks', 'products/attributes/terms', [
- 10,
- 20,
- ] )()
+ invokeTest(
+ 'wc/blocks',
+ 'products/attributes/terms',
+ [ 10, 20 ]
+ )()
).toBe( 'wc/blocks/products/attributes/10/terms/20' );
} );
} );
diff --git a/assets/js/editor-components/external-link-card/stories/index.tsx b/assets/js/editor-components/external-link-card/stories/index.tsx
index 276d916b267..6c1f23fbd71 100644
--- a/assets/js/editor-components/external-link-card/stories/index.tsx
+++ b/assets/js/editor-components/external-link-card/stories/index.tsx
@@ -21,7 +21,6 @@ export const Default = Template.bind( {} );
Default.args = {
description:
'This is the description of the link, perhaps a bit of a longer paragraph or a summary of a blog post, or whatever could give more context',
- href:
- 'https://woocommerce.com/posts/seven-tips-to-extend-holiday-sales-momentum/',
+ href: 'https://woocommerce.com/posts/seven-tips-to-extend-holiday-sales-momentum/',
title: 'Seven tips to extend holiday sales momentum',
};
diff --git a/assets/js/editor-components/product-tag-control/index.js b/assets/js/editor-components/product-tag-control/index.js
index a2386d6f7e3..0b6ed524227 100644
--- a/assets/js/editor-components/product-tag-control/index.js
+++ b/assets/js/editor-components/product-tag-control/index.js
@@ -93,13 +93,8 @@ class ProductTagControl extends Component {
render() {
const { list, loading } = this.state;
- const {
- isCompact,
- onChange,
- onOperatorChange,
- operator,
- selected,
- } = this.props;
+ const { isCompact, onChange, onOperatorChange, operator, selected } =
+ this.props;
const messages = {
clear: __(
diff --git a/assets/js/editor-components/search-list-control/types.ts b/assets/js/editor-components/search-list-control/types.ts
index 6c01296eb49..c1737693c54 100644
--- a/assets/js/editor-components/search-list-control/types.ts
+++ b/assets/js/editor-components/search-list-control/types.ts
@@ -13,7 +13,7 @@ export type SearchListItemType = {
breadcrumbs: string[];
};
-export type SearchListItemsType = SearchListItemType[] | [ ];
+export type SearchListItemsType = SearchListItemType[] | [];
export interface SearchListMessages {
// A more detailed label for the "Clear all" button, read to screen reader users.
diff --git a/assets/js/editor-components/search-list-control/utils.tsx b/assets/js/editor-components/search-list-control/utils.tsx
index 43c65adfbee..f98d8796f26 100644
--- a/assets/js/editor-components/search-list-control/utils.tsx
+++ b/assets/js/editor-components/search-list-control/utils.tsx
@@ -41,7 +41,7 @@ export const defaultMessages = {
export const buildTermsTree = (
filteredList: SearchListItemsType,
list = filteredList
-): SearchListItemType[] | [ ] => {
+): SearchListItemType[] | [] => {
const termsByParent = groupBy( filteredList, 'parent' );
const listById = keyBy( list, 'id' );
const builtParents = [ '0' ];
@@ -90,7 +90,7 @@ export const getFilteredList = (
list: SearchListItemsType,
search: string,
isHierarchical: boolean
-): SearchListItemType[] | [ ] => {
+): SearchListItemType[] | [] => {
if ( ! search ) {
return isHierarchical ? buildTermsTree( list ) : list;
}
diff --git a/assets/js/extensions/google-analytics/utils.ts b/assets/js/extensions/google-analytics/utils.ts
index f5e43762b60..e4b22a73c19 100644
--- a/assets/js/extensions/google-analytics/utils.ts
+++ b/assets/js/extensions/google-analytics/utils.ts
@@ -79,40 +79,40 @@ export const trackEvent = (
let currentStep = -1;
-export const trackCheckoutStep = ( step: number ) => ( {
- storeCart,
-}: {
- storeCart: StoreCart;
-} ): void => {
- if ( currentStep === step ) {
- return;
- }
- trackEvent( step === 0 ? 'begin_checkout' : 'checkout_progress', {
- items: storeCart.cartItems.map( getProductFieldObject ),
- coupon: storeCart.cartCoupons[ 0 ]?.code || '',
- currency: storeCart.cartTotals.currency_code,
- value: (
- parseInt( storeCart.cartTotals.total_price, 10 ) /
- 10 ** storeCart.cartTotals.currency_minor_unit
- ).toString(),
- checkout_step: step,
- } );
- currentStep = step;
-};
+export const trackCheckoutStep =
+ ( step: number ) =>
+ ( { storeCart }: { storeCart: StoreCart } ): void => {
+ if ( currentStep === step ) {
+ return;
+ }
+ trackEvent( step === 0 ? 'begin_checkout' : 'checkout_progress', {
+ items: storeCart.cartItems.map( getProductFieldObject ),
+ coupon: storeCart.cartCoupons[ 0 ]?.code || '',
+ currency: storeCart.cartTotals.currency_code,
+ value: (
+ parseInt( storeCart.cartTotals.total_price, 10 ) /
+ 10 ** storeCart.cartTotals.currency_minor_unit
+ ).toString(),
+ checkout_step: step,
+ } );
+ currentStep = step;
+ };
-export const trackCheckoutOption = ( {
- step,
- option,
- value,
-}: {
- step: number;
- option: string;
- value: string;
-} ) => (): void => {
- trackEvent( 'set_checkout_option', {
- checkout_step: step,
- checkout_option: option,
+export const trackCheckoutOption =
+ ( {
+ step,
+ option,
value,
- } );
- currentStep = step;
-};
+ }: {
+ step: number;
+ option: string;
+ value: string;
+ } ) =>
+ (): void => {
+ trackEvent( 'set_checkout_option', {
+ checkout_step: step,
+ checkout_option: option,
+ value,
+ } );
+ currentStep = step;
+ };
diff --git a/assets/js/filters/exclude-draft-status-from-analytics.js b/assets/js/filters/exclude-draft-status-from-analytics.js
index f935bf8eedb..b97d3e484c9 100644
--- a/assets/js/filters/exclude-draft-status-from-analytics.js
+++ b/assets/js/filters/exclude-draft-status-from-analytics.js
@@ -19,12 +19,14 @@ addFilter(
return optionsGroup;
};
- const actionableStatusesOptions = settings.woocommerce_actionable_order_statuses.options.map(
- removeCheckoutDraft
- );
- const excludedStatusesOptions = settings.woocommerce_excluded_report_order_statuses.options.map(
- removeCheckoutDraft
- );
+ const actionableStatusesOptions =
+ settings.woocommerce_actionable_order_statuses.options.map(
+ removeCheckoutDraft
+ );
+ const excludedStatusesOptions =
+ settings.woocommerce_excluded_report_order_statuses.options.map(
+ removeCheckoutDraft
+ );
return {
...settings,
diff --git a/assets/js/middleware/store-api-nonce.js b/assets/js/middleware/store-api-nonce.js
index 2da91f2a8e3..d533d5a3c0a 100644
--- a/assets/js/middleware/store-api-nonce.js
+++ b/assets/js/middleware/store-api-nonce.js
@@ -103,9 +103,8 @@ const storeNonceMiddleware = ( options, next ) => {
// Add nonce to sub-requests
if ( Array.isArray( options?.data?.requests ) ) {
- options.data.requests = options.data.requests.map(
- appendNonceHeader
- );
+ options.data.requests =
+ options.data.requests.map( appendNonceHeader );
}
}
return next( options, next );
diff --git a/assets/js/previews/reviews.js b/assets/js/previews/reviews.js
index b2ee378a443..f41c2d4607e 100644
--- a/assets/js/previews/reviews.js
+++ b/assets/js/previews/reviews.js
@@ -23,8 +23,8 @@ export const previewReviews = [
'woo-gutenberg-products-block'
) }\n`,
reviewer_avatar_urls: {
- '48': blocksConfig.defaultAvatar,
- '96': blocksConfig.defaultAvatar,
+ 48: blocksConfig.defaultAvatar,
+ 96: blocksConfig.defaultAvatar,
},
rating: 5,
verified: true,
@@ -47,8 +47,8 @@ export const previewReviews = [
'woo-gutenberg-products-block'
) }\n`,
reviewer_avatar_urls: {
- '48': blocksConfig.defaultAvatar,
- '96': blocksConfig.defaultAvatar,
+ 48: blocksConfig.defaultAvatar,
+ 96: blocksConfig.defaultAvatar,
},
rating: null,
verified: false,
diff --git a/assets/js/shared/hocs/with-filtered-attributes.js b/assets/js/shared/hocs/with-filtered-attributes.js
index e3e95488f2e..1a482be565a 100644
--- a/assets/js/shared/hocs/with-filtered-attributes.js
+++ b/assets/js/shared/hocs/with-filtered-attributes.js
@@ -8,17 +8,19 @@ import { getValidBlockAttributes } from '@woocommerce/base-utils';
*
* @param {Object} blockAttributes Component being wrapped.
*/
-export const withFilteredAttributes = ( blockAttributes ) => (
- OriginalComponent
-) => {
- return ( ownProps ) => {
- const validBlockAttributes = getValidBlockAttributes(
- blockAttributes,
- ownProps
- );
+export const withFilteredAttributes =
+ ( blockAttributes ) => ( OriginalComponent ) => {
+ return ( ownProps ) => {
+ const validBlockAttributes = getValidBlockAttributes(
+ blockAttributes,
+ ownProps
+ );
- return (
-
- );
+ return (
+
+ );
+ };
};
-};
diff --git a/bin/hook-docs/actions/index.js b/bin/hook-docs/actions/index.js
index 9e3c1ec3d8a..821a168b6d6 100644
--- a/bin/hook-docs/actions/index.js
+++ b/bin/hook-docs/actions/index.js
@@ -32,8 +32,7 @@ const generate = ( hooks ) => {
const jsonDocs = [
{ html: '' },
{
- html:
- '',
+ html: '',
},
{ h1: 'Actions' },
{ h2: 'Table of Contents' },
diff --git a/bin/hook-docs/filters/index.js b/bin/hook-docs/filters/index.js
index a5d2fde3937..2d114ad10d3 100644
--- a/bin/hook-docs/filters/index.js
+++ b/bin/hook-docs/filters/index.js
@@ -32,8 +32,7 @@ const generate = ( hooks ) => {
const jsonDocs = [
{ html: '' },
{
- html:
- '',
+ html: '',
},
{ h1: 'Filters' },
{ h2: 'Table of Contents' },
diff --git a/bin/webpack-configs.js b/bin/webpack-configs.js
index 2d2ad7684e7..b2e8374333d 100644
--- a/bin/webpack-configs.js
+++ b/bin/webpack-configs.js
@@ -711,10 +711,8 @@ const getStylingConfig = ( options = {} ) => {
includePaths: [ 'assets/css/abstracts' ],
},
additionalData: ( content, loaderContext ) => {
- const {
- resourcePath,
- rootContext,
- } = loaderContext;
+ const { resourcePath, rootContext } =
+ loaderContext;
const relativePath = path.relative(
rootContext,
resourcePath
diff --git a/package-lock.json b/package-lock.json
index 444ae211ac0..1605dad4d41 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -93,6 +93,7 @@
"@wordpress/html-entities": "3.2.3",
"@wordpress/i18n": "4.2.4",
"@wordpress/is-shallow-equal": "4.2.1",
+ "@wordpress/prettier-config": "^1.1.1",
"@wordpress/scripts": "22.3.0",
"autoprefixer": "10.3.7",
"axios": "0.21.4",
@@ -138,10 +139,10 @@
"patch-package": "6.4.7",
"postcss": "8.2.13",
"postcss-loader": "4.2.0",
- "prettier": "npm:wp-prettier@2.0.5",
+ "prettier": "npm:wp-prettier@2.6.2",
"progress-bar-webpack-plugin": "2.1.0",
"promptly": "3.2.0",
- "puppeteer": "^13.7.0",
+ "puppeteer": "13.7.0",
"react-docgen": "5.4.0",
"react-test-renderer": "17.0.2",
"request-promise": "4.2.6",
@@ -39459,10 +39460,19 @@
},
"node_modules/prettier": {
"name": "wp-prettier",
- "version": "2.0.5",
- "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz",
- "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==",
- "dev": true
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.6.2.tgz",
+ "integrity": "sha512-AV33EzqiFJ3fj+mPlKABN59YFPReLkDxQnj067Z3uEOeRQf3g05WprL0RDuqM7UBhSRo9W1rMSC2KvZmjE5UOA==",
+ "dev": true,
+ "bin": {
+ "prettier": "bin-prettier.js"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
+ }
},
"node_modules/prettier-linter-helpers": {
"version": "1.0.0",
@@ -79483,9 +79493,9 @@
"optional": true
},
"prettier": {
- "version": "npm:wp-prettier@2.0.5",
- "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz",
- "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==",
+ "version": "npm:wp-prettier@2.6.2",
+ "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.6.2.tgz",
+ "integrity": "sha512-AV33EzqiFJ3fj+mPlKABN59YFPReLkDxQnj067Z3uEOeRQf3g05WprL0RDuqM7UBhSRo9W1rMSC2KvZmjE5UOA==",
"dev": true
},
"prettier-linter-helpers": {
diff --git a/package.json b/package.json
index 7d76bf4bb2d..3272692faf5 100644
--- a/package.json
+++ b/package.json
@@ -143,6 +143,7 @@
"@wordpress/i18n": "4.2.4",
"@wordpress/is-shallow-equal": "4.2.1",
"@wordpress/scripts": "22.3.0",
+ "@wordpress/prettier-config": "^1.1.1",
"autoprefixer": "10.3.7",
"axios": "0.21.4",
"babel-plugin-explicit-exports-references": "^1.0.2",
@@ -187,7 +188,7 @@
"patch-package": "6.4.7",
"postcss": "8.2.13",
"postcss-loader": "4.2.0",
- "prettier": "npm:wp-prettier@2.0.5",
+ "prettier": "npm:wp-prettier@2.6.2",
"progress-bar-webpack-plugin": "2.1.0",
"promptly": "3.2.0",
"puppeteer": "13.7.0",
diff --git a/packages/checkout/components/discounts-meta/index.js b/packages/checkout/components/discounts-meta/index.js
index 267adf39db4..3f87627a7e8 100644
--- a/packages/checkout/components/discounts-meta/index.js
+++ b/packages/checkout/components/discounts-meta/index.js
@@ -11,10 +11,8 @@ import TotalsWrapper from '../totals-wrapper';
const slotName = '__experimentalDiscountsMeta';
-const {
- Fill: ExperimentalDiscountsMeta,
- Slot: DiscountsMetaSlot,
-} = createSlotFill( slotName );
+const { Fill: ExperimentalDiscountsMeta, Slot: DiscountsMetaSlot } =
+ createSlotFill( slotName );
const Slot = ( { className, extensions, cart, context } ) => {
const { fills } = useSlot( slotName );
diff --git a/packages/checkout/components/order-meta/index.js b/packages/checkout/components/order-meta/index.js
index 7c86bc632ee..39c7a096107 100644
--- a/packages/checkout/components/order-meta/index.js
+++ b/packages/checkout/components/order-meta/index.js
@@ -11,9 +11,8 @@ import TotalsWrapper from '../totals-wrapper';
const slotName = '__experimentalOrderMeta';
-const { Fill: ExperimentalOrderMeta, Slot: OrderMetaSlot } = createSlotFill(
- slotName
-);
+const { Fill: ExperimentalOrderMeta, Slot: OrderMetaSlot } =
+ createSlotFill( slotName );
const Slot = ( { className, extensions, cart, context } ) => {
const { fills } = useSlot( slotName );
diff --git a/packages/checkout/filter-registry/index.ts b/packages/checkout/filter-registry/index.ts
index 854ddc510cf..da3674d9269 100644
--- a/packages/checkout/filter-registry/index.ts
+++ b/packages/checkout/filter-registry/index.ts
@@ -49,8 +49,7 @@ export const __experimentalRegisterCheckoutFilters = (
deprecated( 'snackbarNotices', {
alternative: 'snackbarNoticeVisibility',
plugin: 'WooCommerce Blocks',
- link:
- 'https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4417',
+ link: 'https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/4417',
} );
}
@@ -63,8 +62,7 @@ export const __experimentalRegisterCheckoutFilters = (
deprecated( 'couponName', {
alternative: 'coupons',
plugin: 'WooCommerce Blocks',
- link:
- 'https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/bb921d21f42e21f38df2b1c87b48e07aa4cb0538/docs/extensibility/available-filters.md#coupons',
+ link: 'https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/bb921d21f42e21f38df2b1c87b48e07aa4cb0538/docs/extensibility/available-filters.md#coupons',
} );
}
diff --git a/packages/prices/utils/price.ts b/packages/prices/utils/price.ts
index 40b76974de3..54a7779d744 100644
--- a/packages/prices/utils/price.ts
+++ b/packages/prices/utils/price.ts
@@ -178,13 +178,8 @@ export const formatPrice = (
const currency: Currency = getCurrency( currencyData );
- const {
- minorUnit,
- prefix,
- suffix,
- decimalSeparator,
- thousandSeparator,
- } = currency;
+ const { minorUnit, prefix, suffix, decimalSeparator, thousandSeparator } =
+ currency;
const formattedPrice: number = priceInt / 10 ** minorUnit;
diff --git a/storybook/custom-controls/currency.ts b/storybook/custom-controls/currency.ts
index ce6b175a615..2c1d39e8f1f 100644
--- a/storybook/custom-controls/currency.ts
+++ b/storybook/custom-controls/currency.ts
@@ -25,15 +25,13 @@ export const currencies: Record< string, Currency > = {
},
} as const;
-export const currenciesAPIShape: Record<
- string,
- CurrencyResponse
-> = Object.fromEntries(
- Object.entries( currencies ).map( ( [ key, value ] ) => [
- key,
- snakecaseKeys( value ),
- ] )
-);
+export const currenciesAPIShape: Record< string, CurrencyResponse > =
+ Object.fromEntries(
+ Object.entries( currencies ).map( ( [ key, value ] ) => [
+ key,
+ snakecaseKeys( value ),
+ ] )
+ );
export const currencyControl = {
control: 'select',
diff --git a/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json
index 83be6820f4d..592c5ded3ea 100644
--- a/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json
+++ b/tests/e2e/config/custom-matchers/__fixtures__/best-selling-products.fixture.json
@@ -1 +1,4 @@
-{"title":"Best Selling Products Block","pageContent":""}
\ No newline at end of file
+{
+ "title": "Best Selling Products Block",
+ "pageContent": ""
+}
diff --git a/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json
index 60f0ae7b0d9..b6c77eb3381 100644
--- a/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json
+++ b/tests/e2e/config/custom-matchers/__fixtures__/featured-category.fixture.json
@@ -1 +1,4 @@
-{"title":"Featured Category Block","pageContent":""}
\ No newline at end of file
+{
+ "title": "Featured Category Block",
+ "pageContent": ""
+}
diff --git a/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json
index 907b84ea5ec..4b2f1de3f43 100644
--- a/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json
+++ b/tests/e2e/config/custom-matchers/__fixtures__/hand-picked-products.fixture.json
@@ -1 +1,4 @@
-{"title":"Hand-picked Products Block","pageContent":""}
\ No newline at end of file
+{
+ "title": "Hand-picked Products Block",
+ "pageContent": ""
+}
diff --git a/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json
index 5ffe302fc75..d3aa952f8b7 100644
--- a/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json
+++ b/tests/e2e/config/custom-matchers/__fixtures__/newest-products.fixture.json
@@ -1 +1,4 @@
-{"title":"Newest Products Block","pageContent":""}
\ No newline at end of file
+{
+ "title": "Newest Products Block",
+ "pageContent": ""
+}
diff --git a/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json
index 7e6a4d9e3bb..6f6baf27aef 100644
--- a/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json
+++ b/tests/e2e/config/custom-matchers/__fixtures__/product-categories-list.fixture.json
@@ -1 +1,4 @@
-{"title":"Product Categories List Block","pageContent":""}
\ No newline at end of file
+{
+ "title": "Product Categories List Block",
+ "pageContent": ""
+}
diff --git a/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json b/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json
index 4adb6788563..a3190e493b4 100644
--- a/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json
+++ b/tests/e2e/config/custom-matchers/__fixtures__/top-rated-products.fixture.json
@@ -1 +1,4 @@
-{"title":"Top Rated Products Block","pageContent":""}
\ No newline at end of file
+{
+ "title": "Top Rated Products Block",
+ "pageContent": ""
+}
diff --git a/tests/e2e/config/setup.js b/tests/e2e/config/setup.js
index 10a2684115d..3b57bb981a1 100644
--- a/tests/e2e/config/setup.js
+++ b/tests/e2e/config/setup.js
@@ -49,14 +49,8 @@ module.exports = async ( globalConfig ) => {
enablePaymentGateways(),
setupPageSettings(),
] ).catch( console.log );
- const [
- taxes,
- coupons,
- categories,
- tags,
- shippingZones,
- attributes,
- ] = results;
+ const [ taxes, coupons, categories, tags, shippingZones, attributes ] =
+ results;
// Create products after categories.
const products = await createProducts( categories, tags, attributes );
diff --git a/tests/e2e/fixtures/fixture-data.js b/tests/e2e/fixtures/fixture-data.js
index af7ae386864..382a03c6732 100644
--- a/tests/e2e/fixtures/fixture-data.js
+++ b/tests/e2e/fixtures/fixture-data.js
@@ -152,14 +152,12 @@ const Products = () => [
downloads: [
{
name: 'Woo Single',
- file:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ file: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
images: [
{
- src:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
categories: [ 'Music' ],
@@ -172,8 +170,7 @@ const Products = () => [
downloadable: false,
images: [
{
- src:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
attributes: [
@@ -194,8 +191,7 @@ const Products = () => [
downloadable: false,
images: [
{
- src:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
attributes: [
@@ -216,14 +212,12 @@ const Products = () => [
downloads: [
{
name: 'Woo Single 2',
- file:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ file: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
images: [
{
- src:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
categories: [ 'Music' ],
@@ -238,14 +232,12 @@ const Products = () => [
downloads: [
{
name: 'Woo Single 2',
- file:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ file: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
images: [
{
- src:
- 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
+ src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg',
},
],
categories: [ 'Music' ],
diff --git a/tests/e2e/fixtures/fixture-loaders.js b/tests/e2e/fixtures/fixture-loaders.js
index a343985336b..f734d8c0b74 100644
--- a/tests/e2e/fixtures/fixture-loaders.js
+++ b/tests/e2e/fixtures/fixture-loaders.js
@@ -1,8 +1,8 @@
/**
* External dependencies
*/
-const WooCommerceRestApi = require( '@woocommerce/woocommerce-rest-api' )
- .default;
+const WooCommerceRestApi =
+ require( '@woocommerce/woocommerce-rest-api' ).default;
const glob = require( 'glob-promise' );
const { dirname } = require( 'path' );
const { readJson } = require( 'fs-extra' );
diff --git a/tests/e2e/specs/backend/active-filters.test.js b/tests/e2e/specs/backend/active-filters.test.js
index 157a0c31f08..6c81df7e098 100644
--- a/tests/e2e/specs/backend/active-filters.test.js
+++ b/tests/e2e/specs/backend/active-filters.test.js
@@ -50,9 +50,7 @@ describe( `${ block.name } Block`, () => {
await page.click(
'.components-toolbar button[aria-label="Heading 6"]'
);
- await expect(
- page
- ).toMatchElement(
+ await expect( page ).toMatchElement(
`.wp-block[data-type="${ block.slug }"] h6 textarea`,
{ text: 'New Title' }
);
diff --git a/tests/e2e/specs/backend/attribute-filter.test.js b/tests/e2e/specs/backend/attribute-filter.test.js
index 7b1eebe40a7..a5b4678b6bf 100644
--- a/tests/e2e/specs/backend/attribute-filter.test.js
+++ b/tests/e2e/specs/backend/attribute-filter.test.js
@@ -62,9 +62,7 @@ describe( `${ block.name } Block`, () => {
await page.click(
'.components-toolbar button[aria-label="Heading 6"]'
);
- await expect(
- page
- ).toMatchElement(
+ await expect( page ).toMatchElement(
`.wp-block[data-type="${ block.slug }"] h6 textarea`,
{ text: 'New Title' }
);
diff --git a/tests/e2e/specs/backend/price-filter.test.js b/tests/e2e/specs/backend/price-filter.test.js
index 7a9750a08ca..6acd0887d0e 100644
--- a/tests/e2e/specs/backend/price-filter.test.js
+++ b/tests/e2e/specs/backend/price-filter.test.js
@@ -53,9 +53,7 @@ describe( `${ block.name } Block`, () => {
await page.click(
'.components-toolbar button[aria-label="Heading 6"]'
);
- await expect(
- page
- ).toMatchElement(
+ await expect( page ).toMatchElement(
`.wp-block[data-type="${ block.slug }"] h6 textarea`,
{ text: 'New Title' }
);
@@ -67,9 +65,7 @@ describe( `${ block.name } Block`, () => {
await page.click(
'.components-toolbar button[aria-label="Heading 3"]'
);
- await expect(
- page
- ).not.toMatchElement(
+ await expect( page ).not.toMatchElement(
`.wp-block[data-type="${ block.slug }"] h6 textarea`,
{ text: 'New Title' }
);
diff --git a/tests/e2e/specs/frontend/legacy-template-blocks.test.ts b/tests/e2e/specs/frontend/legacy-template-blocks.test.ts
index 584ab749e5a..0cd13d14589 100644
--- a/tests/e2e/specs/frontend/legacy-template-blocks.test.ts
+++ b/tests/e2e/specs/frontend/legacy-template-blocks.test.ts
@@ -55,10 +55,8 @@ describe( 'Classic Template blocks', () => {
await page.waitForSelector( productArchivePage.productsList );
await page.waitForSelector( productArchivePage.resultsCount );
- const {
- displayedCount,
- shouldHavePaginationUI,
- } = await extractPaginationData();
+ const { displayedCount, shouldHavePaginationUI } =
+ await extractPaginationData();
if ( shouldHavePaginationUI ) {
await expect( page ).toMatchElement(
@@ -93,10 +91,8 @@ describe( 'Classic Template blocks', () => {
await page.waitForSelector( productArchivePage.productsList );
await page.waitForSelector( productArchivePage.resultsCount );
- const {
- displayedCount,
- shouldHavePaginationUI,
- } = await extractPaginationData();
+ const { displayedCount, shouldHavePaginationUI } =
+ await extractPaginationData();
if ( shouldHavePaginationUI ) {
await expect( page ).toMatchElement(
@@ -131,10 +127,8 @@ describe( 'Classic Template blocks', () => {
await page.waitForSelector( productArchivePage.productsList );
await page.waitForSelector( productArchivePage.resultsCount );
- const {
- displayedCount,
- shouldHavePaginationUI,
- } = await extractPaginationData();
+ const { displayedCount, shouldHavePaginationUI } =
+ await extractPaginationData();
if ( shouldHavePaginationUI ) {
await expect( page ).toMatchElement(
diff --git a/tests/e2e/specs/shopper/cart-checkout/account.test.js b/tests/e2e/specs/shopper/cart-checkout/account.test.js
index f49d30c85d9..89943d6400a 100644
--- a/tests/e2e/specs/shopper/cart-checkout/account.test.js
+++ b/tests/e2e/specs/shopper/cart-checkout/account.test.js
@@ -52,8 +52,7 @@ describe( 'Shopper → Checkout → Account', () => {
//Enable shoppers to sign up at checkout option.
// eslint-disable-next-line jest/no-standalone-expect
await expect( page ).toClick( 'label', {
- text:
- 'Allow shoppers to sign up for a user account during checkout',
+ text: 'Allow shoppers to sign up for a user account during checkout',
} );
await saveOrPublish();
await merchant.logout();
diff --git a/tests/e2e/utils.js b/tests/e2e/utils.js
index 74471db59af..b81f23da141 100644
--- a/tests/e2e/utils.js
+++ b/tests/e2e/utils.js
@@ -44,8 +44,7 @@ export const DEFAULT_TIMEOUT = 30000;
const SELECTORS = {
canvas: 'iframe[name="editor-canvas"]',
inserter: {
- search:
- '.components-search-control__input,.block-editor-inserter__search input,.block-editor-inserter__search-input,input.block-editor-inserter__search',
+ search: '.components-search-control__input,.block-editor-inserter__search input,.block-editor-inserter__search-input,input.block-editor-inserter__search',
},
templatesListTable: {
actionsContainer: '.edit-site-list-table__actions',
diff --git a/tests/js/jestPreprocess.js b/tests/js/jestPreprocess.js
index 40bf8c2621e..9baa877eae3 100644
--- a/tests/js/jestPreprocess.js
+++ b/tests/js/jestPreprocess.js
@@ -6,6 +6,5 @@ const babelOptions = {
],
};
-module.exports = require( 'babel-jest' ).default.createTransformer(
- babelOptions
-);
+module.exports =
+ require( 'babel-jest' ).default.createTransformer( babelOptions );
diff --git a/tests/utils/shopper.js b/tests/utils/shopper.js
index be2c75fff41..705449b549a 100644
--- a/tests/utils/shopper.js
+++ b/tests/utils/shopper.js
@@ -69,9 +69,7 @@ export const shopper = {
await expect( page ).toMatchElement( 'span', {
text: productTitle,
} );
- await expect(
- page
- ).toMatchElement(
+ await expect( page ).toMatchElement(
'div.wc-block-components-order-summary-item__quantity',
{ text: quantity }
);
diff --git a/tests/utils/taxes.ts b/tests/utils/taxes.ts
index c3bf4a5e08f..f4ffedc3ce1 100644
--- a/tests/utils/taxes.ts
+++ b/tests/utils/taxes.ts
@@ -72,8 +72,8 @@ export async function getTaxesFromOrderSummaryPage(
)
)
.filter( ( node ) => {
- const taxLabel = node.getElementsByTagName( 'th' )[ 0 ]
- .innerHTML;
+ const taxLabel =
+ node.getElementsByTagName( 'th' )[ 0 ].innerHTML;
return taxRatesEval.some(
// We need to remove the ":" on the end of the string before we compare
( taxRate ) => taxRate.name === taxLabel.slice( 0, -1 )