diff --git a/plugins/woocommerce-blocks/.eslintignore b/plugins/woocommerce-blocks/.eslintignore
index 44c5613ab4d..a2e9341e3f9 100644
--- a/plugins/woocommerce-blocks/.eslintignore
+++ b/plugins/woocommerce-blocks/.eslintignore
@@ -6,3 +6,4 @@ languages
node_modules
vendor
legacy
+tests/e2e/specs
diff --git a/plugins/woocommerce-blocks/.eslintrc.js b/plugins/woocommerce-blocks/.eslintrc.js
index ee4deb72b84..c21dc02830a 100644
--- a/plugins/woocommerce-blocks/.eslintrc.js
+++ b/plugins/woocommerce-blocks/.eslintrc.js
@@ -1,31 +1,59 @@
module.exports = {
- extends: [
- 'plugin:@wordpress/eslint-plugin/recommended',
- 'prettier',
- 'plugin:jest/recommended',
- 'plugin:react-hooks/recommended',
- ],
- env: {
- 'jest/globals': true,
- },
+ extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
globals: {
- wcSettings: 'readonly',
wcStoreApiNonce: 'readonly',
- page: true,
- browser: true,
- context: true,
- jestPuppeteer: true,
fetchMock: true,
jQuery: 'readonly',
IntersectionObserver: 'readonly',
+ // @todo Move E2E related ESLint configuration into custom config.
+ //
+ // We should have linting properties only included for files that they
+ // are specific to as opposed to globally.
+ page: 'readonly',
+ browser: 'readonly',
+ context: 'readonly',
+ jestPuppeteer: 'readonly',
},
- plugins: [ 'jest', 'woocommerce' ],
rules: {
- '@wordpress/dependency-group': 'off',
- 'woocommerce/dependency-group': 'error',
'woocommerce/feature-flag': 'off',
- 'valid-jsdoc': 'off',
- radix: 'error',
- yoda: [ 'error', 'never' ],
+ // @todo Remove temporary disabling of various eslint rules.
+ // To keep pull request reviews smaller and changes more precise, new rules
+ // added via the adoption of `@woocommerce/eslint-plugin` that are failing
+ // will be handled in individual pulls. The following rules need to be turned
+ // back on (via individual pulls):
+ // - jsdoc/require-param
+ // - jsdoc/check-tag-names
+ // - jsdoc/check-param-names
+ // - jsdoc/require-property-description
+ // - jsdoc/valid-types
+ // - jsdoc/require-property
+ // - jsdoc/no-undefined-types
+ // - jsdoc/check-types
+ // - jsdoc/require-returns-description
+ // - jsdoc/require-param-type
+ // - jsdoc/require-returns-type
+ // - jsdoc/newline-after-description
+ // - @wordpress/i18n-translator-comments
+ // - @wordpress/valid-sprintf
+ // - @worpdress/no-unused-vars-before-return
+ // - testing-library/no-await-sync-query
+ // - @woocommerce/dependency-group
+ 'jsdoc/require-param': 'off',
+ 'jsdoc/check-tag-names': 'off',
+ 'jsdoc/check-param-names': 'off',
+ 'jsdoc/require-property-description': 'off',
+ 'jsdoc/valid-types': 'off',
+ 'jsdoc/require-property': 'off',
+ 'jsdoc/no-undefined-types': 'off',
+ 'jsdoc/check-types': 'off',
+ 'jsdoc/require-returns-description': 'off',
+ 'jsdoc/require-param-type': 'off',
+ 'jsdoc/require-returns-type': 'off',
+ 'jsdoc/newline-after-description': 'off',
+ '@wordpress/i18n-translator-comments': 'off',
+ '@wordpress/valid-sprintf': 'off',
+ '@wordpress/no-unused-vars-before-return': 'off',
+ 'testing-library/no-await-sync-query': 'off',
+ '@woocommerce/dependency-group': 'off',
},
};
diff --git a/plugins/woocommerce-blocks/.github/release-automation-config.json b/plugins/woocommerce-blocks/.github/release-automation-config.json
index d94e2ca03e8..d0c9296d69d 100644
--- a/plugins/woocommerce-blocks/.github/release-automation-config.json
+++ b/plugins/woocommerce-blocks/.github/release-automation-config.json
@@ -1,6 +1,3 @@
{
- "labelsToOmit": [
- "skip-changelog",
- "type: build"
- ]
+ "labelsToOmit": [ "skip-changelog", "type: build" ]
}
diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/button/edit.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/button/edit.js
index 2522f150ecb..bd33eb4389b 100644
--- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/button/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/button/edit.js
@@ -23,7 +23,7 @@ export default withProductSelector( {
icon: BLOCK_ICON,
label: BLOCK_TITLE,
description: __(
- "Choose a product to display its add to cart button.",
+ 'Choose a product to display its add to cart button.',
'woo-gutenberg-products-block'
),
} )( Edit );
diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/edit.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/edit.js
index ad15f680f56..1b56833e02c 100644
--- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/price/edit.js
@@ -123,7 +123,7 @@ const Price = isFeaturePluginBuild()
icon: BLOCK_ICON,
label: BLOCK_TITLE,
description: __(
- "Choose a product to display its price.",
+ 'Choose a product to display its price.',
'woo-gutenberg-products-block'
),
} ),
diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/rating/edit.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/rating/edit.js
index 055b0aa7640..93ff774d1e7 100644
--- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/rating/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/rating/edit.js
@@ -17,7 +17,7 @@ export default withProductSelector( {
icon: BLOCK_ICON,
label: BLOCK_TITLE,
description: __(
- "Choose a product to display its rating.",
+ 'Choose a product to display its rating.',
'woo-gutenberg-products-block'
),
} )( Edit );
diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/sale-badge/edit.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/sale-badge/edit.js
index d17488c266a..fd8621a6d2e 100644
--- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/sale-badge/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/sale-badge/edit.js
@@ -18,7 +18,7 @@ export default withProductSelector( {
icon: BLOCK_ICON,
label: BLOCK_TITLE,
description: __(
- "Choose a product to display its sale-badge.",
+ 'Choose a product to display its sale-badge.',
'woo-gutenberg-products-block'
),
} )( Edit );
diff --git a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/summary/edit.js b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/summary/edit.js
index d79a881465e..3a828dd2c84 100644
--- a/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/summary/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/atomic/blocks/product-elements/summary/edit.js
@@ -18,7 +18,7 @@ export default withProductSelector( {
icon: BLOCK_ICON,
label: BLOCK_TITLE,
description: __(
- "Choose a product to display its short description.",
+ 'Choose a product to display its short description.',
'woo-gutenberg-products-block'
),
} )( Edit );
diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/totals-shipping-item/has-shipping-rate.js b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/totals-shipping-item/has-shipping-rate.js
index f72b99897de..0a7b1681edb 100644
--- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/totals-shipping-item/has-shipping-rate.js
+++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/totals-shipping-item/has-shipping-rate.js
@@ -6,7 +6,9 @@
* @return {boolean} True if a rate exists.
*/
const hasShippingRate = ( shippingRatePackages ) => {
- return shippingRatePackages.some( shippingRatePackage => shippingRatePackage.shipping_rates.length );
+ return shippingRatePackages.some(
+ ( shippingRatePackage ) => shippingRatePackage.shipping_rates.length
+ );
};
export default hasShippingRate;
diff --git a/plugins/woocommerce-blocks/assets/js/base/components/price-slider/test/constrain-range-slider-values.js b/plugins/woocommerce-blocks/assets/js/base/components/price-slider/test/constrain-range-slider-values.js
index 0a6a86fe1b0..dce3a33206f 100644
--- a/plugins/woocommerce-blocks/assets/js/base/components/price-slider/test/constrain-range-slider-values.js
+++ b/plugins/woocommerce-blocks/assets/js/base/components/price-slider/test/constrain-range-slider-values.js
@@ -5,23 +5,23 @@ import { constrainRangeSliderValues } from '../constrain-range-slider-values';
describe( 'constrainRangeSliderValues', () => {
test.each`
- values | min | max | step | isMin | expected
- ${[ 20, 60 ]} | ${0} | ${70} | ${10} | ${true} | ${[ 20, 60 ]}
- ${[ 20, 60 ]} | ${20} | ${60} | ${10} | ${true} | ${[ 20, 60 ]}
- ${[ 20, 60 ]} | ${30} | ${50} | ${10} | ${true} | ${[ 30, 50 ]}
- ${[ 50, 50 ]} | ${20} | ${60} | ${10} | ${true} | ${[ 50, 60 ]}
- ${[ 50, 50 ]} | ${20} | ${60} | ${10} | ${false} | ${[ 40, 50 ]}
- ${[ 20, 60 ]} | ${null} | ${null} | ${10} | ${true} | ${[ 20, 60 ]}
- ${[ null, null ]} | ${20} | ${60} | ${10} | ${true} | ${[ 20, 60 ]}
- ${[ '20', '60' ]} | ${30} | ${50} | ${10} | ${true} | ${[ 30, 50 ]}
- ${[ -60, -20 ]} | ${-70} | ${0} | ${10} | ${true} | ${[ -60, -20 ]}
- ${[ -60, -20 ]} | ${-60} | ${-20} | ${10} | ${true} | ${[ -60, -20 ]}
- ${[ -60, -20 ]} | ${-50} | ${-30} | ${10} | ${true} | ${[ -50, -30 ]}
- ${[ -50, -50 ]} | ${-60} | ${-20} | ${10} | ${true} | ${[ -50, -40 ]}
- ${[ -50, -50 ]} | ${-60} | ${-20} | ${10} | ${false} | ${[ -60, -50 ]}
- ${[ -60, -20 ]} | ${null} | ${null} | ${10} | ${true} | ${[ -60, -20 ]}
- ${[ null, null ]} | ${-60} | ${-20} | ${10} | ${true} | ${[ -60, -20 ]}
- ${[ '-60', '-20' ]} | ${-50} | ${-30} | ${10} | ${true} | ${[ -50, -30 ]}
+ values | min | max | step | isMin | expected
+ ${ [ 20, 60 ] } | ${ 0 } | ${ 70 } | ${ 10 } | ${ true } | ${ [ 20, 60 ] }
+ ${ [ 20, 60 ] } | ${ 20 } | ${ 60 } | ${ 10 } | ${ true } | ${ [ 20, 60 ] }
+ ${ [ 20, 60 ] } | ${ 30 } | ${ 50 } | ${ 10 } | ${ true } | ${ [ 30, 50 ] }
+ ${ [ 50, 50 ] } | ${ 20 } | ${ 60 } | ${ 10 } | ${ true } | ${ [ 50, 60 ] }
+ ${ [ 50, 50 ] } | ${ 20 } | ${ 60 } | ${ 10 } | ${ false } | ${ [ 40, 50 ] }
+ ${ [ 20, 60 ] } | ${ null } | ${ null } | ${ 10 } | ${ true } | ${ [ 20, 60 ] }
+ ${ [ null, null ] } | ${ 20 } | ${ 60 } | ${ 10 } | ${ true } | ${ [ 20, 60 ] }
+ ${ [ '20', '60' ] } | ${ 30 } | ${ 50 } | ${ 10 } | ${ true } | ${ [ 30, 50 ] }
+ ${ [ -60, -20 ] } | ${ -70 } | ${ 0 } | ${ 10 } | ${ true } | ${ [ -60, -20 ] }
+ ${ [ -60, -20 ] } | ${ -60 } | ${ -20 } | ${ 10 } | ${ true } | ${ [ -60, -20 ] }
+ ${ [ -60, -20 ] } | ${ -50 } | ${ -30 } | ${ 10 } | ${ true } | ${ [ -50, -30 ] }
+ ${ [ -50, -50 ] } | ${ -60 } | ${ -20 } | ${ 10 } | ${ true } | ${ [ -50, -40 ] }
+ ${ [ -50, -50 ] } | ${ -60 } | ${ -20 } | ${ 10 } | ${ false } | ${ [ -60, -50 ] }
+ ${ [ -60, -20 ] } | ${ null } | ${ null } | ${ 10 } | ${ true } | ${ [ -60, -20 ] }
+ ${ [ null, null ] } | ${ -60 } | ${ -20 } | ${ 10 } | ${ true } | ${ [ -60, -20 ] }
+ ${ [ '-60', '-20' ] } | ${ -50 } | ${ -30 } | ${ 10 } | ${ true } | ${ [ -50, -30 ] }
`(
`correctly sets prices to its constraints with arguments values: $values, min: $min, max: $max, step: $step and isMin: $isMin`,
( { values, min, max, step, isMin, expected } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/base/context/add-to-cart-form/form/submit/index.js b/plugins/woocommerce-blocks/assets/js/base/context/add-to-cart-form/form/submit/index.js
index 4a7fae77f2c..6a6f9c0d76a 100644
--- a/plugins/woocommerce-blocks/assets/js/base/context/add-to-cart-form/form/submit/index.js
+++ b/plugins/woocommerce-blocks/assets/js/base/context/add-to-cart-form/form/submit/index.js
@@ -80,7 +80,7 @@ const FormSubmit = () => {
triggerFetch.setNonce( fetchResponse.headers );
// Handle response.
- fetchResponse.json().then( function( response ) {
+ fetchResponse.json().then( function ( response ) {
if ( ! fetchResponse.ok ) {
// We received an error response.
if ( response.body && response.body.message ) {
@@ -111,7 +111,7 @@ const FormSubmit = () => {
} );
} )
.catch( ( error ) => {
- error.json().then( function( response ) {
+ error.json().then( function ( response ) {
// If updated cart state was returned, also update that.
if ( response.data?.cart ) {
receiveCart( response.data.cart );
diff --git a/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js b/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js
index f518a7d9a35..099aaa7423f 100644
--- a/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js
+++ b/plugins/woocommerce-blocks/assets/js/base/context/cart-checkout/checkout/processor/index.js
@@ -212,7 +212,7 @@ const CheckoutProcessor = () => {
triggerFetch.setNonce( fetchResponse.headers );
// Handle response.
- fetchResponse.json().then( function( response ) {
+ fetchResponse.json().then( function ( response ) {
if ( ! fetchResponse.ok ) {
// We received an error response.
if ( response.body && response.body.message ) {
@@ -237,7 +237,7 @@ const CheckoutProcessor = () => {
} );
} )
.catch( ( error ) => {
- error.json().then( function( response ) {
+ error.json().then( function ( response ) {
// If updated cart state was returned, also update that.
if ( response.data?.cart ) {
receiveCart( response.data.cart );
diff --git a/plugins/woocommerce-blocks/assets/js/base/context/container-width-context.js b/plugins/woocommerce-blocks/assets/js/base/context/container-width-context.js
index 8f55873822c..f13244436cd 100644
--- a/plugins/woocommerce-blocks/assets/js/base/context/container-width-context.js
+++ b/plugins/woocommerce-blocks/assets/js/base/context/container-width-context.js
@@ -55,7 +55,7 @@ export const ContainerWidthContextProvider = ( {
{ children }
- );
+ );
};
ContainerWidthContextProvider.propTypes = {
diff --git a/plugins/woocommerce-blocks/assets/js/base/context/test/utils.js b/plugins/woocommerce-blocks/assets/js/base/context/test/utils.js
index d431f818e6a..88bbfeda9c8 100644
--- a/plugins/woocommerce-blocks/assets/js/base/context/test/utils.js
+++ b/plugins/woocommerce-blocks/assets/js/base/context/test/utils.js
@@ -16,12 +16,12 @@ describe( 'assertValidContextValue', () => {
},
};
it.each`
- testValue | expectedMessage | expectError
- ${{}} | ${'expected'} | ${true}
- ${10} | ${'expected'} | ${true}
- ${{ amountKetchup: 20 }} | ${'not expected'} | ${false}
- ${{ amountKetchup: '10' }} | ${'expected'} | ${true}
- ${{ cheeseburger: 'fries', amountKetchup: 20 }} | ${'not expected'} | ${false}
+ testValue | expectedMessage | expectError
+ ${ {} } | ${ 'expected' } | ${ true }
+ ${ 10 } | ${ 'expected' } | ${ true }
+ ${ { amountKetchup: 20 } } | ${ 'not expected' } | ${ false }
+ ${ { amountKetchup: '10' } } | ${ 'expected' } | ${ true }
+ ${ { cheeseburger: 'fries', amountKetchup: 20 } } | ${ 'not expected' } | ${ false }
`(
'The value of $testValue is $expectedMessage to trigger an Error',
( { testValue, expectError } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-position-relative-to-viewport.js b/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-position-relative-to-viewport.js
index d6d5f6c7768..0b18403ea9d 100644
--- a/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-position-relative-to-viewport.js
+++ b/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-position-relative-to-viewport.js
@@ -53,11 +53,11 @@ describe( 'usePositionRelativeToViewport', () => {
} );
it.each`
- position | isIntersecting | top
- ${'visible'} | ${true} | ${0}
- ${'below'} | ${false} | ${10}
- ${'above'} | ${false} | ${0}
- ${'above'} | ${false} | ${-10}
+ position | isIntersecting | top
+ ${ 'visible' } | ${ true } | ${ 0 }
+ ${ 'below' } | ${ false } | ${ 10 }
+ ${ 'above' } | ${ false } | ${ 0 }
+ ${ 'above' } | ${ false } | ${ -10 }
`(
"position relative to viewport is '$position' with isIntersecting=$isIntersecting and top=$top",
( { position, isIntersecting, top } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-shallow-equal.js b/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-shallow-equal.js
index 0644385291d..cbf88b3d653 100644
--- a/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-shallow-equal.js
+++ b/plugins/woocommerce-blocks/assets/js/base/hooks/test/use-shallow-equal.js
@@ -16,18 +16,18 @@ describe( 'useShallowEqual', () => {
let renderer;
beforeEach( () => ( renderer = null ) );
it.each`
- testValueA | aType | testValueB | bType | expectEqual
- ${{ a: 'b', foo: 'bar' }} | ${'object'} | ${{ foo: 'bar', a: 'b' }} | ${'object'} | ${true}
- ${{ a: 'b', foo: 'bar' }} | ${'object'} | ${{ foo: 'bar', a: 'c' }} | ${'object'} | ${false}
- ${[ 'b', 'bar' ]} | ${'array'} | ${[ 'b', 'bar' ]} | ${'array'} | ${true}
- ${[ 'b', 'bar' ]} | ${'array'} | ${[ 'bar', 'b' ]} | ${'array'} | ${false}
- ${1} | ${'number'} | ${1} | ${'number'} | ${true}
- ${1} | ${'number'} | ${'1'} | ${'string'} | ${false}
- ${'1'} | ${'string'} | ${'1'} | ${'string'} | ${true}
- ${1} | ${'number'} | ${2} | ${'number'} | ${false}
- ${1} | ${'number'} | ${true} | ${'bool'} | ${false}
- ${0} | ${'number'} | ${false} | ${'bool'} | ${false}
- ${true} | ${'bool'} | ${true} | ${'bool'} | ${true}
+ testValueA | aType | testValueB | bType | expectEqual
+ ${ { a: 'b', foo: 'bar' } } | ${ 'object' } | ${ { foo: 'bar', a: 'b' } } | ${ 'object' } | ${ true }
+ ${ { a: 'b', foo: 'bar' } } | ${ 'object' } | ${ { foo: 'bar', a: 'c' } } | ${ 'object' } | ${ false }
+ ${ [ 'b', 'bar' ] } | ${ 'array' } | ${ [ 'b', 'bar' ] } | ${ 'array' } | ${ true }
+ ${ [ 'b', 'bar' ] } | ${ 'array' } | ${ [ 'bar', 'b' ] } | ${ 'array' } | ${ false }
+ ${ 1 } | ${ 'number' } | ${ 1 } | ${ 'number' } | ${ true }
+ ${ 1 } | ${ 'number' } | ${ '1' } | ${ 'string' } | ${ false }
+ ${ '1' } | ${ 'string' } | ${ '1' } | ${ 'string' } | ${ true }
+ ${ 1 } | ${ 'number' } | ${ 2 } | ${ 'number' } | ${ false }
+ ${ 1 } | ${ 'number' } | ${ true } | ${ 'bool' } | ${ false }
+ ${ 0 } | ${ 'number' } | ${ false } | ${ 'bool' } | ${ false }
+ ${ true } | ${ 'bool' } | ${ true } | ${ 'bool' } | ${ true }
`(
'$testValueA ($aType) and $testValueB ($bType) are expected to be equal ($expectEqual)',
( { testValueA, testValueB, expectEqual } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/base/utils/shipping-rates.js b/plugins/woocommerce-blocks/assets/js/base/utils/shipping-rates.js
index 19e5799dd68..54bb82f7483 100644
--- a/plugins/woocommerce-blocks/assets/js/base/utils/shipping-rates.js
+++ b/plugins/woocommerce-blocks/assets/js/base/utils/shipping-rates.js
@@ -13,7 +13,7 @@ export const getShippingRatesPackageCount = ( shippingRates ) => {
* @param {Array} shippingRates Shipping rates and packages array.
*/
export const getShippingRatesRateCount = ( shippingRates ) => {
- return shippingRates.reduce( function( count, shippingPackage ) {
+ return shippingRates.reduce( function ( count, shippingPackage ) {
return count + shippingPackage.shipping_rates.length;
}, 0 );
};
diff --git a/plugins/woocommerce-blocks/assets/js/base/utils/test/price.js b/plugins/woocommerce-blocks/assets/js/base/utils/test/price.js
index 65433956598..2bf72610571 100644
--- a/plugins/woocommerce-blocks/assets/js/base/utils/test/price.js
+++ b/plugins/woocommerce-blocks/assets/js/base/utils/test/price.js
@@ -5,15 +5,15 @@ import { formatPrice, getCurrency } from '../price';
describe( 'formatPrice', () => {
test.each`
- value | prefix | suffix | expected
- ${1000} | ${'€'} | ${''} | ${'€10'}
- ${1000} | ${''} | ${'€'} | ${'10€'}
- ${1000} | ${''} | ${'$'} | ${'10$'}
- ${'1000'} | ${'€'} | ${''} | ${'€10'}
- ${0} | ${'€'} | ${''} | ${'€0'}
- ${''} | ${'€'} | ${''} | ${''}
- ${null} | ${'€'} | ${''} | ${''}
- ${undefined} | ${'€'} | ${''} | ${''}
+ value | prefix | suffix | expected
+ ${ 1000 } | ${ '€' } | ${ '' } | ${ '€10' }
+ ${ 1000 } | ${ '' } | ${ '€' } | ${ '10€' }
+ ${ 1000 } | ${ '' } | ${ '$' } | ${ '10$' }
+ ${ '1000' } | ${ '€' } | ${ '' } | ${ '€10' }
+ ${ 0 } | ${ '€' } | ${ '' } | ${ '€0' }
+ ${ '' } | ${ '€' } | ${ '' } | ${ '' }
+ ${ null } | ${ '€' } | ${ '' } | ${ '' }
+ ${ undefined } | ${ '€' } | ${ '' } | ${ '' }
`(
'correctly formats price given "$value", "$prefix" prefix, and "$suffix" suffix',
( { value, prefix, suffix, expected } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/blocks/price-filter/edit.js b/plugins/woocommerce-blocks/assets/js/blocks/price-filter/edit.js
index 2b76022a3ad..99b0e4f0785 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/price-filter/edit.js
+++ b/plugins/woocommerce-blocks/assets/js/blocks/price-filter/edit.js
@@ -24,7 +24,7 @@ import { Icon, bill, external } from '@woocommerce/icons';
import Block from './block.js';
import './editor.scss';
-export default function( { attributes, setAttributes } ) {
+export default function ( { attributes, setAttributes } ) {
const {
className,
heading,
diff --git a/plugins/woocommerce-blocks/assets/js/blocks/price-filter/test/use-price-constraints.js b/plugins/woocommerce-blocks/assets/js/blocks/price-filter/test/use-price-constraints.js
index 091a471b14f..66f752ff791 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/price-filter/test/use-price-constraints.js
+++ b/plugins/woocommerce-blocks/assets/js/blocks/price-filter/test/use-price-constraints.js
@@ -22,7 +22,9 @@ describe( 'usePriceConstraints', () => {
};
it( 'max price constraint should be updated when new price is set', () => {
- const renderer = TestRenderer.create( );
+ const renderer = TestRenderer.create(
+
+ );
const container = renderer.root.findByType( 'div' );
expect( container.props.maxPriceConstraint ).toBe( 1000 );
@@ -33,7 +35,9 @@ describe( 'usePriceConstraints', () => {
} );
it( 'min price constraint should be updated when new price is set', () => {
- const renderer = TestRenderer.create( );
+ const renderer = TestRenderer.create(
+
+ );
const container = renderer.root.findByType( 'div' );
expect( container.props.minPriceConstraint ).toBe( 1000 );
@@ -70,9 +74,7 @@ describe( 'usePriceConstraints', () => {
} );
it( 'min price constraint should be lower if the price is decimal', () => {
- const renderer = TestRenderer.create(
-
- );
+ const renderer = TestRenderer.create( );
const container = renderer.root.findByType( 'div' );
expect( container.props.minPriceConstraint ).toBe( 0 );
diff --git a/plugins/woocommerce-blocks/assets/js/data/collections/test/selectors.js b/plugins/woocommerce-blocks/assets/js/data/collections/test/selectors.js
index 3edc4d375ca..bde2a8097ea 100644
--- a/plugins/woocommerce-blocks/assets/js/data/collections/test/selectors.js
+++ b/plugins/woocommerce-blocks/assets/js/data/collections/test/selectors.js
@@ -63,10 +63,10 @@ describe( 'getCollection', () => {
} );
describe( 'returns expected values for items existing in state', () => {
test.each`
- resourceName | ids | query | expected
- ${'products'} | ${[]} | ${{ someQuery: 2 }} | ${[ 'foo' ]}
- ${'products/attributes'} | ${[ 10 ]} | ${{ someQuery: 2 }} | ${[ 'bar' ]}
- ${'products/attributes/terms'} | ${[ 10, 20 ]} | ${{ someQuery: 10 }} | ${[ 42 ]}
+ resourceName | ids | query | expected
+ ${ 'products' } | ${ [] } | ${ { someQuery: 2 } } | ${ [ 'foo' ] }
+ ${ 'products/attributes' } | ${ [ 10 ] } | ${ { someQuery: 2 } } | ${ [ 'bar' ] }
+ ${ 'products/attributes/terms' } | ${ [ 10, 20 ] } | ${ { someQuery: 10 } } | ${ [ 42 ] }
`(
'for "$resourceName", "$ids", and "$query"',
( { resourceName, ids, query, expected } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/data/schema/selectors.js b/plugins/woocommerce-blocks/assets/js/data/schema/selectors.js
index bc6ccf9b29e..6f6fe4754ae 100644
--- a/plugins/woocommerce-blocks/assets/js/data/schema/selectors.js
+++ b/plugins/woocommerce-blocks/assets/js/data/schema/selectors.js
@@ -33,10 +33,9 @@ import { STORE_KEY } from './constants';
*/
export const getRoute = createRegistrySelector(
( select ) => ( state, namespace, resourceName, ids = [] ) => {
- const hasResolved = select( STORE_KEY ).hasFinishedResolution(
- 'getRoutes',
- [ namespace ]
- );
+ const hasResolved = select(
+ STORE_KEY
+ ).hasFinishedResolution( 'getRoutes', [ namespace ] );
state = state.routes;
let error = '';
if ( ! state[ namespace ] ) {
@@ -86,10 +85,9 @@ 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/plugins/woocommerce-blocks/assets/js/data/schema/test/selectors.js b/plugins/woocommerce-blocks/assets/js/data/schema/test/selectors.js
index 63d488fcc86..ded81504bfe 100644
--- a/plugins/woocommerce-blocks/assets/js/data/schema/test/selectors.js
+++ b/plugins/woocommerce-blocks/assets/js/data/schema/test/selectors.js
@@ -62,10 +62,10 @@ describe( 'getRoute', () => {
describe( 'with no throwing of errors if resolution has not finished', () => {
beforeEach( () => mockHasFinishedResolution.mockReturnValue( false ) );
it.each`
- description | args
- ${'is no route for the given namespace'} | ${[ 'invalid' ]}
- ${'are no routes for the given namespace, but no route for the given resource'} | ${[ 'wc/blocks', 'invalid' ]}
- ${'are routes for the given namespace and resource name, but no routes for the given ids'} | ${[ 'wc/blocks', 'products/attributes', [ 10 ] ]}
+ description | args
+ ${ 'is no route for the given namespace' } | ${ [ 'invalid' ] }
+ ${ 'are no routes for the given namespace, but no route for the given resource' } | ${ [ 'wc/blocks', 'invalid' ] }
+ ${ 'are routes for the given namespace and resource name, but no routes for the given ids' } | ${ [ 'wc/blocks', 'products/attributes', [ 10 ] ] }
`( 'does not throw an error if there $description', ( { args } ) => {
expect( invokeTest( ...args ) ).not.toThrowError();
} );
diff --git a/plugins/woocommerce-blocks/assets/js/data/schema/test/utils.js b/plugins/woocommerce-blocks/assets/js/data/schema/test/utils.js
index d783c5b4dac..1529cdb9d1f 100644
--- a/plugins/woocommerce-blocks/assets/js/data/schema/test/utils.js
+++ b/plugins/woocommerce-blocks/assets/js/data/schema/test/utils.js
@@ -9,12 +9,12 @@ import {
describe( 'extractResourceNameFromRoute', () => {
it.each`
- namespace | route | expected
- ${'wc/blocks'} | ${'wc/blocks/products'} | ${'products'}
- ${'wc/other'} | ${'wc/blocks/product'} | ${'wc/blocks/product'}
- ${'wc/blocks'} | ${'wc/blocks/products/attributes/(?P[\\d]+)'} | ${'products/attributes'}
- ${'wc/blocks'} | ${'wc/blocks/products/attributes/(?P[\\d]+)/terms'} | ${'products/attributes/terms'}
- ${'wc/blocks'} | ${'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[d]+)'} | ${'products/attributes/terms'}
+ namespace | route | expected
+ ${ 'wc/blocks' } | ${ 'wc/blocks/products' } | ${ 'products' }
+ ${ 'wc/other' } | ${ 'wc/blocks/product' } | ${ 'wc/blocks/product' }
+ ${ 'wc/blocks' } | ${ 'wc/blocks/products/attributes/(?P[\\d]+)' } | ${ 'products/attributes' }
+ ${ 'wc/blocks' } | ${ 'wc/blocks/products/attributes/(?P[\\d]+)/terms' } | ${ 'products/attributes/terms' }
+ ${ 'wc/blocks' } | ${ 'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[d]+)' } | ${ 'products/attributes/terms' }
`(
'returns "$expected" when namespace is "$namespace" and route is "$route"',
( { namespace, route, expected } ) => {
@@ -27,10 +27,10 @@ describe( 'extractResourceNameFromRoute', () => {
describe( 'getRouteIds', () => {
it.each`
- route | expected
- ${'wc/blocks/products'} | ${[]}
- ${'wc/blocks/products/(?P[\\d]+)'} | ${[ 'id' ]}
- ${'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)'} | ${[ 'attribute_id', 'id' ]}
+ route | expected
+ ${ 'wc/blocks/products' } | ${ [] }
+ ${ 'wc/blocks/products/(?P[\\d]+)' } | ${ [ 'id' ] }
+ ${ 'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)' } | ${ [ 'attribute_id', 'id' ] }
`(
'returns "$expected" when route is "$route"',
( { route, expected } ) => {
@@ -41,12 +41,12 @@ describe( 'getRouteIds', () => {
describe( 'simplifyRouteWithId', () => {
it.each`
- route | matchIds | expected
- ${'wc/blocks/products'} | ${[]} | ${'wc/blocks/products'}
- ${'wc/blocks/products/attributes/(?P[\\d]+)'} | ${[ 'attribute_id' ]} | ${'wc/blocks/products/attributes/{attribute_id}'}
- ${'wc/blocks/products/attributes/(?P[\\d]+)/terms'} | ${[ 'attribute_id' ]} | ${'wc/blocks/products/attributes/{attribute_id}/terms'}
- ${'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)'} | ${[ 'attribute_id', 'id' ]} | ${'wc/blocks/products/attributes/{attribute_id}/terms/{id}'}
- ${'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)'} | ${[ 'id', 'attribute_id' ]} | ${'wc/blocks/products/attributes/{attribute_id}/terms/{id}'}
+ route | matchIds | expected
+ ${ 'wc/blocks/products' } | ${ [] } | ${ 'wc/blocks/products' }
+ ${ 'wc/blocks/products/attributes/(?P[\\d]+)' } | ${ [ 'attribute_id' ] } | ${ 'wc/blocks/products/attributes/{attribute_id}' }
+ ${ 'wc/blocks/products/attributes/(?P[\\d]+)/terms' } | ${ [ 'attribute_id' ] } | ${ 'wc/blocks/products/attributes/{attribute_id}/terms' }
+ ${ 'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)' } | ${ [ 'attribute_id', 'id' ] } | ${ 'wc/blocks/products/attributes/{attribute_id}/terms/{id}' }
+ ${ 'wc/blocks/products/attributes/(?P[\\d]+)/terms/(?P[\\d]+)' } | ${ [ 'id', 'attribute_id' ] } | ${ 'wc/blocks/products/attributes/{attribute_id}/terms/{id}' }
`(
'returns "$expected" when route is "$route" and matchIds is "$matchIds"',
( { route, matchIds, expected } ) => {
diff --git a/plugins/woocommerce-blocks/assets/js/editor-components/toggle-button-control/index.js b/plugins/woocommerce-blocks/assets/js/editor-components/toggle-button-control/index.js
index 2bca473c812..50e23688105 100644
--- a/plugins/woocommerce-blocks/assets/js/editor-components/toggle-button-control/index.js
+++ b/plugins/woocommerce-blocks/assets/js/editor-components/toggle-button-control/index.js
@@ -74,9 +74,7 @@ class ToggleButtonControl extends Component {
return (