Skip to content

Commit b25f175

Browse files
committed
[chore] Linting and formating tweaking
1 parent 08a5694 commit b25f175

24 files changed

+157
-67
lines changed

.eslintrc.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
root: true,
23
env: {
34
browser: true,
45
es2021: true,
@@ -9,25 +10,34 @@ module.exports = {
910
"plugin:react/recommended",
1011
"plugin:react-hooks/recommended",
1112
"plugin:@next/next/recommended",
13+
"plugin:tailwindcss/recommended",
14+
"plugin:@typescript-eslint/recommended",
1215
"next",
1316
"prettier",
1417
],
18+
plugins: ["tailwindcss", "@typescript-eslint"],
1519
parserOptions: {
1620
ecmaVersion: "latest",
1721
sourceType: "module",
1822
},
1923
ignorePatterns: ["postcss.config.js"],
2024
rules: {
21-
"no-redeclare": "off",
2225
"@next/next/no-html-link-for-pages": "off",
23-
"no-undef": "off",
24-
"react/jsx-no-undef": "off",
25-
"no-unused-vars": [
26+
"tailwindcss/no-custom-classname": "off",
27+
"tailwindcss/migration-from-tailwind-2": "off",
28+
29+
"@typescript-eslint/no-unused-vars": [
2630
"error",
2731
{
2832
varsIgnorePattern: "^_",
2933
argsIgnorePattern: "^_",
3034
},
3135
],
3236
},
37+
overrides: [
38+
{
39+
files: ["*.ts", "*.tsx"],
40+
parser: "@typescript-eslint/parser",
41+
},
42+
],
3343
};

.prettierrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"plugins": ["prettier-plugin-tailwindcss"]
3+
}

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
MAKEFLAGS += --always-make
22

33
format:
4-
yarn prettier . --write && yarn exec 'eslint .'
4+
yarn prettier . --write
5+
6+
lint:
7+
yarn eslint .
58

69
prisma:
710
cd packages/db; \

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"es-errors": "^1.3.0",
2222
"eslint": "^8.56.0",
2323
"eslint-config-next": "14.1.0",
24+
"eslint-plugin-tailwindcss": "^3.14.2",
25+
"install": "^0.13.0",
2426
"prettier": "3.2.5",
27+
"prettier-plugin-tailwindcss": "^0.5.11",
2528
"typescript": "^5"
2629
},
2730
"packageManager": "[email protected]"

packages/web/app/api/v1/bookmarks/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function POST(request: NextRequest) {
2929

3030
const bookmark = await bookmarkLink(linkRequest.data.url, session.user.id);
3131

32-
let response: ZBookmark = { ...bookmark };
32+
const response: ZBookmark = { ...bookmark };
3333
return NextResponse.json(response, { status: 201 });
3434
}
3535

@@ -42,6 +42,6 @@ export async function GET() {
4242

4343
const bookmarks = await getBookmarks(session.user.id);
4444

45-
let response: ZGetBookmarksResponse = { bookmarks };
45+
const response: ZGetBookmarksResponse = { bookmarks };
4646
return NextResponse.json(response);
4747
}

