Skip to content

Commit

Permalink
Configure ts so it doesnt error on lib types, allowing it to be enabl…
Browse files Browse the repository at this point in the history
…ed precommit (or in ci) (#37)

* Configure ts so it doesnt error on lib types, allowing it to be enabled on precommit hook
* Fix bad rebase / syntax error

---------

Co-authored-by: Cal Irvine <[email protected]>
Co-authored-by: Ben Vinegar <[email protected]>
  • Loading branch information
3 people authored Feb 5, 2024
1 parent 71b54e3 commit 7818688
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ echo "$FILES" | xargs git add

npm test
npm run lint
npm run typecheck

exit 0
26 changes: 13 additions & 13 deletions app/analytics/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("collectRequestHandler", () => {
[
1, // new visitor
1, // new session
],
]
);
});

Expand All @@ -100,13 +100,13 @@ describe("collectRequestHandler", () => {
} as CFAnalyticsEngine,
} as Environment;

// @ts-expect-error - we're mocking the request object
const request = httpMocks.createRequest(
// @ts-expect-error - we're mocking the request object
generateRequestParams({
"if-modified-since": new Date(
Date.now() - 5 * 60 * 1000,
Date.now() - 5 * 60 * 1000
).toUTCString(),
}),
})
);

collectRequestHandler(request, env);
Expand All @@ -117,7 +117,7 @@ describe("collectRequestHandler", () => {
[
0, // new visitor
0, // new session
],
]
);
});

Expand All @@ -128,13 +128,13 @@ describe("collectRequestHandler", () => {
} as CFAnalyticsEngine,
} as Environment;

// @ts-expect-error - we're mocking the request object
const request = httpMocks.createRequest(
// @ts-expect-error - we're mocking the request object
generateRequestParams({
"if-modified-since": new Date(
Date.now() - 31 * 60 * 1000,
Date.now() - 31 * 60 * 1000
).toUTCString(),
}),
})
);

collectRequestHandler(request, env);
Expand All @@ -145,7 +145,7 @@ describe("collectRequestHandler", () => {
[
0, // new visitor
1, // new session
],
]
);
});

Expand All @@ -156,13 +156,13 @@ describe("collectRequestHandler", () => {
} as CFAnalyticsEngine,
} as Environment;

// @ts-expect-error - we're mocking the request object
const request = httpMocks.createRequest(
// @ts-expect-error - we're mocking the request object
generateRequestParams({
"if-modified-since": new Date(
Date.now() - 60 * 24 * 60 * 1000,
Date.now() - 60 * 24 * 60 * 1000
).toUTCString(),
}),
})
);

collectRequestHandler(request, env);
Expand All @@ -173,7 +173,7 @@ describe("collectRequestHandler", () => {
[
1, // new visitor
1, // new session
],
]
);
});
});
1 change: 1 addition & 0 deletions app/analytics/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export class AnalyticsEngineAPI {
return this.getVisitorCountByColumn(siteId, "deviceModel", sinceDays);
}


async getSitesOrderedByHits(sinceDays: number, limit?: number) {
// defaults to 1 day if not specified
const interval = sinceDays || 1;
Expand Down
5 changes: 3 additions & 2 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export default async function handleRequest(
// free to delete this parameter in your app if you're not using it!

// eslint-disable-next-line @typescript-eslint/no-unused-vars
loadContext: AppLoadContext,
loadContext: AppLoadContext
) {
const body = await renderToReadableStream(
// @ts-expect-error This is a mistake in the package types, resolved in @remix-run/[email protected]
<RemixServer context={remixContext} url={request.url} />,
{
signal: request.signal,
Expand All @@ -30,7 +31,7 @@ export default async function handleRequest(
console.error(error);
responseStatusCode = 500;
},
},
}
);

if (isbot(request.headers.get("user-agent"))) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"~/*": ["./app/*"]
},
// Remix takes care of building everything in `remix build`.
"noEmit": true
"noEmit": true,
"skipLibCheck": true
}
}

0 comments on commit 7818688

Please sign in to comment.