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: resolve all eslint warning #2097

Merged
merged 2 commits into from
Mar 8, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/hooks/src/useFusionTable/fusionAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const resultAdapter = (result: any) => {
},
);
},
onFilter: (filterParams: Object) => {
onFilter: (filterParams: Record<string, any>) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onFilter: (filterParams: Record<string, any>) => {
onFilter: (filterParams: Record<PropertyKey, any>) => {

result.tableProps.onChange(
{ current: result.pagination.current, pageSize: result.pagination.pageSize },
filterParams,
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useFusionTable/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AntdTableOptions, AntdTableResult, Data, Params } from '../useAntdTable/types';

export interface Field {
getFieldInstance?: (name: string) => {};
getFieldInstance?: (name: string) => Record<string, any>;
setValues: (value: Record<string, any>) => void;
getValues: (...args: any) => Record<string, any>;
reset: (...args: any) => void;
Expand Down
9 changes: 2 additions & 7 deletions packages/hooks/src/useKeyPress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const aliasKeyCodeMap = {
z: 90,
leftwindowkey: 91,
rightwindowkey: 92,
meta: isAppleDevice ? [91, 93] : [91, 92],
selectkey: 93,
numpad0: 96,
numpad1: 97,
Expand Down Expand Up @@ -123,20 +124,14 @@ const aliasKeyCodeMap = {
singlequote: 222,
};

if (isAppleDevice) {
aliasKeyCodeMap['meta'] = [91, 93];
} else {
aliasKeyCodeMap['meta'] = [91, 92];
}

// 修饰键
const modifierKey = {
ctrl: (event: KeyboardEvent) => event.ctrlKey,
shift: (event: KeyboardEvent) => event.shiftKey,
alt: (event: KeyboardEvent) => event.altKey,
meta: (event: KeyboardEvent) => {
if (event.type === 'keyup') {
return aliasKeyCodeMap['meta'].includes(event.keyCode);
return aliasKeyCodeMap.meta.includes(event.keyCode);
}
return event.metaKey;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useRef } from 'react';
import type { Plugin, Timeout } from '../types';
import { isBoolean } from '../../../utils';

const useLoadingDelayPlugin: Plugin<any, any[]> = (fetchInstance, { loadingDelay, ready }) => {
const timerRef = useRef<Timeout>();
Expand Down
3 changes: 2 additions & 1 deletion packages/hooks/src/useVirtualList/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useMemo, useState, useRef, CSSProperties } from 'react';
import { useEffect, useMemo, useState, useRef } from 'react';
import type { CSSProperties } from 'react';
import useEventListener from '../useEventListener';
import useLatest from '../useLatest';
import useMemoizedFn from '../useMemoizedFn';
Expand Down
3 changes: 2 additions & 1 deletion packages/hooks/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const isObject = (value: unknown): value is Record<any, any> =>
value !== null && typeof value === 'object';
export const isFunction = (value: unknown): value is Function => typeof value === 'function';
export const isFunction = (value: unknown): value is (...args: any) => any =>
typeof value === 'function';

export const isString = (value: unknown): value is string => typeof value === 'string';
export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';
Expand Down