Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add prefer-ts-expect-error rule #1608

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/components/Disclosure/Disclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} *`,
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/hoc/withTableCopy/withTableCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} *`,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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} *`,
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/demo/ColPresenter/ColPresenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
Expand Down
2 changes: 1 addition & 1 deletion test-utils/setup-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
);
Loading