Skip to content

Commit

Permalink
style: refine type checking and adjust eslint rules
Browse files Browse the repository at this point in the history
The base type in the Router interface within router.ts was unnecessarily strict. As such, it has been simplified. We've also made stricter type checking in theme-schema.tsx for the 'providers' object inside 'sandbox'. Additionally, comments to disable certain eslint rules were added in theme-schema.tsx and sandbox.tsx to optimize the code's readability and avoid potential warnings or errors.

Signed-off-by: prisis <d.bannert@anolilab.de>
  • Loading branch information
prisis committed Aug 2, 2023
1 parent aeb6378 commit 8202d40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/connect/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type Route<H> = {

export class Router<H extends FunctionLike> {
public constructor(
public base: string = "/",
public base = "/",
public routes: Route<Nextable<H>>[] = [],
) {}

Expand Down
3 changes: 2 additions & 1 deletion packages/nextra-theme-docs/src/components/sandbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ const Sandbox: FC<{
storageKey="sandbox"
>
{Object.keys(providers).map((key: string) => (
// eslint-disable-next-line @arthurgeron/react-usememo/require-usememo
<Tab className="not-prose relative" key={key} style={{ minHeight }} title={key}>
<span className="absolute inset-x-0 top-20 m-auto block w-40 text-center">Loading Sandbox...</span>
<iframe
className="not-prose absolute left-0 top-0 z-10 h-full w-full overflow-hidden"
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
/* eslint-disable-next-line security/detect-object-injection */
// eslint-disable-next-line security/detect-object-injection
src={providers[key]}
style={{ minHeight, width: "100%" }}
title="Sandbox editor"
Expand Down
3 changes: 2 additions & 1 deletion packages/nextra-theme-docs/src/theme/theme-schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ export const themeSchema = z
link: z.string().startsWith("https://").optional(),
})
.strict(),
// eslint-disable-next-line zod/require-strict
sandbox: z
.object({
providers: z.object({}).catchall(z.string()),
providers: z.object({}).catchall(z.string()).strict(),
})
.optional(),
search: z
Expand Down

1 comment on commit 8202d40

@vercel
Copy link

@vercel vercel bot commented on 8202d40 Aug 2, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.