From d5e2973dce617f451e4eb07491b3a6874ea6ca47 Mon Sep 17 00:00:00 2001 From: xuatz Date: Sun, 22 Jun 2025 20:29:30 +0900 Subject: 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 --- apps/web/.oxlintrc.json | 35 ++++++++++++++++++++++ apps/web/app/dashboard/cleanups/page.tsx | 1 + apps/web/app/dashboard/highlights/page.tsx | 1 + apps/web/app/dashboard/lists/page.tsx | 1 + apps/web/app/dashboard/tags/page.tsx | 1 + .../components/dashboard/bookmarks/EditorCard.tsx | 2 +- .../components/dashboard/lists/EditListModal.tsx | 6 +++- .../components/dashboard/preview/HighlightsBox.tsx | 7 +++-- apps/web/components/settings/ApiKeySettings.tsx | 1 + apps/web/components/settings/ImportExport.tsx | 2 +- apps/web/components/settings/UserDetails.tsx | 1 + .../components/shared/sidebar/MobileSidebar.tsx | 1 + apps/web/components/shared/sidebar/Sidebar.tsx | 1 + apps/web/components/ui/copy-button.tsx | 2 +- apps/web/lib/importBookmarkParser.ts | 2 +- apps/web/lib/userLocalSettings/types.ts | 2 +- apps/web/package.json | 15 ++-------- apps/web/server/api/client.ts | 2 +- 18 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 apps/web/.oxlintrc.json (limited to 'apps/web') 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) => { 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 }) { {highlights.highlights.map((highlight) => ( - <> - + + - + ))} 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 (