Skip to content

Commit f8c541c

Browse files
committed
Install Trunk & resolve linting issues
1 parent 01243aa commit f8c541c

31 files changed

+124
-71
lines changed

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"rules": {
1111
"@next/next/no-html-link-for-pages": "off",
1212
"react/jsx-key": "off",
13-
"tailwindcss/no-custom-classname": "off"
13+
"tailwindcss/no-custom-classname": "off",
14+
"@next/next/no-img-element": "off"
1415
},
1516
"settings": {
1617
"tailwindcss": {

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ updates:
1616
prefix-development: deps(dev)
1717
ignore:
1818
- dependency-name: eslint
19-
versions: [">=9"]
19+
versions: [">=9"]

.trunk/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*out
2+
*logs
3+
*actions
4+
*notifications
5+
*tools
6+
plugins
7+
user_trunk.yaml
8+
user.yaml
9+
tmp

.trunk/configs/.markdownlint.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Prettier friendly markdownlint config (all formatting rules disabled)
2+
extends: markdownlint/style/prettier
3+
4+
# Override individual rules based on our README files
5+
first-line-heading: false
6+
no-inline-html:
7+
allowed_elements:
8+
- a
9+
- picture
10+
- source
11+
- img
12+
- p

.trunk/configs/.yamllint.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rules:
2+
quoted-strings:
3+
required: only-when-needed
4+
extra-allowed: ["{|}"]
5+
key-duplicates: {}
6+
octal-values:
7+
forbid-implicit-octal: true

.trunk/trunk.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
2+
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
3+
version: 0.1
4+
cli:
5+
version: 1.22.1
6+
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
7+
plugins:
8+
sources:
9+
- id: trunk
10+
ref: v1.5.0
11+
uri: https://github.com/trunk-io/plugins
12+
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
13+
runtimes:
14+
enabled:
15+
16+
17+
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
18+
lint:
19+
enabled:
20+
21+
22+
- git-diff-check
23+
24+
25+
26+
27+
28+
29+
actions:
30+
enabled:
31+
- trunk-announce
32+
- trunk-check-pre-push
33+
- trunk-fmt-pre-commit
34+
- trunk-upgrade-available

app/attack/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function IndexPage() {
3838
<h2 className="text-xl font-bold">Try it</h2>
3939
<p>Simulate an attack using curl:</p>
4040
<pre className="p-4">
41-
curl -v -H "x-arcjet-suspicious: true"
41+
curl -v -H &quot;x-arcjet-suspicious: true&quot;
4242
https://example.arcjet.com/attack/test
4343
</pre>
4444
<p className="max-w-[700px]">

app/attack/test/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function GET(req: Request) {
3232
if (decision.isDenied()) {
3333
return NextResponse.json(
3434
{ error: "Forbidden", ip: decision.ip },
35-
{ status: 403 }
35+
{ status: 403 },
3636
);
3737
}
3838

app/bots/test/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function GET(req: Request) {
3131
if (decision.isDenied()) {
3232
return NextResponse.json(
3333
{ error: "Forbidden", ip: decision.ip },
34-
{ status: 403 }
34+
{ status: 403 },
3535
);
3636
}
3737

app/layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
4040
<body
4141
className={cn(
4242
"min-h-screen bg-background font-sans antialiased",
43-
fontSans.variable
43+
fontSans.variable,
4444
)}
4545
>
4646
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>

app/rate-limiting/page.tsx

+1-13
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,7 @@ export default async function IndexPage() {
6161
</Link>{" "}
6262
e.g. to set a limit based on the authenticated user.
6363
</p>
64-
{session ? (
65-
<>
66-
<p className="max-w-[700px]">
67-
<SignOut />
68-
</p>
69-
</>
70-
) : (
71-
<>
72-
<p className="max-w-[700px]">
73-
<SignIn />
74-
</p>
75-
</>
76-
)}
64+
{session ? <SignOut /> : <SignIn />}
7765
</section>
7866
);
7967
}

app/rate-limiting/test/route.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ function getClient(session: Session | null) {
3232
mode: "LIVE",
3333
max: 5,
3434
window: "60s",
35-
})
35+
}),
3636
);
3737
} else {
3838
return aj.withRule(
3939
fixedWindow({
4040
mode: "LIVE",
4141
max: 2,
4242
window: "60s",
43-
})
43+
}),
4444
);
4545
}
4646
}
@@ -89,18 +89,18 @@ export async function POST(req: Request) {
8989
if (decision.reason.isRateLimit()) {
9090
return NextResponse.json(
9191
{ error: `HTTP 429: Too many requests. ${message}`, ip: decision.ip },
92-
{ status: 429, headers }
92+
{ status: 429, headers },
9393
);
9494
} else {
9595
return NextResponse.json(
9696
{ error: "Forbidden", ip: decision.ip },
97-
{ status: 403, headers }
97+
{ status: 403, headers },
9898
);
9999
}
100100
}
101101