packages/web/app/dashboard/bookmarks/components/AddLink.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function AddLink() {
4343
return (
4444
<Form {...form}>
4545
<form onSubmit={form.handleSubmit(onSubmit, onError)}>
46-
<div className="py-4 container flex w-full items-center space-x-2">
46+
<div className="container flex w-full items-center space-x-2 py-4">
4747
<FormField
4848
control={form.control}
4949
name="url"

packages/web/app/dashboard/bookmarks/components/BookmarksGrid.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default async function BookmarksGrid() {
2020
const bookmarks = await getBookmarks(session.user.id);
2121

2222
return (
23-
<div className="container grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
23+
<div className="container grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
2424
{bookmarks.map((b) => renderBookmark(b))}
2525
</div>
2626
);

packages/web/app/dashboard/bookmarks/components/LinkCard.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function LinkOptions({ linkId }: { linkId: string }) {
2626
const router = useRouter();
2727

2828
const unbookmarkLink = async () => {
29-
let [_, error] = await APIClient.deleteBookmark(linkId);
29+
const [_, error] = await APIClient.deleteBookmark(linkId);
3030

3131
if (error) {
3232
toast({
@@ -51,7 +51,7 @@ export function LinkOptions({ linkId }: { linkId: string }) {
5151
</DropdownMenuTrigger>
5252
<DropdownMenuContent className="w-fit">
5353
<DropdownMenuItem className="text-destructive" onClick={unbookmarkLink}>
54-
<Trash2 className="mr-2 h-4 w-4" />
54+
<Trash2 className="mr-2 size-4" />
5555
<span>Delete</span>
5656
</DropdownMenuItem>
5757
</DropdownMenuContent>
@@ -66,7 +66,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
6666
return (
6767
<ImageCard
6868
className={
69-
"bg-gray-50 duration-300 ease-in border border-grey-100 hover:transition-all hover:border-blue-300"
69+
"border-grey-100 border bg-gray-50 duration-300 ease-in hover:border-blue-300 hover:transition-all"
7070
}
7171
image={link?.imageUrl ?? undefined}
7272
>
@@ -75,7 +75,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
7575
{link?.title ?? parsedUrl.host}
7676
</Link>
7777
</ImageCardTitle>
78-
<ImageCardBody className="py-2 overflow-clip">
78+
<ImageCardBody className="overflow-clip py-2">
7979
{bookmark.tags.map((t) => (
8080
<Badge
8181
variant="default"

packages/web/app/dashboard/components/Sidebar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ export default async function Sidebar() {
3131
}
3232

3333
return (
34-
<aside className="flex flex-col h-full w-60 border-r p-4">
35-
<div className="flex px-1 mb-5 items-center rounded-lg text-slate-900">
34+
<aside className="flex h-full w-60 flex-col border-r p-4">
35+
<div className="mb-5 flex items-center rounded-lg px-1 text-slate-900">
3636
<Brain />
3737
<span className="ml-2 text-base font-semibold">Remember</span>
3838
</div>
3939
<hr />
4040
<div>
41-
<ul className="space-y-2 mt-5 text-sm font-medium">
41+
<ul className="mt-5 space-y-2 text-sm font-medium">
4242
<SidebarItem logo={<Home />} name="Home" path="#" />
4343
<SidebarItem logo={<Star />} name="Favourites" path="#" />
4444
<SidebarItem logo={<Archive />} name="Archived" path="#" />
@@ -47,7 +47,7 @@ export default async function Sidebar() {
4747
</div>
4848
<div className="mt-auto flex justify-between">
4949
<div className="my-auto"> {session.user.name} </div>
50-
<Button variant="ghost" className="h-10 w-30">
50+
<Button variant="ghost" className="h-10">
5151
<MoreHorizontal />
5252
</Button>
5353
</div>

packages/web/app/dashboard/layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Sidebar from "@/app/dashboard/components/Sidebar";
33

44
export default async function Dashboard() {
55
return (
6-
<div className="flex w-screen h-screen">
6+
<div className="flex h-screen w-screen">
77
<div className="flex-none">
88
<Sidebar />
99
</div>

packages/web/components/ui/badge.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import { cva, type VariantProps } from "class-variance-authority";
44
import { cn } from "@/lib/utils";
55

66
const badgeVariants = cva(
7-
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
7+
"focus:ring-ring inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2",
88
{
99
variants: {
1010
variant: {
1111
default:
12-
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
12+
"bg-primary text-primary-foreground hover:bg-primary/80 border-transparent",
1313
secondary:
14-
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
14+
"bg-secondary text-secondary-foreground hover:bg-secondary/80 border-transparent",
1515
destructive:
16-
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
16+
"bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent",
1717
outline: "text-foreground",
1818
},
1919
},

packages/web/components/ui/button.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { cva, type VariantProps } from "class-variance-authority";
55
import { cn } from "@/lib/utils";
66

77
const buttonVariants = cva(
8-
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
8+
"ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
99
{
1010
variants: {
1111
variant: {
1212
default: "bg-primary text-primary-foreground hover:bg-primary/90",
1313
destructive:
1414
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
1515
outline:
16-
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
16+
"border-input bg-background hover:bg-accent hover:text-accent-foreground border",
1717
secondary:
1818
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
1919
ghost: "hover:bg-accent hover:text-accent-foreground",
@@ -23,7 +23,7 @@ const buttonVariants = cva(
2323
default: "h-10 px-4 py-2",
2424
sm: "h-9 rounded-md px-3",
2525
lg: "h-11 rounded-md px-8",
26-
icon: "h-10 w-10",
26+
icon: "size-10",
2727
},
2828
},
2929
defaultVariants: {

packages/web/components/ui/card.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Card = React.forwardRef<
99
<div
1010
ref={ref}
1111
className={cn(
12-
"rounded-lg border bg-card text-card-foreground shadow-sm",
12+
"bg-card text-card-foreground rounded-lg border shadow-sm",
1313
className,
1414
)}
1515
{...props}
@@ -50,7 +50,7 @@ const CardDescription = React.forwardRef<
5050
>(({ className, ...props }, ref) => (
5151
<p
5252
ref={ref}
53-
className={cn("text-sm text-muted-foreground", className)}
53+
className={cn("text-muted-foreground text-sm", className)}
5454
{...props}
5555
/>
5656
));

packages/web/components/ui/dropdown-menu.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const DropdownMenuSubTrigger = React.forwardRef<
2727
<DropdownMenuPrimitive.SubTrigger
2828
ref={ref}
2929
className={cn(
30-
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
30+
"focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
3131
inset && "pl-8",
3232
className,
3333
)}
3434
{...props}
3535
>
3636
{children}
37-
<ChevronRight className="ml-auto h-4 w-4" />
37+
<ChevronRight className="ml-auto size-4" />
3838
</DropdownMenuPrimitive.SubTrigger>
3939
));
4040
DropdownMenuSubTrigger.displayName =
@@ -47,7 +47,7 @@ const DropdownMenuSubContent = React.forwardRef<
4747
<DropdownMenuPrimitive.SubContent
4848
ref={ref}
4949
className={cn(
50-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
50+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",
5151
className,
5252
)}
5353
{...props}
@@ -65,7 +65,7 @@ const DropdownMenuContent = React.forwardRef<
6565
ref={ref}
6666
sideOffset={sideOffset}
6767
className={cn(
68-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
68+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",
6969
className,
7070
)}
7171
{...props}
@@ -83,7 +83,7 @@ const DropdownMenuItem = React.forwardRef<
8383
<DropdownMenuPrimitive.Item
8484
ref={ref}
8585
className={cn(
86-
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
86+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
8787
inset && "pl-8",
8888
className,
8989
)}
@@ -99,15 +99,15 @@ const DropdownMenuCheckboxItem = React.forwardRef<
9999
<DropdownMenuPrimitive.CheckboxItem
100100
ref={ref}
101101
className={cn(
102-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
102+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
103103
className,
104104
)}
105105
checked={checked}
106106
{...props}
107107
>
108-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
108+
<span className="absolute left-2 flex size-3.5 items-center justify-center">
109109
<DropdownMenuPrimitive.ItemIndicator>
110-
<Check className="h-4 w-4" />
110+
<Check className="size-4" />
111111
</DropdownMenuPrimitive.ItemIndicator>
112112
</span>
113113
{children}
@@ -123,14 +123,14 @@ const DropdownMenuRadioItem = React.forwardRef<
123123
<DropdownMenuPrimitive.RadioItem
124124
ref={ref}
125125
className={cn(
126-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
126+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
127127
className,
128128
)}
129129
{...props}
130130
>
131-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
131+
<span className="absolute left-2 flex size-3.5 items-center justify-center">
132132
<DropdownMenuPrimitive.ItemIndicator>
133-
<Circle className="h-2 w-2 fill-current" />
133+
<Circle className="size-2 fill-current" />
134134
</DropdownMenuPrimitive.ItemIndicator>
135135
</span>
136136
{children}
@@ -162,7 +162,7 @@ const DropdownMenuSeparator = React.forwardRef<
162162
>(({ className, ...props }, ref) => (
163163
<DropdownMenuPrimitive.Separator
164164
ref={ref}
165-
className={cn("-mx-1 my-1 h-px bg-muted", className)}
165+
className={cn("bg-muted -mx-1 my-1 h-px", className)}
166166
{...props}
167167
/>
168168
));

packages/web/components/ui/form.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const FormDescription = React.forwardRef<
134134
<p
135135
ref={ref}
136136
id={formDescriptionId}
137-
className={cn("text-sm text-muted-foreground", className)}
137+
className={cn("text-muted-foreground text-sm", className)}
138138
{...props}
139139
/>
140140
);
@@ -156,7 +156,7 @@ const FormMessage = React.forwardRef<
156156
<p
157157
ref={ref}
158158
id={formMessageId}
159-
className={cn("text-sm font-medium text-destructive", className)}
159+
className={cn("text-destructive text-sm font-medium", className)}
160160
{...props}
161161
>
162162
{body}

packages/web/components/ui/imageCard.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function ImageCard({
1010
}: React.HTMLAttributes<HTMLDivElement> & { image?: string }) {
1111
return (
1212
<div
13-
className={cn("h-96 rounded-lg overflow-hidden shadow-md", className)}
13+
className={cn("h-96 overflow-hidden rounded-lg shadow-md", className)}
1414
{...props}
1515
>
1616
<div
@@ -19,7 +19,7 @@ export function ImageCard({
1919
backgroundImage: image ? `url(${image})` : undefined,
2020
}}
2121
></div>
22-
<div className="flex flex-col h-2/5 p-2">{children}</div>
22+
<div className="flex h-2/5 flex-col p-2">{children}</div>
2323
</div>
2424
);
2525
}
@@ -30,7 +30,7 @@ export function ImageCardTitle({
3030
}: React.HTMLAttributes<HTMLDivElement>) {
3131
return (
3232
<div
33-
className={cn("order-first flex-none font-bold text-lg", className)}
33+
className={cn("order-first flex-none text-lg font-bold", className)}
3434
{...props}
3535
/>
3636
);
@@ -42,7 +42,7 @@ export function ImageCardBody({
4242
}: React.HTMLAttributes<HTMLDivElement>) {
4343
return (
4444
<div
45-
className={cn("grow order-1 font-bold text-lg", className)}
45+
className={cn("order-1 grow text-lg font-bold", className)}
4646
{...props}
4747
/>
4848
);

packages/web/components/ui/input.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
1111
<input
1212
type={type}
1313
className={cn(
14-
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
14+
"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
1515
className,
1616
)}
1717
ref={ref}

0 commit comments

Comments
 (0)