From b25f17509e704eb41523bf455a33804cabf8aaca Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 9 Feb 2024 02:17:45 +0000 Subject: [PATCH] [chore] Linting and formating tweaking --- .eslintrc.js | 18 +++-- .prettierrc | 4 +- Makefile | 5 +- package.json | 3 + packages/web/app/api/v1/bookmarks/route.ts | 4 +- .../bookmarks/components/AddLink.tsx | 2 +- .../bookmarks/components/BookmarksGrid.tsx | 2 +- .../bookmarks/components/LinkCard.tsx | 8 +-- .../web/app/dashboard/components/Sidebar.tsx | 8 +-- packages/web/app/dashboard/layout.tsx | 2 +- packages/web/components/ui/badge.tsx | 8 +-- packages/web/components/ui/button.tsx | 6 +- packages/web/components/ui/card.tsx | 4 +- packages/web/components/ui/dropdown-menu.tsx | 24 +++---- packages/web/components/ui/form.tsx | 4 +- packages/web/components/ui/imageCard.tsx | 8 +-- packages/web/components/ui/input.tsx | 2 +- packages/web/components/ui/toast.tsx | 12 ++-- packages/web/lib/api.ts | 4 +- packages/web/lib/auth.ts | 2 +- packages/web/lib/config.ts | 2 +- packages/workers/crawler.ts | 16 +++-- packages/workers/openai.ts | 6 +- yarn.lock | 70 ++++++++++++++++++- 24 files changed, 157 insertions(+), 67 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index bf32149f..75b50972 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,5 @@ module.exports = { + root: true, env: { browser: true, es2021: true, @@ -9,20 +10,23 @@ module.exports = { "plugin:react/recommended", "plugin:react-hooks/recommended", "plugin:@next/next/recommended", + "plugin:tailwindcss/recommended", + "plugin:@typescript-eslint/recommended", "next", "prettier", ], + plugins: ["tailwindcss", "@typescript-eslint"], parserOptions: { ecmaVersion: "latest", sourceType: "module", }, ignorePatterns: ["postcss.config.js"], rules: { - "no-redeclare": "off", "@next/next/no-html-link-for-pages": "off", - "no-undef": "off", - "react/jsx-no-undef": "off", - "no-unused-vars": [ + "tailwindcss/no-custom-classname": "off", + "tailwindcss/migration-from-tailwind-2": "off", + + "@typescript-eslint/no-unused-vars": [ "error", { varsIgnorePattern: "^_", @@ -30,4 +34,10 @@ module.exports = { }, ], }, + overrides: [ + { + files: ["*.ts", "*.tsx"], + parser: "@typescript-eslint/parser", + }, + ], }; diff --git a/.prettierrc b/.prettierrc index 0967ef42..b4bfed35 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1 +1,3 @@ -{} +{ + "plugins": ["prettier-plugin-tailwindcss"] +} diff --git a/Makefile b/Makefile index 78c0da13..4c7bf5b8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ MAKEFLAGS += --always-make format: - yarn prettier . --write && yarn exec 'eslint .' + yarn prettier . --write + +lint: + yarn eslint . prisma: cd packages/db; \ diff --git a/package.json b/package.json index 8df8a09d..3a17a8f7 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,10 @@ "es-errors": "^1.3.0", "eslint": "^8.56.0", "eslint-config-next": "14.1.0", + "eslint-plugin-tailwindcss": "^3.14.2", + "install": "^0.13.0", "prettier": "3.2.5", + "prettier-plugin-tailwindcss": "^0.5.11", "typescript": "^5" }, "packageManager": "yarn@4.1.0" diff --git a/packages/web/app/api/v1/bookmarks/route.ts b/packages/web/app/api/v1/bookmarks/route.ts index b9305ca8..a78535cc 100644 --- a/packages/web/app/api/v1/bookmarks/route.ts +++ b/packages/web/app/api/v1/bookmarks/route.ts @@ -29,7 +29,7 @@ export async function POST(request: NextRequest) { const bookmark = await bookmarkLink(linkRequest.data.url, session.user.id); - let response: ZBookmark = { ...bookmark }; + const response: ZBookmark = { ...bookmark }; return NextResponse.json(response, { status: 201 }); } @@ -42,6 +42,6 @@ export async function GET() { const bookmarks = await getBookmarks(session.user.id); - let response: ZGetBookmarksResponse = { bookmarks }; + const response: ZGetBookmarksResponse = { bookmarks }; return NextResponse.json(response); } diff --git a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx index fb77786c..f99c1655 100644 --- a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx +++ b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx @@ -43,7 +43,7 @@ export default function AddLink() { return (
-
+
+
{bookmarks.map((b) => renderBookmark(b))}
); diff --git a/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx b/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx index 1cbd8865..aeef6bae 100644 --- a/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx +++ b/packages/web/app/dashboard/bookmarks/components/LinkCard.tsx @@ -26,7 +26,7 @@ export function LinkOptions({ linkId }: { linkId: string }) { const router = useRouter(); const unbookmarkLink = async () => { - let [_, error] = await APIClient.deleteBookmark(linkId); + const [_, error] = await APIClient.deleteBookmark(linkId); if (error) { toast({ @@ -51,7 +51,7 @@ export function LinkOptions({ linkId }: { linkId: string }) { - + Delete @@ -66,7 +66,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) { return ( @@ -75,7 +75,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) { {link?.title ?? parsedUrl.host} - + {bookmark.tags.map((t) => ( -
+