From 505596c610402e75c2bd4be5c0bb871939e665ad Mon Sep 17 00:00:00 2001 From: VIVEK PATEL Date: Sat, 11 May 2024 03:40:46 -0400 Subject: [PATCH] Added lint staged --- .eslintignore | 5 + .eslintrc.json | 8 +- .husky/pre-commit | 8 +- .huskyrc | 2 +- .lintstagedrc | 10 ++ .prettierignore | 11 ++ .prettierrc | 6 +- app/PhotoGallery/page.tsx | 12 ++- app/actions.ts | 4 +- app/api/route.ts | 17 +-- app/blog/[slug]/page.tsx | 54 +++++++--- app/blog/page.tsx | 19 ++-- app/blog/views.tsx | 2 +- app/contact/ContactForm.tsx | 55 +++++++--- app/contact/page.tsx | 47 ++++++--- app/erros.tsx | 2 +- app/layout.tsx | 21 +++- app/not-found.tsx | 29 ++++-- app/page.tsx | 31 +++--- app/projects/[slug]/page.tsx | 45 +++++--- app/projects/page.tsx | 19 ++-- app/sitemap.ts | 20 ++-- app/snippet/[slug]/page.tsx | 47 ++++++--- app/snippet/page.tsx | 8 +- app/tag/[slug]/page.tsx | 40 ++++--- app/tag/page.tsx | 13 ++- bun.lockb | Bin 252235 -> 267361 bytes components/BlogPost.tsx | 32 ++++-- components/Footer.jsx | 8 +- components/Hero.jsx | 31 ++++-- components/Pagination.tsx | 61 ++++++++--- components/ProjectCard.tsx | 14 ++- components/ScrollToTopButton.tsx | 4 +- components/Search.tsx | 39 ------- components/SnippetCard.tsx | 13 ++- components/mdx/Callout.tsx | 18 +++- components/mdx/CustomLink.tsx | 16 ++- components/mdx/Pre.tsx | 13 ++- components/mdx/mdx.tsx | 103 ++++++++++++++++--- components/navbar/FloatingNav.tsx | 10 +- components/navbar/MobileNav.tsx | 27 +++-- components/skeletons/RecentBlogsSkeleton.tsx | 12 ++- components/submit-button.tsx | 8 +- components/ui/button.tsx | 21 +++- components/ui/input.tsx | 31 +++--- components/ui/label.tsx | 15 ++- components/ui/progress.tsx | 4 +- components/ui/sheet.tsx | 76 ++++++++++---- components/ui/skeleton.tsx | 16 ++- components/ui/textarea.tsx | 29 +++--- lib/get-blogs.ts | 20 +++- lib/get-projects.ts | 13 ++- lib/get-snippets.ts | 17 ++- lib/get-views.ts | 8 +- lib/supabase/private.js | 5 +- lib/utils.ts | 10 +- package.json | 7 +- prettier.config.js | 3 - 58 files changed, 851 insertions(+), 368 deletions(-) create mode 100644 .eslintignore create mode 100644 .lintstagedrc create mode 100644 .prettierignore delete mode 100644 components/Search.tsx delete mode 100644 prettier.config.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..eddfbf9 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,5 @@ +node_modules +.vscode +public +.next +prisma \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..cc261c1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,7 @@ { - "extends": "next/core-web-vitals" -} + "extends": ["next/core-web-vitals", "eslint:recommended", "next", "prettier"], + "plugins": ["prettier"], + "rules": { + "prettier/prettier": ["error", { "endOfLine": "auto" }] + } +} \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 2b889e6..0312b76 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ -npm run lint -npm run format -npm run build -git add . \ No newline at end of file +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged \ No newline at end of file diff --git a/.huskyrc b/.huskyrc index 2b0bf1a..05ea0d9 100644 --- a/.huskyrc +++ b/.huskyrc @@ -1,5 +1,5 @@ { "hooks": { - "pre-commit": "sh .husky/pre-commit" + "pre-commit": "lint-staged" } } \ No newline at end of file diff --git a/.lintstagedrc b/.lintstagedrc new file mode 100644 index 0000000..c020d3b --- /dev/null +++ b/.lintstagedrc @@ -0,0 +1,10 @@ +{ + "*/**/*.{js,jsx,ts,tsx}": [ + "prettier --write", + "eslint --fix", + "eslint" + ], + "*/**/*.{json,css,md,mdx}": [ + "prettier --write" + ] +} \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..034611d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +bun.lock +package-lock.json +node_modules +.next +.cache +.vscode +.husky +public +next-env.d.ts +next.config.ts +prisma \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index c00a99a..35a1b8a 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,9 +1,11 @@ { + "bracketSpacing": true, "trailingComma": "all", "arrowParens": "always", "tabWidth": 2, - "printWidth": 130, + "printWidth": 80, "semi": true, "singleQuote": true, - "jsxSingleQuote": true + "jsxSingleQuote": true, + "plugins": ["prettier-plugin-tailwindcss"] } diff --git a/app/PhotoGallery/page.tsx b/app/PhotoGallery/page.tsx index 88d21f1..40706ca 100644 --- a/app/PhotoGallery/page.tsx +++ b/app/PhotoGallery/page.tsx @@ -1,6 +1,5 @@ import { Button } from '@/components/ui/button'; import type { Metadata } from 'next'; -import Image from 'next/image'; export const metadata: Metadata = { title: 'Photo Gallery', @@ -10,13 +9,18 @@ export const metadata: Metadata = { const PhotoGallery = () => { return ( -
+

Photo Gallery

{/* Show that this page is still in development */} -

This page is still in development. Check back later for more photos.

+

+ This page is still in development. Check back later for more photos. +

-
diff --git a/app/actions.ts b/app/actions.ts index 4d14111..e21a53c 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -1,5 +1,5 @@ 'use server'; -import { revalidatePath, unstable_noStore as noStore } from 'next/cache'; +import { unstable_noStore as noStore } from 'next/cache'; import supabase from '@/lib/supabase/private'; import { z } from 'zod'; @@ -36,7 +36,7 @@ export async function sendMessage(prevState: any, formData: FormData) { }; } try { - const { data, error } = await supabase.from('Message').upsert({ + const { error } = await supabase.from('Message').upsert({ email: validatedFields.data.email, message: validatedFields.data.message, name: validatedFields.data.name, diff --git a/app/api/route.ts b/app/api/route.ts index 1dd04ed..76a0b41 100644 --- a/app/api/route.ts +++ b/app/api/route.ts @@ -10,14 +10,17 @@ export async function POST(request: Request) { negative_prompt: 'deformed, ugly', }); - const response = await fetch('https://modal-labs--instant-stable-diffusion-xl.modal.run/v1/inference', { - method: 'POST', - headers: { - Authorization: `Token ${process.env.MODAL_TOKEN_ID}:${process.env.MODAL_TOKEN_SECRET}`, - 'Content-Type': 'application/json', + const response = await fetch( + 'https://modal-labs--instant-stable-diffusion-xl.modal.run/v1/inference', + { + method: 'POST', + headers: { + Authorization: `Token ${process.env.MODAL_TOKEN_ID}:${process.env.MODAL_TOKEN_SECRET}`, + 'Content-Type': 'application/json', + }, + body, }, - body, - }); + ); if (response.status !== 201) { const message = await response.text(); diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx index b584075..13273de 100644 --- a/app/blog/[slug]/page.tsx +++ b/app/blog/[slug]/page.tsx @@ -19,16 +19,28 @@ import { increment } from '@/app/actions'; // return blogs.map((blog) => ({ slug: blog.slug })); // } -export async function generateMetadata({ params }: { params: any }): Promise { +export async function generateMetadata({ + params, +}: { + params: any; +}): Promise { const blog = getBlogs().find((post) => post.slug === params.slug); if (!blog) { return notFound(); } - let { title, publishedAt: publishedTime, summary: description, image, tags } = blog.metadata; + let { + title, + publishedAt: publishedTime, + summary: description, + image, + tags, + } = blog.metadata; - let ogImage = image ? `https://patelvivek.dev${image}` : `https://patelvivek.dev/og?title=${title}`; + let ogImage = image + ? `https://patelvivek.dev${image}` + : `https://patelvivek.dev/og?title=${title}`; return { title, @@ -68,7 +80,7 @@ export default function Blog({ params }: { params: any }) { } return ( -
+