Fix most of lint warnings (#50869)
* Fix number of lint warnings * Add changelog * Improve mocking value * Fix exports * Fix mock * Bring back the empty array hook dependency
This commit is contained in:
parent
257762b564
commit
2f68f9265b
|
@ -104,22 +104,20 @@ const { state } = store< Store >( 'woocommerce/product-button', {
|
|||
},
|
||||
get addToCartText(): string {
|
||||
const context = getContext();
|
||||
const inTheCartText = state.inTheCartText || '';
|
||||
// We use the temporary number of items when there's no animation, or the
|
||||
// second part of the animation hasn't started.
|
||||
if (
|
||||
const showTemporaryNumber =
|
||||
context.animationStatus === AnimationStatus.IDLE ||
|
||||
context.animationStatus === AnimationStatus.SLIDE_OUT
|
||||
) {
|
||||
return getButtonText(
|
||||
context.addToCartText,
|
||||
state.inTheCartText!,
|
||||
context.temporaryNumberOfItems
|
||||
);
|
||||
}
|
||||
context.animationStatus === AnimationStatus.SLIDE_OUT;
|
||||
const numberOfItems = showTemporaryNumber
|
||||
? context.temporaryNumberOfItems
|
||||
: state.numberOfItemsInTheCart;
|
||||
|
||||
return getButtonText(
|
||||
context.addToCartText,
|
||||
state.inTheCartText!,
|
||||
state.numberOfItemsInTheCart
|
||||
inTheCartText,
|
||||
numberOfItems
|
||||
);
|
||||
},
|
||||
get displayViewCart(): boolean {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
export * from './block-error-boundary';
|
||||
export { default as BlockErrorBoundary } from './block-error-boundary';
|
||||
export * from './button';
|
||||
export * from './cart-checkout';
|
||||
export * from './combobox';
|
||||
export * from './country-input';
|
||||
export * from './drawer';
|
||||
export * from './filter-element-label';
|
||||
export * from './filter-placeholder';
|
||||
export * from './filter-reset-button';
|
||||
export * from './filter-submit-button';
|
||||
export * from './form';
|
||||
export { default as FilterElementLabel } from './filter-element-label';
|
||||
export { default as FilterPlaceholder } from './filter-placeholder';
|
||||
export { default as FilterResetButton } from './filter-reset-button';
|
||||
export { default as FilterSubmitButton } from './filter-submit-button';
|
||||
export { default as FormComponent } from './form';
|
||||
export * from './form-token-field';
|
||||
export * from './load-more-button';
|
||||
export * from './loading-mask';
|
||||
export * from './noninteractive';
|
||||
export { default as LoadingMask } from './loading-mask';
|
||||
export { default as Noninteractive } from './noninteractive';
|
||||
export * from './notice-banner';
|
||||
export * from './pagination';
|
||||
export { default as Pagination } from './pagination';
|
||||
export * from './price-slider';
|
||||
export * from './product-list';
|
||||
export * from './product-name';
|
||||
|
|
|
@ -115,6 +115,7 @@ export const useCollection = < T >(
|
|||
currentResourceValues,
|
||||
currentQuery,
|
||||
shouldSelect,
|
||||
throwError,
|
||||
]
|
||||
);
|
||||
// if selector was not bailed, then update current results. Otherwise return
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
CartShippingRate,
|
||||
CartShippingPackageShippingRate,
|
||||
} from '@woocommerce/type-defs/cart';
|
||||
import * as blockSettings from '@woocommerce/block-settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -38,6 +37,7 @@ jest.mock( '@woocommerce/block-settings', () => ( {
|
|||
...jest.requireActual( '@woocommerce/block-settings' ),
|
||||
LOCAL_PICKUP_ENABLED: true,
|
||||
} ) );
|
||||
const blockSettingsMock = jest.requireMock( '@woocommerce/block-settings' );
|
||||
|
||||
// Returns a rate object with the given values
|
||||
const generateRate = (
|
||||
|
@ -133,8 +133,7 @@ describe( 'isPackageRateCollectable', () => {
|
|||
expect( hasCollectableRate( ratesToTest2 ) ).toBe( false );
|
||||
} );
|
||||
it( 'returns false for all rates if local pickup is disabled', () => {
|
||||
// Attempt to assign to const or readonly variable error on next line is OK because it is mocked by jest
|
||||
blockSettings.LOCAL_PICKUP_ENABLED = false;
|
||||
blockSettingsMock.LOCAL_PICKUP_ENABLED = false;
|
||||
const ratesToTest = [ 'flat_rate', 'local_pickup' ];
|
||||
expect( hasCollectableRate( ratesToTest ) ).toBe( false );
|
||||
} );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export * from './attributes';
|
||||
export { default as attributes } from './attributes';
|
||||
export * from './form-step-block';
|
||||
export * from './form-step-heading';
|
||||
export { default as FormStepHeading } from './form-step-heading';
|
||||
export * from './additional-fields';
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
/**
|
||||
* External dependencies
|
||||
|
|
|
@ -18,7 +18,7 @@ export const getValidationError = ( state: State, errorId: string ) =>
|
|||
*
|
||||
* @param { State } state The current state.
|
||||
* @param { string } errorId The error ID.
|
||||
* @return { string } The validation error ID.
|
||||
* @return { string | undefined } The validation error ID.
|
||||
*/
|
||||
export const getValidationErrorId = ( state: State, errorId: string ) => {
|
||||
if ( ! state.hasOwnProperty( errorId ) || state[ errorId ].hidden ) {
|
||||
|
|
|
@ -78,7 +78,7 @@ export const SearchListItem = < T extends object = object >( {
|
|||
if ( hasChildren && isSelected ) {
|
||||
setExpandedPanelId( item.id as number );
|
||||
}
|
||||
}, [ item, hasChildren, isSelected ] );
|
||||
}, [ item, hasChildren, isSelected, setExpandedPanelId ] );
|
||||
|
||||
const name = props.name || `search-list-item-${ controlId }`;
|
||||
const id = `${ name }-${ item.id }`;
|
||||
|
|
|
@ -57,8 +57,8 @@ class FlakyTestsReporter implements Reporter {
|
|||
this.failingTestCaseResults.set( testTitle, [] );
|
||||
}
|
||||
this.failingTestCaseResults
|
||||
.get( testTitle )!
|
||||
.push( formatTestResult( testCaseResult ) );
|
||||
.get( testTitle )
|
||||
?.push( formatTestResult( testCaseResult ) );
|
||||
break;
|
||||
}
|
||||
case 'flaky': {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
Fix eslint warnings
|
Loading…
Reference in New Issue