Skip to content

Commit

Permalink
update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
inker committed Sep 23, 2024
1 parent 93ffcfb commit be5a4a3
Show file tree
Hide file tree
Showing 19 changed files with 5,576 additions and 2,546 deletions.
8,041 changes: 5,533 additions & 2,508 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"dependencies": {
"bowser": "^2.11.0",
"date-fns": "^3.0.5",
"date-fns": "^4.1.0",
"delay.js": "^2.0.1",
"dom-to-image": "^2.6.0",
"fast-delete": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export default ({
}: Parameters<Func>[0] & {
worker: Worker;
}) => {
const invoke = workerSendAndReceive<Parameters<Func>[0], ReturnType<Func>>(
worker,
);
const invoke = workerSendAndReceive<ReturnType<Func>>(worker);
return invoke(options);
};
2 changes: 2 additions & 0 deletions src/engine/predicates/wc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export default (year: number, teams: readonly Team[]): Predicate<Team> => {
const teamsPerGroup = v / numGroups;
return [Math.floor(teamsPerGroup), Math.ceil(teamsPerGroup)] as const;
});

type Pair = [Confederation, readonly [number, number]];

const confMinMaxEntries = Object.entries(confMinMax) as readonly Pair[];

return (picked, groups, groupIndex) => {
Expand Down
1 change: 0 additions & 1 deletion src/model/team/GsTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Club from './Club';

export default class GsTeam extends Club {
readonly coefficient: number;
// eslint-disable-next-line no-use-before-define
pairing?: GsTeam;

// eslint-disable-next-line max-params
Expand Down
1 change: 1 addition & 0 deletions src/model/team/KnockoutTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Club from './Club';
export default class KnockoutTeam extends Club {
readonly group: number;

// eslint-disable-next-line max-params
constructor(
name: string,
country: UefaCountry,
Expand Down
1 change: 1 addition & 0 deletions src/model/team/NationalTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class NationalTeam extends Team {
readonly confederation: Confederation;
readonly host: boolean;

// eslint-disable-next-line max-params
constructor(
name: string,
coefficient: number,
Expand Down
15 changes: 9 additions & 6 deletions src/routes/Pages/getPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export default async (tournament: Tournament, stage: Stage) => {
// TODO
const tournamentDir = tournament === 'ecl' ? 'el' : tournament;

return import(
/* webpackChunkName: "[request]" */
`../../pages/${tournamentDir}/${stage}`
)
.then(mod => mod?.default)
.catch(console.error);
try {
const mod = await import(
/* webpackChunkName: "[request]" */
`../../pages/${tournamentDir}/${stage}`
);
return mod?.default;
} catch (err) {
console.error(err);
}
};
6 changes: 4 additions & 2 deletions src/store/utils/syncStorageWithThemeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type atomWithStorage } from 'jotai/utils';
import { noop } from 'lodash';

type Storage<T> = NonNullable<Parameters<typeof atomWithStorage<T>>[2]>;

Expand All @@ -23,14 +24,15 @@ export default <T>({ validate }: Options) =>
if (e.storageArea === localStorage && e.key === key) {
const { newValue } = e;
if (validate(newValue)) {
return callback(newValue as T);
callback(newValue as T);
return;
}
if (newValue !== null) {
localStorage.removeItem(key);
}
callback(initialValue);
}
});
return () => {};
return noop;
},
}) satisfies Storage<T>;
14 changes: 6 additions & 8 deletions src/ui/Announcement/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,12 @@ function Download({ completed, groupsElement }: Props) {
}
}, [completed]);

const onDownloadPngClick = useCallback(
() => setDownloadClicked('png'),
[setDownloadClicked],
);
const onDownloadSvgClick = useCallback(
() => setDownloadClicked('svg'),
[setDownloadClicked],
);
const onDownloadPngClick = useCallback(() => {
setDownloadClicked('png');
}, [setDownloadClicked]);
const onDownloadSvgClick = useCallback(() => {
setDownloadClicked('svg');
}, [setDownloadClicked]);

