Fix ESLint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7556)
* Add type to imports that need it * Add type to imports that need it * Fix the sanitize lint error * Include missing dep * Remove check from deps * bot: update checkstyle.xml Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
a79bfba32c
commit
6ca9f90c44
|
@ -5,7 +5,7 @@
|
||||||
"/**",
|
"/**",
|
||||||
" * External dependencies",
|
" * External dependencies",
|
||||||
" */",
|
" */",
|
||||||
"import { Story, Meta } from '@storybook/react';",
|
"import type { Story, Meta } from '@storybook/react';",
|
||||||
"",
|
"",
|
||||||
"/**",
|
"/**",
|
||||||
" * Internal dependencies",
|
" * Internal dependencies",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { useBlockProps } from '@wordpress/block-editor';
|
import { useBlockProps } from '@wordpress/block-editor';
|
||||||
import { BlockEditProps } from '@wordpress/blocks';
|
import type { BlockEditProps } from '@wordpress/blocks';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { useArgs } from '@storybook/client-api';
|
import { useArgs } from '@storybook/client-api';
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { INTERACTION_TIMEOUT } from '@woocommerce/storybook-controls';
|
import { INTERACTION_TIMEOUT } from '@woocommerce/storybook-controls';
|
||||||
import { useDispatch } from '@wordpress/data';
|
import { useDispatch } from '@wordpress/data';
|
||||||
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { useArgs } from '@storybook/client-api';
|
import { useArgs } from '@storybook/client-api';
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import {
|
import {
|
||||||
currenciesAPIShape as currencies,
|
currenciesAPIShape as currencies,
|
||||||
currencyControl,
|
currencyControl,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { allSettings } from '@woocommerce/settings';
|
import { allSettings } from '@woocommerce/settings';
|
||||||
import { Currency } from '@woocommerce/types';
|
import { Currency } from '@woocommerce/types';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { useDispatch } from '@wordpress/data';
|
import { useDispatch } from '@wordpress/data';
|
||||||
import { useState, useEffect } from '@wordpress/element';
|
import { useState, useEffect } from '@wordpress/element';
|
||||||
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { useState } from '@wordpress/element';
|
import { useState } from '@wordpress/element';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { useState } from '@wordpress/element';
|
import { useState } from '@wordpress/element';
|
||||||
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { currencyControl } from '@woocommerce/storybook-controls';
|
import { currencyControl } from '@woocommerce/storybook-controls';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { useArgs } from '@storybook/client-api';
|
import { useArgs } from '@storybook/client-api';
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
||||||
import { BlockEditProps } from '@wordpress/blocks';
|
import type { BlockEditProps } from '@wordpress/blocks';
|
||||||
import BlockTitle from '@woocommerce/editor-components/block-title';
|
import BlockTitle from '@woocommerce/editor-components/block-title';
|
||||||
import {
|
import {
|
||||||
Disabled,
|
Disabled,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import { InspectorControls } from '@wordpress/block-editor';
|
import { InspectorControls } from '@wordpress/block-editor';
|
||||||
import { PanelBody, ToggleControl } from '@wordpress/components';
|
import { PanelBody, ToggleControl } from '@wordpress/components';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { BlockAttributes } from '@wordpress/blocks';
|
import type { BlockAttributes } from '@wordpress/blocks';
|
||||||
|
|
||||||
export const BlockSettings = ( {
|
export const BlockSettings = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -69,7 +69,12 @@ const Block = ( {
|
||||||
setBillingAddress( shippingAddress );
|
setBillingAddress( shippingAddress );
|
||||||
}
|
}
|
||||||
setAddressesSynced( true );
|
setAddressesSynced( true );
|
||||||
}, [ setBillingAddress, shippingAddress, useShippingAsBilling ] );
|
}, [
|
||||||
|
addressesSynced,
|
||||||
|
setBillingAddress,
|
||||||
|
shippingAddress,
|
||||||
|
useShippingAsBilling,
|
||||||
|
] );
|
||||||
|
|
||||||
const addressFieldsConfig = useMemo( () => {
|
const addressFieldsConfig = useMemo( () => {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
BlockEditProps,
|
|
||||||
createBlock,
|
createBlock,
|
||||||
getBlockType,
|
getBlockType,
|
||||||
registerBlockType,
|
registerBlockType,
|
||||||
unregisterBlockType,
|
unregisterBlockType,
|
||||||
} from '@wordpress/blocks';
|
} from '@wordpress/blocks';
|
||||||
|
import type { BlockEditProps } from '@wordpress/blocks';
|
||||||
import {
|
import {
|
||||||
isExperimentalBuild,
|
isExperimentalBuild,
|
||||||
WC_BLOCKS_IMAGE_URL,
|
WC_BLOCKS_IMAGE_URL,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Block } from '@wordpress/blocks';
|
import type { Block } from '@wordpress/blocks';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { BlockAlignment } from '@wordpress/blocks';
|
import type { BlockAlignment } from '@wordpress/blocks';
|
||||||
|
|
||||||
export interface Attributes {
|
export interface Attributes {
|
||||||
align?: BlockAlignment;
|
align?: BlockAlignment;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Block } from '@wordpress/blocks';
|
import type { Block } from '@wordpress/blocks';
|
||||||
import { addFilter } from '@wordpress/hooks';
|
import { addFilter } from '@wordpress/hooks';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { BlockAlignment } from '@wordpress/blocks';
|
import type { BlockAlignment } from '@wordpress/blocks';
|
||||||
|
|
||||||
export interface Attributes {
|
export interface Attributes {
|
||||||
align?: BlockAlignment;
|
align?: BlockAlignment;
|
||||||
|
|
|
@ -232,12 +232,7 @@ const StockStatusFilterBlock = ( {
|
||||||
|
|
||||||
updateFilterUrl( checkedOptions );
|
updateFilterUrl( checkedOptions );
|
||||||
},
|
},
|
||||||
[
|
[ isEditor, setProductStockStatusQuery, filteringForPhpTemplate ]
|
||||||
isEditor,
|
|
||||||
setProductStockStatusQuery,
|
|
||||||
checked,
|
|
||||||
filteringForPhpTemplate,
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Track checked STATE changes - if state changes, update the query.
|
// Track checked STATE changes - if state changes, update the query.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { useArgs } from '@storybook/client-api';
|
import { useArgs } from '@storybook/client-api';
|
||||||
import { INTERACTION_TIMEOUT } from '@woocommerce/storybook-controls';
|
import { INTERACTION_TIMEOUT } from '@woocommerce/storybook-controls';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { omitBy } from 'lodash';
|
import { omitBy } from 'lodash';
|
||||||
import { Story } from '@storybook/react';
|
import type { Story } from '@storybook/react';
|
||||||
import { useState } from '@wordpress/element';
|
import { useState } from '@wordpress/element';
|
||||||
import { Icon } from '@wordpress/icons';
|
import { Icon } from '@wordpress/icons';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { sanitize } from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
|
||||||
const ALLOWED_TAGS = [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ];
|
const ALLOWED_TAGS = [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ];
|
||||||
const ALLOWED_ATTR = [ 'target', 'href', 'rel', 'name', 'download' ];
|
const ALLOWED_ATTR = [ 'target', 'href', 'rel', 'name', 'download' ];
|
||||||
|
@ -13,7 +13,7 @@ export const sanitizeHTML = (
|
||||||
const tagsValue = config?.tags || ALLOWED_TAGS;
|
const tagsValue = config?.tags || ALLOWED_TAGS;
|
||||||
const attrValue = config?.attr || ALLOWED_ATTR;
|
const attrValue = config?.attr || ALLOWED_ATTR;
|
||||||
|
|
||||||
return sanitize( html, {
|
return DOMPurify.sanitize( html, {
|
||||||
ALLOWED_TAGS: tagsValue,
|
ALLOWED_TAGS: tagsValue,
|
||||||
ALLOWED_ATTR: attrValue,
|
ALLOWED_ATTR: attrValue,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import {
|
import {
|
||||||
currenciesAPIShape,
|
currenciesAPIShape,
|
||||||
currencies,
|
currencies,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,7 +38,7 @@ Let's see the code in detail.
|
||||||
This is the minimal scaffold you need for your new Story:
|
This is the minimal scaffold you need for your new Story:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { Story, Meta } from '@storybook/react';
|
import type { Story, Meta } from '@storybook/react';
|
||||||
import MyComponent, { MyComponentProps } from '..';
|
import MyComponent, { MyComponentProps } from '..';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
Loading…
Reference in New Issue