diff --git a/.eslintrc b/.eslintrc index 2f52429610..f11af1b6e1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -30,6 +30,7 @@ "jsx-a11y/no-autofocus": "off", "import/no-extraneous-dependencies": "off", "import/consistent-type-specifier-style": ["error", "prefer-top-level"], + "@typescript-eslint/prefer-ts-expect-error": "error", "@typescript-eslint/consistent-type-imports": ["error", {"prefer": "type-imports", "fixStyle": "separate-type-imports"}] }, "overrides": [ diff --git a/src/components/Disclosure/Disclosure.tsx b/src/components/Disclosure/Disclosure.tsx index 1d4a074b62..7353f0513f 100644 --- a/src/components/Disclosure/Disclosure.tsx +++ b/src/components/Disclosure/Disclosure.tsx @@ -42,7 +42,7 @@ export interface DisclosureProps extends QAProps { const isDisclosureSummaryComponent = isOfType(DisclosureSummary); -// @ts-ignore this ts-error is appears when forwarding ref. It complains that DisclosureComposition props is not provided initially +// @ts-expect-error this ts-error is appears when forwarding ref. It complains that DisclosureComposition props is not provided initially export const Disclosure: React.FunctionComponent & DisclosureComposition = React.forwardRef(function Disclosure(props, ref) { const { diff --git a/src/components/Table/__tests__/Table.withTableSettings.test.tsx b/src/components/Table/__tests__/Table.withTableSettings.test.tsx index 1e0f453d9e..9b84eea2b4 100644 --- a/src/components/Table/__tests__/Table.withTableSettings.test.tsx +++ b/src/components/Table/__tests__/Table.withTableSettings.test.tsx @@ -149,10 +149,8 @@ describe('withTableSettings', () => { ); expect(osSettings).toBeDefined(); expect(osxSettings).toBeDefined(); - // @ts-ignore - expect(osSettings.isSelected).toBe(true); - // @ts-ignore - expect(osxSettings.isSelected).toBe(false); + expect(osSettings?.isSelected).toBe(true); + expect(osxSettings?.isSelected).toBe(false); }); it('should return columns when no settings provided', () => { diff --git a/src/components/Table/hoc/withTableActions/withTableActions.tsx b/src/components/Table/hoc/withTableActions/withTableActions.tsx index cdb2f3145b..50e342e056 100644 --- a/src/components/Table/hoc/withTableActions/withTableActions.tsx +++ b/src/components/Table/hoc/withTableActions/withTableActions.tsx @@ -272,7 +272,7 @@ export function withTableActions( return (item: I, index: number, event: React.MouseEvent) => { if ( - // @ts-ignore + // @ts-expect-error event.nativeEvent.target.matches( `.${actionsButtonCn}, .${actionsButtonCn} *`, ) diff --git a/src/components/Table/hoc/withTableCopy/withTableCopy.tsx b/src/components/Table/hoc/withTableCopy/withTableCopy.tsx index 966f009928..b9efad1f2e 100644 --- a/src/components/Table/hoc/withTableCopy/withTableCopy.tsx +++ b/src/components/Table/hoc/withTableCopy/withTableCopy.tsx @@ -104,7 +104,7 @@ export function withTableCopy( return (item: I, index: number, event: React.MouseEvent) => { const buttonClassName = b('copy-button'); if ( - // @ts-ignore + // @ts-expect-error event.nativeEvent.target.matches( `.${buttonClassName}, .${buttonClassName} *`, ) diff --git a/src/components/Table/hoc/withTableSelection/withTableSelection.tsx b/src/components/Table/hoc/withTableSelection/withTableSelection.tsx index cfa4c89b30..497de15a6f 100644 --- a/src/components/Table/hoc/withTableSelection/withTableSelection.tsx +++ b/src/components/Table/hoc/withTableSelection/withTableSelection.tsx @@ -120,7 +120,7 @@ export function withTableSelection( event: React.ChangeEvent, ) => { const {checked} = event.target; - // @ts-ignore shiftKey is defined for click events + // @ts-expect-error shiftKey is defined for click events const isShiftPressed = event.nativeEvent.shiftKey; const {data, selectedIds, onSelectionChange} = this.props; @@ -191,7 +191,7 @@ export function withTableSelection( return (item: I, index: number, event: React.MouseEvent) => { const checkboxClassName = b('selection-checkbox'); if ( - // @ts-ignore + // @ts-expect-error event.nativeEvent.target.matches( `.${checkboxClassName}, .${checkboxClassName} *`, ) diff --git a/src/components/layout/demo/ColPresenter/ColPresenter.tsx b/src/components/layout/demo/ColPresenter/ColPresenter.tsx index c203cf7265..d77a5f2bbc 100644 --- a/src/components/layout/demo/ColPresenter/ColPresenter.tsx +++ b/src/components/layout/demo/ColPresenter/ColPresenter.tsx @@ -4,7 +4,7 @@ import {Col} from '../../Col/Col'; import type {ColProps} from '../../Col/Col'; import {Box} from '../Box/Box'; -// @ts-ignore-error +// @ts-expect-error const pickSizeProps = ({l, xl, s, m, xxl, xxxl, size}: T = {}): string => { // skip empty values return Object.entries({...{l, xl, s, m, xxl, xxxl, size}}) diff --git a/test-utils/setup-tests.ts b/test-utils/setup-tests.ts index 2d03f72af0..374470e6e5 100644 --- a/test-utils/setup-tests.ts +++ b/test-utils/setup-tests.ts @@ -20,7 +20,7 @@ global.ResizeObserver = class implements ResizeObserver { jest.mock( 'react-virtualized-auto-sizer', () => - //@ts-ignore + //@ts-expect-error ({children}) => children({height: 400, width: 400}), );