Skip to content

Commit 43aa1c6

Browse files
authored
Switch to vercel's biome setup (#543)
1 parent b864335 commit 43aa1c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+414
-201
lines changed

app/(auth)/actions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface LoginActionState {
1717

1818
export const login = async (
1919
_: LoginActionState,
20-
formData: FormData
20+
formData: FormData,
2121
): Promise<LoginActionState> => {
2222
try {
2323
const validatedData = authFormSchema.parse({
@@ -53,7 +53,7 @@ export interface RegisterActionState {
5353

5454
export const register = async (
5555
_: RegisterActionState,
56-
formData: FormData
56+
formData: FormData,
5757
): Promise<RegisterActionState> => {
5858
try {
5959
const validatedData = authFormSchema.parse({

app/(auth)/auth.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export const {
2020
providers: [
2121
Credentials({
2222
credentials: {},
23-
// biome-ignore lint/suspicious/noExplicitAny: TODO
2423
async authorize({ email, password }: any) {
2524
const users = await getUser(email);
2625
if (users.length === 0) return null;
26+
// biome-ignore lint: Forbidden non-null assertion.
2727
const passwordsMatch = await compare(password, users[0].password!);
28-
// biome-ignore lint/suspicious/noExplicitAny: TODO
28+
if (!passwordsMatch) return null;
2929
return users[0] as any;
3030
},
3131
}),
@@ -43,7 +43,6 @@ export const {
4343
token,
4444
}: {
4545
session: ExtendedSession;
46-
// biome-ignore lint/suspicious/noExplicitAny: TODO
4746
token: any;
4847
}) {
4948
if (session.user) {

app/(auth)/login/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Page() {
2020
login,
2121
{
2222
status: 'idle',
23-
}
23+
},
2424
);
2525

2626
useEffect(() => {

app/(auth)/register/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Page() {
2020
register,
2121
{
2222
status: 'idle',
23-
}
23+
},
2424
);
2525

2626
useEffect(() => {

app/(chat)/actions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use server';
22

3-
import { CoreMessage, type CoreUserMessage, generateText } from 'ai';
3+
import { type CoreUserMessage, generateText } from 'ai';
44
import { cookies } from 'next/headers';
55

66
import { customModel } from '@/lib/ai';

app/(chat)/api/chat/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function POST(request: Request) {
104104
}),
105105
execute: async ({ latitude, longitude }) => {
106106
const response = await fetch(
107-
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto`
107+
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto`,
108108
);
109109

110110
const weatherData = await response.json();
@@ -350,7 +350,7 @@ export async function POST(request: Request) {
350350
content: message.content,
351351
createdAt: new Date(),
352352
};
353-
}
353+
},
354354
),
355355
});
356356
} catch (error) {

app/(chat)/api/files/upload/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const FileSchema = z.object({
1616
['image/jpeg', 'image/png', 'application/pdf'].includes(file.type),
1717
{
1818
message: 'File type should be JPEG, PNG, or PDF',
19-
}
19+
},
2020
),
2121
});
2222

@@ -65,7 +65,7 @@ export async function POST(request: Request) {
6565
} catch (error) {
6666
return NextResponse.json(
6767
{ error: 'Failed to process request' },
68-
{ status: 500 }
68+
{ status: 500 },
6969
);
7070
}
7171
}

app/(chat)/api/history/route.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export async function GET() {
88
return Response.json('Unauthorized!', { status: 401 });
99
}
1010

11+
// biome-ignore lint: Forbidden non-null assertion.
1112
const chats = await getChatsByUserId({ id: session.user.id! });
1213
return Response.json(chats);
1314
}

app/(chat)/chat/[id]/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CoreMessage } from 'ai';
1+
22
import { cookies } from 'next/headers';
33
import { notFound } from 'next/navigation';
44

app/layout.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export default async function RootLayout({
5151
>
5252
<head>
5353
<script
54-
// biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
5554
dangerouslySetInnerHTML={{
5655
__html: THEME_COLOR_SCRIPT,
5756
}}

biome.json

+86-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3-
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": true },
43
"files": {
54
"ignoreUnknown": false,
65
"ignore": [
@@ -13,46 +12,118 @@
1312
".vercel"
1413
]
1514
},
15+
"vcs": {
16+
"enabled": true,
17+
"clientKind": "git",
18+
"defaultBranch": "main",
19+
"useIgnoreFile": true
20+
},
1621
"formatter": {
1722
"enabled": true,
18-
"useEditorconfig": true,
1923
"formatWithErrors": false,
2024
"indentStyle": "space",
2125
"indentWidth": 2,
2226
"lineEnding": "lf",
2327
"lineWidth": 80,
24-
"attributePosition": "auto",
25-
"bracketSpacing": true,
26-
"ignore": ["**/pnpm-lock.yaml", "lib/db/drizzle"]
28+
"attributePosition": "auto"
2729
},
28-
"organizeImports": { "enabled": true },
2930
"linter": {
3031
"enabled": true,
3132
"rules": {
3233
"recommended": true,
3334
"a11y": {
34-
"noSvgWithoutTitle": "off",
35-
"useKeyWithClickEvents": "off"
35+
"useHtmlLang": "warn",
36+
"noHeaderScope": "warn",
37+
"useValidAriaRole": {
38+
"level": "warn",
39+
"options": {
40+
"ignoreNonDom": false,
41+
"allowInvalidRoles": ["none", "text"]
42+
}
43+
},
44+
"useSemanticElements": "off",
45+
"noSvgWithoutTitle": "off",
46+
"useMediaCaption": "off",
47+
"noAutofocus": "off",
48+
"noBlankTarget": "off"
3649
},
37-
"style": {
38-
"noNonNullAssertion": "off"
50+
"complexity": {
51+
"noUselessStringConcat": "warn",
52+
"noForEach": "off",
53+
"noUselessSwitchCase": "off",
54+
"noUselessThisAlias": "off"
3955
},
4056
"correctness": {
41-
"useExhaustiveDependencies": "off"
57+
"noUnusedImports": "warn",
58+
"useArrayLiterals": "warn",
59+
"noNewSymbol": "warn",
60+
"useJsxKeyInIterable": "off",
61+
"useExhaustiveDependencies": "off",
62+
"noUnnecessaryContinue": "off"
63+
},
64+
"security": {
65+
"noDangerouslySetInnerHtml": "off"
66+
},
67+
"style": {
68+
"useFragmentSyntax": "warn",
69+
"noYodaExpression": "warn",
70+
"useDefaultParameterLast": "warn",
71+
"useExponentiationOperator": "off",
72+
"noUnusedTemplateLiteral": "off",
73+
"noUselessElse": "off"
74+
},
75+
"suspicious": {
76+
"noExplicitAny": "off"
77+
},
78+
"nursery": {
79+
"noStaticElementInteractions": "warn",
80+
"noHeadImportInDocument": "warn",
81+
"noDocumentImportInPage": "warn",
82+
"noDuplicateElseIf": "warn",
83+
"noIrregularWhitespace": "warn",
84+
"useValidAutocomplete": "warn"
4285
}
4386
}
4487
},
4588
"javascript": {
89+
"jsxRuntime": "reactClassic",
4690
"formatter": {
4791
"jsxQuoteStyle": "double",
4892
"quoteProperties": "asNeeded",
49-
"trailingCommas": "es5",
93+
"trailingCommas": "all",
5094
"semicolons": "always",
5195
"arrowParentheses": "always",
96+
"bracketSpacing": true,
5297
"bracketSameLine": false,
5398
"quoteStyle": "single",
54-
"attributePosition": "auto",
55-
"bracketSpacing": true
99+
"attributePosition": "auto"
100+
}
101+
},
102+
"json": {
103+
"formatter": {
104+
"enabled": true,
105+
"trailingCommas": "none"
106+
},
107+
"parser": {
108+
"allowComments": true,
109+
"allowTrailingCommas": false
110+
}
111+
},
112+
"css": {
113+
"formatter": { "enabled": false },
114+
"linter": { "enabled": false }
115+
},
116+
"organizeImports": { "enabled": false },
117+
"overrides": [
118+
{
119+
"include": ["playwright/**", "tooling/playwright/src/test/test.ts"],
120+
"linter": {
121+
"rules": {
122+
"correctness": {
123+
"noEmptyPattern": "off"
124+
}
125+
}
126+
}
56127
}
57-
}
128+
]
58129
}

biome.jsonc

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"files": {
4+
"ignoreUnknown": false,
5+
"ignore": [
6+
"**/pnpm-lock.yaml",
7+
"lib/db/migrations",
8+
"lib/editor/react-renderer.tsx",
9+
"node_modules",
10+
".next",
11+
"public",
12+
".vercel"
13+
]
14+
},
15+
"vcs": {
16+
"enabled": true,
17+
"clientKind": "git",
18+
"defaultBranch": "main",
19+
"useIgnoreFile": true
20+
},
21+
"formatter": {
22+
"enabled": true,
23+
"formatWithErrors": false,
24+
"indentStyle": "space",
25+
"indentWidth": 2,
26+
"lineEnding": "lf",
27+
"lineWidth": 80,
28+
"attributePosition": "auto"
29+
},
30+
"linter": {
31+
"enabled": true,
32+
"rules": {
33+
"recommended": true,
34+
"a11y": {
35+
"useHtmlLang": "warn", // Not in recommended ruleset, turning on manually
36+
"noHeaderScope": "warn", // Not in recommended ruleset, turning on manually
37+
"useValidAriaRole": {
38+
"level": "warn",
39+
"options": {
40+
"ignoreNonDom": false,
41+
"allowInvalidRoles": ["none", "text"]
42+
}
43+
},
44+
"useSemanticElements": "off", // Rule is buggy, revisit later
45+
"noSvgWithoutTitle": "off", // We do not intend to adhere to this rule
46+
"useMediaCaption": "off", // We would need a cultural change to turn this on
47+
"noAutofocus": "off", // We're highly intentional about when we use autofocus
48+
"noBlankTarget": "off" // Covered by Conformance
49+
},
50+
"complexity": {
51+
"noUselessStringConcat": "warn", // Not in recommended ruleset, turning on manually
52+
"noForEach": "off", // forEach is too familiar to ban
53+
"noUselessSwitchCase": "off", // Turned off due to developer preferences
54+
"noUselessThisAlias": "off" // Turned off due to developer preferences
55+
},
56+
"correctness": {
57+
"noUnusedImports": "warn", // Not in recommended ruleset, turning on manually
58+
"useArrayLiterals": "warn", // Not in recommended ruleset, turning on manually
59+
"noNewSymbol": "warn", // Not in recommended ruleset, turning on manually
60+
"useJsxKeyInIterable": "off", // Rule is buggy, revisit later
61+
"useExhaustiveDependencies": "off", // Community feedback on this rule has been poor, we will continue with ESLint
62+
"noUnnecessaryContinue": "off" // Turned off due to developer preferences
63+
},
64+
"security": {
65+
"noDangerouslySetInnerHtml": "off" // Covered by Conformance
66+
},
67+
"style": {
68+
"useFragmentSyntax": "warn", // Not in recommended ruleset, turning on manually
69+
"noYodaExpression": "warn", // Not in recommended ruleset, turning on manually
70+
"useDefaultParameterLast": "warn", // Not in recommended ruleset, turning on manually
71+
"useExponentiationOperator": "off", // Obscure and arguably not easily readable
72+
"noUnusedTemplateLiteral": "off", // Stylistic opinion
73+
"noUselessElse": "off" // Stylistic opinion
74+
},
75+
"suspicious": {
76+
"noExplicitAny": "off" // We trust Vercelians to use any only when necessary
77+
},
78+
"nursery": {
79+
"noStaticElementInteractions": "warn",
80+
"noHeadImportInDocument": "warn",
81+
"noDocumentImportInPage": "warn",
82+
"noDuplicateElseIf": "warn",
83+
"noIrregularWhitespace": "warn",
84+
"useValidAutocomplete": "warn"
85+
}
86+
}
87+
},
88+
"javascript": {
89+
"jsxRuntime": "reactClassic",
90+
"formatter": {
91+
"jsxQuoteStyle": "double",
92+
"quoteProperties": "asNeeded",
93+
"trailingCommas": "all",
94+
"semicolons": "always",
95+
"arrowParentheses": "always",
96+
"bracketSpacing": true,
97+
"bracketSameLine": false,
98+
"quoteStyle": "single",
99+
"attributePosition": "auto"
100+
}
101+
},
102+
"json": {
103+
"formatter": {
104+
"enabled": true,
105+
"trailingCommas": "none"
106+
},
107+
"parser": {
108+
"allowComments": true,
109+
"allowTrailingCommas": false
110+
}
111+
},
112+
"css": {
113+
"formatter": { "enabled": false },
114+
"linter": { "enabled": false }
115+
},
116+
"organizeImports": { "enabled": false },
117+
"overrides": [
118+
// Playwright requires an object destructure, even if empty
119+
// https://github.com/microsoft/playwright/issues/30007
120+
{
121+
"include": ["playwright/**"],
122+
"linter": {
123+
"rules": {
124+
"correctness": {
125+
"noEmptyPattern": "off"
126+
}
127+
}
128+
}
129+
}
130+
]
131+
}

0 commit comments

Comments
 (0)