Skip to content

Commit

Permalink
refactor: add prefer-ts-expect-error rule (#1608)
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork authored May 23, 2024
1 parent 9b8f4f8 commit 27b62e1
Showing 8 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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": [
2 changes: 1 addition & 1 deletion src/components/Disclosure/Disclosure.tsx
Original file line number Diff line number Diff line change
@@ -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<DisclosureProps> & DisclosureComposition =
React.forwardRef<HTMLDivElement, DisclosureProps>(function Disclosure(props, ref) {
const {
Original file line number Diff line number Diff line change
@@ -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', () => {
Original file line number Diff line number Diff line change
@@ -272,7 +272,7 @@ export function withTableActions<I extends TableDataItem, E extends {} = {}>(

return (item: I, index: number, event: React.MouseEvent<HTMLTableRowElement>) => {
if (
// @ts-ignore
// @ts-expect-error
event.nativeEvent.target.matches(
`.${actionsButtonCn}, .${actionsButtonCn} *`,
)
2 changes: 1 addition & 1 deletion src/components/Table/hoc/withTableCopy/withTableCopy.tsx
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ export function withTableCopy<I extends TableDataItem, E extends {} = {}>(
return (item: I, index: number, event: React.MouseEvent<HTMLTableRowElement>) => {
const buttonClassName = b('copy-button');
if (
// @ts-ignore
// @ts-expect-error
event.nativeEvent.target.matches(
`.${buttonClassName}, .${buttonClassName} *`,
)
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ export function withTableSelection<I extends TableDataItem, E extends {} = {}>(
event: React.ChangeEvent<HTMLInputElement>,
) => {
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<I extends TableDataItem, E extends {} = {}>(
return (item: I, index: number, event: React.MouseEvent<HTMLTableRowElement>) => {
const checkboxClassName = b('selection-checkbox');
if (
// @ts-ignore
// @ts-expect-error
event.nativeEvent.target.matches(
`.${checkboxClassName}, .${checkboxClassName} *`,
)
2 changes: 1 addition & 1 deletion src/components/layout/demo/ColPresenter/ColPresenter.tsx
Original file line number Diff line number Diff line change
@@ -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 = <T extends {}>({l, xl, s, m, xxl, xxxl, size}: T = {}): string => {
// skip empty values
return Object.entries({...{l, xl, s, m, xxl, xxxl, size}})
2 changes: 1 addition & 1 deletion test-utils/setup-tests.ts
Original file line number Diff line number Diff line change
@@ -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}),
);

0 comments on commit 27b62e1

Please sign in to comment.