Skip to content

Commit

Permalink
Switch to vercel's biome setuo
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed Nov 15, 2024
1 parent b864335 commit 9324ec6
Show file tree
Hide file tree
Showing 50 changed files with 324 additions and 242 deletions.
4 changes: 2 additions & 2 deletions app/(auth)/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface LoginActionState {

export const login = async (
_: LoginActionState,
formData: FormData
formData: FormData,
): Promise<LoginActionState> => {
try {
const validatedData = authFormSchema.parse({
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface RegisterActionState {

export const register = async (
_: RegisterActionState,
formData: FormData
formData: FormData,
): Promise<RegisterActionState> => {
try {
const validatedData = authFormSchema.parse({
Expand Down
5 changes: 2 additions & 3 deletions app/(auth)/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export const {
providers: [
Credentials({
credentials: {},
// biome-ignore lint/suspicious/noExplicitAny: TODO
async authorize({ email, password }: any) {
const users = await getUser(email);
if (users.length === 0) return null;
// biome-ignore lint: Forbidden non-null assertion.
const passwordsMatch = await compare(password, users[0].password!);
// biome-ignore lint/suspicious/noExplicitAny: TODO
if (!passwordsMatch) return null;
return users[0] as any;
},
}),
Expand All @@ -43,7 +43,6 @@ export const {
token,
}: {
session: ExtendedSession;
// biome-ignore lint/suspicious/noExplicitAny: TODO
token: any;
}) {
if (session.user) {
Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function Page() {
login,
{
status: 'idle',
}
},
);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function Page() {
register,
{
status: 'idle',
}
},
);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/(chat)/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { CoreMessage, type CoreUserMessage, generateText } from 'ai';
import { type CoreUserMessage, generateText } from 'ai';
import { cookies } from 'next/headers';

import { customModel } from '@/lib/ai';
Expand Down
4 changes: 2 additions & 2 deletions app/(chat)/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function POST(request: Request) {
}),
execute: async ({ latitude, longitude }) => {
const response = await fetch(
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto`
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto`,
);

const weatherData = await response.json();
Expand Down Expand Up @@ -350,7 +350,7 @@ export async function POST(request: Request) {
content: message.content,
createdAt: new Date(),
};
}
},
),
});
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions app/(chat)/api/files/upload/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const FileSchema = z.object({
['image/jpeg', 'image/png', 'application/pdf'].includes(file.type),
{
message: 'File type should be JPEG, PNG, or PDF',
}
},
),
});

Expand Down Expand Up @@ -65,7 +65,7 @@ export async function POST(request: Request) {
} catch (error) {
return NextResponse.json(
{ error: 'Failed to process request' },
{ status: 500 }
{ status: 500 },
);
}
}
2 changes: 1 addition & 1 deletion app/(chat)/chat/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoreMessage } from 'ai';

import { cookies } from 'next/headers';
import { notFound } from 'next/navigation';

Expand Down
1 change: 0 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export default async function RootLayout({
>
<head>
<script
// biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
dangerouslySetInnerHTML={{
__html: THEME_COLOR_SCRIPT,
}}
Expand Down
58 changes: 0 additions & 58 deletions biome.json

This file was deleted.

131 changes: 131 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"files": {
"ignoreUnknown": false,
"ignore": [
"**/pnpm-lock.yaml",
"lib/db/migrations",
"lib/editor/react-renderer.tsx",
"node_modules",
".next",
"public",
".vercel"
]
},
"vcs": {
"enabled": true,
"clientKind": "git",
"defaultBranch": "main",
"useIgnoreFile": true
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"useHtmlLang": "warn", // Not in recommended ruleset, turning on manually
"noHeaderScope": "warn", // Not in recommended ruleset, turning on manually
"useValidAriaRole": {
"level": "warn",
"options": {
"ignoreNonDom": false,
"allowInvalidRoles": ["none", "text"]
}
},
"useSemanticElements": "off", // Rule is buggy, revisit later
"noSvgWithoutTitle": "off", // We do not intend to adhere to this rule
"useMediaCaption": "off", // We would need a cultural change to turn this on
"noAutofocus": "off", // We're highly intentional about when we use autofocus
"noBlankTarget": "off" // Covered by Conformance
},
"complexity": {
"noUselessStringConcat": "warn", // Not in recommended ruleset, turning on manually
"noForEach": "off", // forEach is too familiar to ban
"noUselessSwitchCase": "off", // Turned off due to developer preferences
"noUselessThisAlias": "off" // Turned off due to developer preferences
},
"correctness": {
"noUnusedImports": "warn", // Not in recommended ruleset, turning on manually
"useArrayLiterals": "warn", // Not in recommended ruleset, turning on manually
"noNewSymbol": "warn", // Not in recommended ruleset, turning on manually
"useJsxKeyInIterable": "off", // Rule is buggy, revisit later
"useExhaustiveDependencies": "off", // Community feedback on this rule has been poor, we will continue with ESLint
"noUnnecessaryContinue": "off" // Turned off due to developer preferences
},
"security": {
"noDangerouslySetInnerHtml": "off" // Covered by Conformance
},
"style": {
"useFragmentSyntax": "warn", // Not in recommended ruleset, turning on manually
"noYodaExpression": "warn", // Not in recommended ruleset, turning on manually
"useDefaultParameterLast": "warn", // Not in recommended ruleset, turning on manually
"useExponentiationOperator": "off", // Obscure and arguably not easily readable
"noUnusedTemplateLiteral": "off", // Stylistic opinion
"noUselessElse": "off" // Stylistic opinion
},
"suspicious": {
"noExplicitAny": "off" // We trust Vercelians to use any only when necessary
},
"nursery": {
"noStaticElementInteractions": "warn",
"noHeadImportInDocument": "warn",
"noDocumentImportInPage": "warn",
"noDuplicateElseIf": "warn",
"noIrregularWhitespace": "warn",
"useValidAutocomplete": "warn"
}
}
},
"javascript": {
"jsxRuntime": "reactClassic",
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
},
"json": {
"formatter": {
"enabled": true,
"trailingCommas": "none"
},
"parser": {
"allowComments": true,
"allowTrailingCommas": false
}
},
"css": {
"formatter": { "enabled": false },
"linter": { "enabled": false }
},
"organizeImports": { "enabled": false },
"overrides": [
// Playwright requires an object destructure, even if empty
// https://github.com/microsoft/playwright/issues/30007
{
"include": ["playwright/**"],
"linter": {
"rules": {
"correctness": {
"noEmptyPattern": "off"
}
}
}
}
]
}
9 changes: 5 additions & 4 deletions components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
useSidebar,
} from '@/components/ui/sidebar';
import { BetterTooltip } from '@/components/ui/tooltip';
import Link from 'next/link';

export function AppSidebar({ user }: { user: User | undefined }) {
const router = useRouter();
Expand All @@ -28,21 +29,21 @@ export function AppSidebar({ user }: { user: User | undefined }) {
<SidebarHeader>
<SidebarMenu>
<div className="flex flex-row justify-between items-center">
<div
<Link
href="/"
onClick={() => {
setOpenMobile(false);
router.push('/');
router.refresh();
}}
className="flex flex-row gap-3 items-center"
>
<span className="text-lg font-semibold px-2 hover:bg-muted rounded-md cursor-pointer">
Chatbot
</span>
</div>
</Link>
<BetterTooltip content="New Chat" align="start">
<Button
variant="ghost"
type="button"
className="p-2 h-fit"
onClick={() => {
setOpenMobile(false);
Expand Down
2 changes: 1 addition & 1 deletion components/block-stream-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function PureBlockStreamHandler({

function areEqual(
prevProps: BlockStreamHandlerProps,
nextProps: BlockStreamHandlerProps
nextProps: BlockStreamHandlerProps,
) {
if (!prevProps.streamingData && !nextProps.streamingData) {
return true;
Expand Down
Loading

0 comments on commit 9324ec6

Please sign in to comment.