Skip to content

Commit

Permalink
Add eslint to lint:typescript; fix final warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed Jan 8, 2025
1 parent a64be55 commit 8926ad7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"scripts": {
"trust-localhost": "./script/trust-localhost.bash",
"lint": "npm run-script lint:bash && npm run-script lint:css && npm run-script lint:typescript",
"lint:typescript": "tslint -p ./tsconfig.json && tsc",
"lint:typescript": "eslint src && tslint -p ./tsconfig.json && tsc",
"lint:exports": "ts-unused-exports ./tsconfig.json",
"lint:css": "stylelint 'src/**/*.tsx'",
"lint:bash": "shellcheck $(find . -type f \\( -iname '*\\.sh' -or -iname '*\\.bash' \\) | grep -v 'node_modules' )",
Expand Down
2 changes: 2 additions & 0 deletions src/app/content/components/Content.browserspec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ beforeAll(async() => {
});

describe('Content', () => {
const page = global.page;

for (const testCase of Object.keys(TEST_CASES)) {
describe(testCase, () => {
beforeEach(async() => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/content/content.prerenderspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('content', () => {
await navigate(page, TEST_PAGE_WITHOUT_MATH);

const pendingEvents = await page.evaluate(() =>
window!.__APP_ANALYTICS.googleAnalyticsClient.getPendingCommands()
window?.__APP_ANALYTICS.googleAnalyticsClient.getPendingCommands()
);

expect(pendingEvents).toContainEqual({
Expand All @@ -132,18 +132,18 @@ describe('content', () => {
await navigate(page, TEST_PAGE_WITHOUT_MATH);

const initialEvents = await page.evaluate(() =>
window!.__APP_ANALYTICS.googleAnalyticsClient.getPendingCommands()
window?.__APP_ANALYTICS.googleAnalyticsClient.getPendingCommands()
);

await page.click('a[data-analytics-label="next"]');
await finishRender(page);

const pendingEvents = await page.evaluate(() =>
window!.__APP_ANALYTICS.googleAnalyticsClient.getPendingCommands()
window?.__APP_ANALYTICS.googleAnalyticsClient.getPendingCommands()
);

const newEvents = pendingEvents.filter(
(event: any) => !initialEvents.find(equals(event))
(event: Event) => !initialEvents.find(equals(event))
);

expect(newEvents).toMatchObject([
Expand Down
12 changes: 7 additions & 5 deletions src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface AppServices {
imageCDNUtils: ReturnType<typeof createImageCDNUtils>;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type ActionCreator<T extends string = string> = (...args: any[]) => { type: T };
type ActionCreatorMap<T> = { [K in keyof T]: FlattenedActionMap<T[K]> };

Expand All @@ -80,15 +81,16 @@ export type Middleware = ReduxMiddleware<{}, AppState, Dispatch>;
export type MiddlewareAPI = ReduxMiddlewareAPI<Dispatch, AppState>;
export type Store = ReduxStore<AppState, AnyAction>;

export type Initializer = (helpers: MiddlewareAPI & AppServices) => Promise<any>;
export type Initializer = (helpers: MiddlewareAPI & AppServices) => Promise<unknown>;

export type ActionHookBody<C extends AnyActionCreator> = (helpers: MiddlewareAPI & AppServices) =>
(action: ReturnType<C>) => Promise<any> | void;
(action: ReturnType<C>) => Promise<unknown> | void;

// helpers
export type ArgumentTypes<F> = F extends (...args: infer A) => any ? A : never;
export type FirstArgumentType<F> = F extends (first: infer A, ...args: any) => any ? A : never;
export type ArgumentTypes<F> = F extends (...args: infer A) => unknown ? A : never;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type FirstArgumentType<F> = F extends (first: infer A, ...args: any[]) => unknown ? A : never;
export type Unpromisify<F> = F extends Promise<infer T> ? T : never;
// https://stackoverflow.com/a/50375286/14809536
export type UnionToIntersection<U> =
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
(U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;

0 comments on commit 8926ad7

Please sign in to comment.