Skip to content

Commit

Permalink
[chore] Linting and formating tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Feb 9, 2024
1 parent 08a5694 commit b25f175
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 67 deletions.
18 changes: 14 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
Expand All @@ -9,25 +10,34 @@ 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: "^_",
argsIgnorePattern: "^_",
},
],
},
overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
},
],
};
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"plugins": ["prettier-plugin-tailwindcss"]
}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
MAKEFLAGS += --always-make

format:
yarn prettier . --write && yarn exec 'eslint .'
yarn prettier . --write

lint:
yarn eslint .

prisma:
cd packages/db; \
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/web/app/api/v1/bookmarks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function AddLink() {
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit, onError)}>
<div className="py-4 container flex w-full items-center space-x-2">
<div className="container flex w-full items-center space-x-2 py-4">
<FormField
control={form.control}
name="url"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function BookmarksGrid() {
const bookmarks = await getBookmarks(session.user.id);

return (
<div className="container grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
<div className="container grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{bookmarks.map((b) => renderBookmark(b))}
</div>
);
Expand Down
8 changes: 4 additions & 4 deletions packages/web/app/dashboard/bookmarks/components/LinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -51,7 +51,7 @@ export function LinkOptions({ linkId }: { linkId: string }) {
</DropdownMenuTrigger>
<DropdownMenuContent className="w-fit">
<DropdownMenuItem className="text-destructive" onClick={unbookmarkLink}>
<Trash2 className="mr-2 h-4 w-4" />
<Trash2 className="mr-2 size-4" />
<span>Delete</span>
</DropdownMenuItem>
</DropdownMenuContent>
Expand All @@ -66,7 +66,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
return (
<ImageCard
className={
"bg-gray-50 duration-300 ease-in border border-grey-100 hover:transition-all hover:border-blue-300"
"border-grey-100 border bg-gray-50 duration-300 ease-in hover:border-blue-300 hover:transition-all"
}
image={link?.imageUrl ?? undefined}
>
Expand All @@ -75,7 +75,7 @@ export default function LinkCard({ bookmark }: { bookmark: ZBookmark }) {
{link?.title ?? parsedUrl.host}
</Link>
</ImageCardTitle>
<ImageCardBody className="py-2 overflow-clip">
<ImageCardBody className="overflow-clip py-2">
{bookmark.tags.map((t) => (
<Badge
variant="default"
Expand Down
8 changes: 4 additions & 4 deletions packages/web/app/dashboard/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export default async function Sidebar() {
}

return (
<aside className="flex flex-col h-full w-60 border-r p-4">
<div className="flex px-1 mb-5 items-center rounded-lg text-slate-900">
<aside className="flex h-full w-60 flex-col border-r p-4">
<div className="mb-5 flex items-center rounded-lg px-1 text-slate-900">
<Brain />
<span className="ml-2 text-base font-semibold">Remember</span>
</div>
<hr />
<div>
<ul className="space-y-2 mt-5 text-sm font-medium">
<ul className="mt-5 space-y-2 text-sm font-medium">
<SidebarItem logo={<Home />} name="Home" path="#" />
<SidebarItem logo={<Star />} name="Favourites" path="#" />
<SidebarItem logo={<Archive />} name="Archived" path="#" />
Expand All @@ -47,7 +47,7 @@ export default async function Sidebar() {
</div>
<div className="mt-auto flex justify-between">
<div className="my-auto"> {session.user.name} </div>
<Button variant="ghost" className="h-10 w-30">
<Button variant="ghost" className="h-10">
<MoreHorizontal />
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Sidebar from "@/app/dashboard/components/Sidebar";

export default async function Dashboard() {
return (
<div className="flex w-screen h-screen">
<div className="flex h-screen w-screen">
<div className="flex-none">
<Sidebar />
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/web/components/ui/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";

const badgeVariants = cva(
"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",
"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",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
"bg-primary text-primary-foreground hover:bg-primary/80 border-transparent",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
"bg-secondary text-secondary-foreground hover:bg-secondary/80 border-transparent",
destructive:
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
"bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent",
outline: "text-foreground",
},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/web/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";

const buttonVariants = cva(
"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",
"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",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
"border-input bg-background hover:bg-accent hover:text-accent-foreground border",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
Expand All @@ -23,7 +23,7 @@ const buttonVariants = cva(
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
icon: "size-10",
},
},
defaultVariants: {
Expand Down
4 changes: 2 additions & 2 deletions packages/web/components/ui/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Card = React.forwardRef<
<div
ref={ref}
className={cn(
"rounded-lg border bg-card text-card-foreground shadow-sm",
"bg-card text-card-foreground rounded-lg border shadow-sm",
className,
)}
{...props}
Expand Down Expand Up @@ -50,7 +50,7 @@ const CardDescription = React.forwardRef<
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
));
Expand Down
24 changes: 12 additions & 12 deletions packages/web/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ const DropdownMenuSubTrigger = React.forwardRef<
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"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",
"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",
inset && "pl-8",
className,
)}
{...props}
>
{children}
<ChevronRight className="ml-auto h-4 w-4" />
<ChevronRight className="ml-auto size-4" />
</DropdownMenuPrimitive.SubTrigger>
));
DropdownMenuSubTrigger.displayName =
Expand All @@ -47,7 +47,7 @@ const DropdownMenuSubContent = React.forwardRef<
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
"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",
"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",
className,
)}
{...props}
Expand All @@ -65,7 +65,7 @@ const DropdownMenuContent = React.forwardRef<
ref={ref}
sideOffset={sideOffset}
className={cn(
"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",
"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",
className,
)}
{...props}
Expand All @@ -83,7 +83,7 @@ const DropdownMenuItem = React.forwardRef<
<DropdownMenuPrimitive.Item
ref={ref}
className={cn(
"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",
"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",
inset && "pl-8",
className,
)}
Expand All @@ -99,15 +99,15 @@ const DropdownMenuCheckboxItem = React.forwardRef<
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
"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",
"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",
className,
)}
checked={checked}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span className="absolute left-2 flex size-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
<Check className="size-4" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
Expand All @@ -123,14 +123,14 @@ const DropdownMenuRadioItem = React.forwardRef<
<DropdownMenuPrimitive.RadioItem
ref={ref}
className={cn(
"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",
"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",
className,
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span className="absolute left-2 flex size-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Circle className="h-2 w-2 fill-current" />
<Circle className="size-2 fill-current" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
Expand Down Expand Up @@ -162,7 +162,7 @@ const DropdownMenuSeparator = React.forwardRef<
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
className={cn("bg-muted -mx-1 my-1 h-px", className)}
{...props}
/>
));
Expand Down
4 changes: 2 additions & 2 deletions packages/web/components/ui/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const FormDescription = React.forwardRef<
<p
ref={ref}
id={formDescriptionId}
className={cn("text-sm text-muted-foreground", className)}
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
Expand All @@ -156,7 +156,7 @@ const FormMessage = React.forwardRef<
<p
ref={ref}
id={formMessageId}
className={cn("text-sm font-medium text-destructive", className)}
className={cn("text-destructive text-sm font-medium", className)}
{...props}
>
{body}
Expand Down
8 changes: 4 additions & 4 deletions packages/web/components/ui/imageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function ImageCard({
}: React.HTMLAttributes<HTMLDivElement> & { image?: string }) {
return (
<div
className={cn("h-96 rounded-lg overflow-hidden shadow-md", className)}
className={cn("h-96 overflow-hidden rounded-lg shadow-md", className)}
{...props}
>
<div
Expand All @@ -19,7 +19,7 @@ export function ImageCard({
backgroundImage: image ? `url(${image})` : undefined,
}}
></div>
<div className="flex flex-col h-2/5 p-2">{children}</div>
<div className="flex h-2/5 flex-col p-2">{children}</div>
</div>
);
}
Expand All @@ -30,7 +30,7 @@ export function ImageCardTitle({
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn("order-first flex-none font-bold text-lg", className)}
className={cn("order-first flex-none text-lg font-bold", className)}
{...props}
/>
);
Expand All @@ -42,7 +42,7 @@ export function ImageCardBody({
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn("grow order-1 font-bold text-lg", className)}
className={cn("order-1 grow text-lg font-bold", className)}
{...props}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
"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",
"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",
className,
)}
ref={ref}
Expand Down
Loading

0 comments on commit b25f175

Please sign in to comment.