102102
return NextResponse.json(
103103
{ message: `HTTP 200: OK. ${remaining} requests remaining. ${message}` },
104-
{ status: 200, headers }
104+
{ status: 200, headers },
105105
);
106106
}

app/signup/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function IndexPage() {
1818
</Link>{" "}
1919
which includes:
2020
</p>
21-
<ul className="max-w-[700px] list-disc list-outside ms-8">
21+
<ul className="ms-8 max-w-[700px] list-outside list-disc">
2222
<li>
2323
Arcjet server-side email verification configured to block disposable
2424
providers and ensure that the domain has a valid MX record.
@@ -35,7 +35,7 @@ export default function IndexPage() {
3535

3636
<h2 className="text-xl font-bold">Test emails</h2>
3737
<p>Try these emails to see how it works:</p>
38-
<ul className="list-disc list-outside ms-8">
38+
<ul className="ms-8 list-outside list-disc">
3939
<li>
4040
<code>invalid.@arcjet</code> is an invalid email address.
4141
</li>

app/signup/test/route.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function POST(req: Request) {
4444

4545
return NextResponse.json(
4646
{ message: "Invalid request", error },
47-
{ status: 400 }
47+
{ status: 400 },
4848
);
4949
}
5050

@@ -79,7 +79,7 @@ export async function POST(req: Request) {
7979

8080
return NextResponse.json(
8181
{ message, reason: decision.reason },
82-
{ status: 400 }
82+
{ status: 400 },
8383
);
8484
} else if (decision.reason.isRateLimit()) {
8585
const reset = decision.reason.resetTime;
@@ -90,7 +90,7 @@ export async function POST(req: Request) {
9090
message: "Too many requests. Please try again later.",
9191
reason: decision.reason,
9292
},
93-
{ status: 429 }
93+
{ status: 429 },
9494
);
9595
}
9696

@@ -104,15 +104,15 @@ export async function POST(req: Request) {
104104
message: `Too many requests. Please try again in ${minutes} minutes.`,
105105
reason: decision.reason,
106106
},
107-
{ status: 429 }
107+
{ status: 429 },
108108
);
109109
} else {
110110
return NextResponse.json(
111111
{
112112
message: `Too many requests. Please try again in ${seconds} seconds.`,
113113
reason: decision.reason,
114114
},
115-
{ status: 429 }
115+
{ status: 429 },
116116
);
117117
}
118118
} else {

components/EmailForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function EmailForm() {
7878
/>
7979
</FormControl>
8080
<FormDescription>
81-
Just a test form - you won't receive any emails.
81+
Just a test form - you won&apos;t receive any emails.
8282
</FormDescription>
8383
<FormMessage />
8484
{errors.root?.serverError && (

components/main-nav.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function MainNav({ items }: MainNavProps) {
1313
return (
1414
<div className="flex gap-6 md:gap-10">
1515
<Link href="/" className="flex items-center space-x-2">
16-
<Icons.logo className="h-6 w-6" />
16+
<Icons.logo className="size-6" />
1717
<span className="inline-block font-bold">Arcjet Example App</span>
1818
</Link>
1919
{items?.length ? (
@@ -26,12 +26,12 @@ export function MainNav({ items }: MainNavProps) {
2626
href={item.href}
2727
className={cn(
2828
"flex items-center text-sm font-medium text-muted-foreground",
29-
item.disabled && "cursor-not-allowed opacity-80"
29+
item.disabled && "cursor-not-allowed opacity-80",
3030
)}
3131
>
3232
{item.title}
3333
</Link>
34-
)
34+
),
3535
)}
3636
</nav>
3737
) : null}

components/site-header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ export function SiteHeader() {
2323
buttonVariants({
2424
variant: "ghost",
2525
}),
26-
"w-9 px-0"
26+
"w-9 px-0",
2727
)}
2828
>
29-
<Icons.gitHub className="h-4 w-4" />
29+
<Icons.gitHub className="size-4" />
3030
<span className="sr-only">GitHub</span>
3131
</div>
3232
</Link>

components/theme-toggle.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export function ThemeToggle() {
1515
size="icon"
1616
onClick={() => setTheme(theme === "light" ? "dark" : "light")}
1717
>
18-
<Sun className="h-[1.5rem] w-[1.3rem] dark:hidden" />
19-
<Moon className="hidden h-5 w-5 dark:block" />
18+
<Sun className="h-6 w-[1.3rem] dark:hidden" />
19+
<Moon className="hidden size-5 dark:block" />
2020
<span className="sr-only">Toggle theme</span>
2121
</Button>
2222
);

components/ui/button.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const buttonVariants = cva(
3030
variant: "default",
3131
size: "default",
3232
},
33-
}
33+
},
3434
);
3535