return completed && !!groupsElement ? (
<div>
Expand Down
7 changes: 3 additions & 4 deletions src/ui/GroupsContainer/GroupCellDeferred.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ function GroupCellDeferred({ team, possible }: Props) {
const themeContext = useContext(ThemeContext);
const destinationRef = useRef<HTMLElement | null>(null);

const setIsPickedAnimationFalse = useCallback(
() => setIsPickedAnimation(false),
[],
);
const setIsPickedAnimationFalse = useCallback(() => {
setIsPickedAnimation(false);
}, []);

const fill = useCallback(() => {
setDisplayedTeam(team);
Expand Down
7 changes: 3 additions & 4 deletions src/ui/MatchupsContainer/MatchupCellDeferred.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ function MatchupCellDeferred({ team }: Props) {
const themeContext = useContext(ThemeContext);
const destinationRef = useRef<HTMLElement | null>(null);

const setIsPickedAnimationFalse = useCallback(
() => setIsPickedAnimation(false),
[],
);
const setIsPickedAnimationFalse = useCallback(() => {
setIsPickedAnimation(false);
}, []);

const fill = useCallback(() => {
setDisplayedTeam(team);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/PotsContainer/Pot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Pot({
const offset = i * numCols;
const rowTeams = Array.from(
{ length: numCols },
// eslint-disable-next-line @typescript-eslint/no-shadow, no-shadow
// eslint-disable-next-line @typescript-eslint/no-shadow
(_, c) => teams[offset + c],
);

Expand Down
3 changes: 2 additions & 1 deletion src/utils/hooks/useGlobalEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { useEffect } from 'react';
export default <K extends keyof WindowEventMap>(
type: K,
listener: (e: WindowEventMap[K]) => void,
) =>
) => {
useEffect(() => {
window.addEventListener(type, listener);
return () => {
window.removeEventListener(type, listener);
};
}, [type, listener]);
};
4 changes: 2 additions & 2 deletions src/utils/hooks/useWorkerSendAndReceive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useCallback } from 'react';
import useWorker from '#utils/hooks/useWorker';
import workerSendAndReceive from '#utils/worker/sendAndReceive';

export default <Request, Response>(getWorker: () => Worker) => {
export default (getWorker: () => Worker) => {
const worker = useWorker(getWorker);

// eslint-disable-next-line react-hooks/exhaustive-deps
return useCallback(workerSendAndReceive<Request, Response>(worker), [worker]);
return useCallback(workerSendAndReceive<any>(worker), [worker]);
};
1 change: 1 addition & 0 deletions src/utils/makeStyleClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default (strings: TemplateStringsArray, ...keys: readonly any[]) => {
}
const className = getRandomId('styled-element-');
const content = template(strings, ...keys);
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
styleElement.textContent += `.${className}{${content}}`;
return className;
};
4 changes: 2 additions & 2 deletions src/utils/raceWorkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export default async <Func extends (...args: any) => void>({
workers[workerIndex] = worker;
// eslint-disable-next-line no-await-in-loop
const raceResult = await Promise.race([
workerSendAndReceive<Parameters<Func>[0], ReturnType<Func>>(worker)(
workerSendAndReceive<ReturnType<Func>>(worker)(
getPayload(workerIndex, attempt),
).catch(err => {
).catch((err: unknown) => {
console.error(err);
}),
delay(getTimeout(workerIndex, attempt)),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/worker/expose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type MessageFromWorker,
} from './constants';

export default <F extends (arg: any) => any>(func: F) => {
export default (func: (arg: any) => any) => {
// eslint-disable-next-line no-restricted-globals
addEventListener('message', (e: MessageEvent) => {
const {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/worker/sendAndReceive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
type MessageFromWorker,
} from './constants';

export default <Request, Response>(worker: Worker) => {
export default <Response>(worker: Worker) => {
type Callback = (response: Response) => void;

const callbacks = new Map<string, Callback>();

worker.addEventListener(
Expand All @@ -24,7 +25,7 @@ export default <Request, Response>(worker: Worker) => {
},
);

return (message: Request) =>
return (message: unknown) =>
new Promise<Response>(resolve => {
const id = globalThis.crypto.randomUUID();
callbacks.set(id, resolve);
Expand Down

0 comments on commit be5a4a3

Please sign in to comment.