diff options
| author | xuatz <xzlow10@gmail.com> | 2025-06-22 20:29:30 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-22 12:29:30 +0100 |
| commit | d5e2973dce617f451e4eb07491b3a6874ea6ca47 (patch) | |
| tree | 9e134ac8c0b263cec755068082ca61c9646efd21 /apps/web | |
| parent | 91a9d3c1aee04d77b2a2d022821f4a7a38e315f3 (diff) | |
| download | karakeep-d5e2973dce617f451e4eb07491b3a6874ea6ca47.tar.zst | |
chore: migrate away from eslint to oxlint (#1642)
* chore: migrate away from eslint to oxlint
* revert turbo task name lint
* it seems like we can remove the seemingly default globals
Diffstat (limited to 'apps/web')
| -rw-r--r-- | apps/web/.oxlintrc.json | 35 | ||||
| -rw-r--r-- | apps/web/app/dashboard/cleanups/page.tsx | 1 | ||||
| -rw-r--r-- | apps/web/app/dashboard/highlights/page.tsx | 1 | ||||
| -rw-r--r-- | apps/web/app/dashboard/lists/page.tsx | 1 | ||||
| -rw-r--r-- | apps/web/app/dashboard/tags/page.tsx | 1 | ||||
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/EditorCard.tsx | 2 | ||||
| -rw-r--r-- | apps/web/components/dashboard/lists/EditListModal.tsx | 6 | ||||
| -rw-r--r-- | apps/web/components/dashboard/preview/HighlightsBox.tsx | 7 | ||||
| -rw-r--r-- | apps/web/components/settings/ApiKeySettings.tsx | 1 | ||||
| -rw-r--r-- | apps/web/components/settings/ImportExport.tsx | 2 | ||||
| -rw-r--r-- | apps/web/components/settings/UserDetails.tsx | 1 | ||||
| -rw-r--r-- | apps/web/components/shared/sidebar/MobileSidebar.tsx | 1 | ||||
| -rw-r--r-- | apps/web/components/shared/sidebar/Sidebar.tsx | 1 | ||||
| -rw-r--r-- | apps/web/components/ui/copy-button.tsx | 2 | ||||
| -rw-r--r-- | apps/web/lib/importBookmarkParser.ts | 2 | ||||
| -rw-r--r-- | apps/web/lib/userLocalSettings/types.ts | 2 | ||||
| -rw-r--r-- | apps/web/package.json | 15 | ||||
| -rw-r--r-- | apps/web/server/api/client.ts | 2 |
18 files changed, 61 insertions, 22 deletions
diff --git a/apps/web/.oxlintrc.json b/apps/web/.oxlintrc.json new file mode 100644 index 00000000..3a2cb742 --- /dev/null +++ b/apps/web/.oxlintrc.json @@ -0,0 +1,35 @@ +{ + "$schema": "../../node_modules/oxlint/configuration_schema.json", + "extends": [ + "../../tooling/oxlint/oxlint-base.json", + "../../tooling/oxlint/oxlint-nextjs.json", + "../../tooling/oxlint/oxlint-react.json" + ], + "categories": { + "correctness": "warn" + }, + "env": { + "builtin": true, + "commonjs": true, + "browser": true, + "es2022": true, + "node": true + }, + "globals": { + "React": "writeable" + }, + "settings": { + "react": { + "version": "detect" + } + }, + "ignorePatterns": [ + "**/*.config.js", + "**/*.config.cjs", + "**/.eslintrc.cjs", + ".next", + "dist", + "build", + "pnpm-lock.yaml" + ] +} diff --git a/apps/web/app/dashboard/cleanups/page.tsx b/apps/web/app/dashboard/cleanups/page.tsx index 1974d2a7..8da6e75b 100644 --- a/apps/web/app/dashboard/cleanups/page.tsx +++ b/apps/web/app/dashboard/cleanups/page.tsx @@ -4,6 +4,7 @@ import { useTranslation } from "@/lib/i18n/server"; import { Paintbrush, Tags } from "lucide-react"; export default async function Cleanups() { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); return ( diff --git a/apps/web/app/dashboard/highlights/page.tsx b/apps/web/app/dashboard/highlights/page.tsx index 646b1c41..1410d1fd 100644 --- a/apps/web/app/dashboard/highlights/page.tsx +++ b/apps/web/app/dashboard/highlights/page.tsx @@ -5,6 +5,7 @@ import { api } from "@/server/api/client"; import { Highlighter } from "lucide-react"; export default async function HighlightsPage() { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); const highlights = await api.highlights.getAll({}); return ( diff --git a/apps/web/app/dashboard/lists/page.tsx b/apps/web/app/dashboard/lists/page.tsx index 36eb8b7a..1c28073d 100644 --- a/apps/web/app/dashboard/lists/page.tsx +++ b/apps/web/app/dashboard/lists/page.tsx @@ -4,6 +4,7 @@ import { useTranslation } from "@/lib/i18n/server"; import { api } from "@/server/api/client"; export default async function ListsPage() { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); const lists = await api.lists.list(); diff --git a/apps/web/app/dashboard/tags/page.tsx b/apps/web/app/dashboard/tags/page.tsx index 1639e4c5..9108d6ba 100644 --- a/apps/web/app/dashboard/tags/page.tsx +++ b/apps/web/app/dashboard/tags/page.tsx @@ -4,6 +4,7 @@ import { useTranslation } from "@/lib/i18n/server"; import { api } from "@/server/api/client"; export default async function TagsPage() { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); const allTags = (await api.tags.list()).tags; diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx index 75745bad..a5966845 100644 --- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx +++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx @@ -132,7 +132,7 @@ export default function EditorCard({ className }: { className?: string }) { if (!text.length) return; try { tryToImportUrls(text); - } catch (e) { + } catch { // Not a URL mutate({ type: BookmarkTypes.TEXT, text }); } diff --git a/apps/web/components/dashboard/lists/EditListModal.tsx b/apps/web/components/dashboard/lists/EditListModal.tsx index 7a750c33..3b35e7d4 100644 --- a/apps/web/components/dashboard/lists/EditListModal.tsx +++ b/apps/web/components/dashboard/lists/EditListModal.tsx @@ -192,7 +192,11 @@ export function EditListModal({ (value: z.infer<typeof zNewBookmarkListSchema>) => { value.parentId = value.parentId === "" ? null : value.parentId; value.query = value.type === "smart" ? value.query : undefined; - isEdit ? editList({ ...value, listId: list.id }) : createList(value); + if (isEdit) { + editList({ ...value, listId: list.id }); + } else { + createList(value); + } }, ); diff --git a/apps/web/components/dashboard/preview/HighlightsBox.tsx b/apps/web/components/dashboard/preview/HighlightsBox.tsx index af065a9d..4da22d04 100644 --- a/apps/web/components/dashboard/preview/HighlightsBox.tsx +++ b/apps/web/components/dashboard/preview/HighlightsBox.tsx @@ -1,3 +1,4 @@ +import { Fragment } from "react"; import { Collapsible, CollapsibleContent, @@ -28,10 +29,10 @@ export default function HighlightsBox({ bookmarkId }: { bookmarkId: string }) { </CollapsibleTrigger> <CollapsibleContent className="group flex flex-col py-3 text-sm"> {highlights.highlights.map((highlight) => ( - <> - <HighlightCard key={highlight.id} highlight={highlight} clickable /> + <Fragment key={highlight.id}> + <HighlightCard highlight={highlight} clickable /> <Separator className="m-2 h-0.5 bg-gray-200 last:hidden" /> - </> + </Fragment> ))} </CollapsibleContent> </Collapsible> diff --git a/apps/web/components/settings/ApiKeySettings.tsx b/apps/web/components/settings/ApiKeySettings.tsx index 8f07e5a4..2b9d19d1 100644 --- a/apps/web/components/settings/ApiKeySettings.tsx +++ b/apps/web/components/settings/ApiKeySettings.tsx @@ -13,6 +13,7 @@ import AddApiKey from "./AddApiKey"; import DeleteApiKey from "./DeleteApiKey"; export default async function ApiKeys() { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); const keys = await api.apiKeys.list(); return ( diff --git a/apps/web/components/settings/ImportExport.tsx b/apps/web/components/settings/ImportExport.tsx index 35c2b88f..3dde577b 100644 --- a/apps/web/components/settings/ImportExport.tsx +++ b/apps/web/components/settings/ImportExport.tsx @@ -282,7 +282,7 @@ export function ImportExportRow() { }; }); return { status: "fulfilled" as const, value: created }; - } catch (e) { + } catch { setImportProgress((prev) => { const newDone = (prev?.done ?? 0) + 1; return { diff --git a/apps/web/components/settings/UserDetails.tsx b/apps/web/components/settings/UserDetails.tsx index b86129c8..5b99c0ea 100644 --- a/apps/web/components/settings/UserDetails.tsx +++ b/apps/web/components/settings/UserDetails.tsx @@ -7,6 +7,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; import { Label } from "../ui/label"; export default async function UserDetails() { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); const whoami = await api.users.whoami(); diff --git a/apps/web/components/shared/sidebar/MobileSidebar.tsx b/apps/web/components/shared/sidebar/MobileSidebar.tsx index 15285a9e..c512a981 100644 --- a/apps/web/components/shared/sidebar/MobileSidebar.tsx +++ b/apps/web/components/shared/sidebar/MobileSidebar.tsx @@ -9,6 +9,7 @@ export default async function MobileSidebar({ }: { items: (t: TFunction) => TSidebarItem[]; }) { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); return ( <aside className="w-full overflow-x-auto"> diff --git a/apps/web/components/shared/sidebar/Sidebar.tsx b/apps/web/components/shared/sidebar/Sidebar.tsx index dff26cdd..21d3ea48 100644 --- a/apps/web/components/shared/sidebar/Sidebar.tsx +++ b/apps/web/components/shared/sidebar/Sidebar.tsx @@ -14,6 +14,7 @@ export default async function Sidebar({ items: (t: TFunction) => TSidebarItem[]; extraSections?: React.ReactNode; }) { + // oxlint-disable-next-line rules-of-hooks const { t } = await useTranslation(); return ( diff --git a/apps/web/components/ui/copy-button.tsx b/apps/web/components/ui/copy-button.tsx index 1cb405da..8d8699f8 100644 --- a/apps/web/components/ui/copy-button.tsx +++ b/apps/web/components/ui/copy-button.tsx @@ -54,7 +54,7 @@ export function CopyBtnV2({ await navigator.clipboard.writeText(url);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
- } catch (err) {
+ } catch {
toast({
description:
"Failed to copy link. Browsers only support copying to the clipboard from https pages.",
diff --git a/apps/web/lib/importBookmarkParser.ts b/apps/web/lib/importBookmarkParser.ts index 2e354ffe..44fe872c 100644 --- a/apps/web/lib/importBookmarkParser.ts +++ b/apps/web/lib/importBookmarkParser.ts @@ -39,7 +39,7 @@ export async function parseNetscapeBookmarkFile( const tagsStr = $a.attr("tags"); try { tags = tagsStr && tagsStr.length > 0 ? tagsStr.split(",") : []; - } catch (e) { + } catch { /* empty */ } const url = $a.attr("href"); diff --git a/apps/web/lib/userLocalSettings/types.ts b/apps/web/lib/userLocalSettings/types.ts index bcd2ff26..94c9bb21 100644 --- a/apps/web/lib/userLocalSettings/types.ts +++ b/apps/web/lib/userLocalSettings/types.ts @@ -15,7 +15,7 @@ export type UserLocalSettings = z.infer<typeof zUserLocalSettings>; export function parseUserLocalSettings(str: string | undefined) { try { return zUserLocalSettings.parse(JSON.parse(str ?? "{}")); - } catch (e) { + } catch { return undefined; } } diff --git a/apps/web/package.json b/apps/web/package.json index ff6410f6..164358f4 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -9,12 +9,12 @@ "clean": "git clean -xdf .next .turbo node_modules", "build": "next build --experimental-build-mode compile", "start": "next start", - "lint": "next lint", + "lint": "oxlint .", + "lint:fix": "oxlint . --fix", "test": "vitest", "typecheck": "tsc --noEmit", "format": "prettier --check . --ignore-path ../../.gitignore", - "format:fix": "prettier --write . --ignore-path ../../.gitignore", - "lint:fix": "next lint --fix" + "format:fix": "prettier --write . --ignore-path ../../.gitignore" }, "dependencies": { "@auth/drizzle-adapter": "~1.5.0", @@ -96,7 +96,6 @@ "zustand": "^4.5.1" }, "devDependencies": { - "@karakeep/eslint-config": "workspace:^0.2.0", "@karakeep/prettier-config": "workspace:^0.1.0", "@karakeep/tailwind-config": "workspace:^0.1.0", "@karakeep/tsconfig": "workspace:^0.1.0", @@ -112,13 +111,5 @@ "vite-tsconfig-paths": "^4.3.1", "vitest": "^1.6.1" }, - "eslintConfig": { - "root": true, - "extends": [ - "@karakeep/eslint-config/base", - "@karakeep/eslint-config/nextjs", - "@karakeep/eslint-config/react" - ] - }, "prettier": "@karakeep/prettier-config" } diff --git a/apps/web/server/api/client.ts b/apps/web/server/api/client.ts index fc223313..b36459a2 100644 --- a/apps/web/server/api/client.ts +++ b/apps/web/server/api/client.ts @@ -25,7 +25,7 @@ export async function createContextFromRequest(req: Request) { ip, }, }; - } catch (e) { + } catch { // Fallthrough to cookie-based auth } } |