3636
export interface ButtonProps
@@ -49,8 +49,8 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
4949
{...props}
5050
/>
5151
);
52-
}
52+
},
5353
);
5454
Button.displayName = "Button";
5555

56-
export { Button, buttonVariants };
56+
export { Button, buttonVariants };

components/ui/form.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ const Form = FormProvider;
1717

1818
type FormFieldContextValue<
1919
TFieldValues extends FieldValues = FieldValues,
20-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
20+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
2121
> = {
2222
name: TName;
2323
};
2424

2525
const FormFieldContext = React.createContext<FormFieldContextValue>(
26-
{} as FormFieldContextValue
26+
{} as FormFieldContextValue,
2727
);
2828

2929
const FormField = <
3030
TFieldValues extends FieldValues = FieldValues,
31-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
31+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
3232
>({
3333
...props
3434
}: ControllerProps<TFieldValues, TName>) => {
@@ -67,7 +67,7 @@ type FormItemContextValue = {
6767
};
6868

6969
const FormItemContext = React.createContext<FormItemContextValue>(
70-
{} as FormItemContextValue
70+
{} as FormItemContextValue,
7171
);
7272

7373
const FormItem = React.forwardRef<
@@ -174,4 +174,4 @@ export {
174174
FormDescription,
175175
FormMessage,
176176
FormField,
177-
};
177+
};

components/ui/input.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
1212
type={type}
1313
className={cn(
1414
"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",
15-
className
15+
className,
1616
)}
1717
ref={ref}
1818
{...props}
1919
/>
2020
);
21-
}
21+
},
2222
);
2323
Input.displayName = "Input";
2424

25-
export { Input };
25+
export { Input };

components/ui/label.tsx

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

77
const labelVariants = cva(
8-
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
8+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
99
);
1010

1111
const Label = React.forwardRef<
@@ -21,4 +21,4 @@ const Label = React.forwardRef<
2121
));
2222
Label.displayName = LabelPrimitive.Root.displayName;
2323

24-
export { Label };
24+
export { Label };

0 commit comments

Comments
 (0)