mirror of
				https://github.com/zws-im/zws.git
				synced 2025-10-30 23:27:52 +02:00 
			
		
		
		
	build: update Biome config & CLI usage
This commit is contained in:
		| @@ -31,7 +31,6 @@ export class BlockedUrlsService { | ||||
| 		return results.some(Boolean); | ||||
| 	} | ||||
|  | ||||
| 	// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: I don't want to make this a separate function | ||||
| 	public matchesCaptchaPhishHeuristic(url: URL): boolean { | ||||
| 		let score = 0; | ||||
|  | ||||
|   | ||||
| @@ -36,31 +36,21 @@ const DEFAULT_SHORT_CHARS: readonly string[] = [ | ||||
| ]; | ||||
|  | ||||
| export const env = cleanEnv(process.env, { | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	NODE_ENV: str({ default: 'production', choices: ['production', 'development', 'staging'] }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	PORT: port({ default: 3000 }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	DATABASE_URL: url({ desc: 'PostgreSQL URL' }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	SENTRY_DSN: url({ desc: 'Sentry DSN' }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	REDIS_URL: url({ desc: 'Redis URL' }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	WEBSITE_URL: url({ desc: 'Website URL' }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	SHORT_LENGTH: num({ desc: 'Number of characters to generate in a shortened URL', default: 7 }), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	SHORT_CHARS: json<readonly string[]>({ | ||||
| 		desc: 'Characters to use in shortened URLs', | ||||
| 		default: DEFAULT_SHORT_CHARS, | ||||
| 	}), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	SHORT_REWRITES: json<Record<string, string>>({ | ||||
| 		desc: 'A mapping of characters to apply to short IDs before they are used', | ||||
| 		default: {}, | ||||
| 	}), | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	GOOGLE_API_KEY: str({ desc: 'Google API Key' }), | ||||
| }); | ||||
|  | ||||
|   | ||||
| @@ -1,3 +1 @@ | ||||
| // biome-ignore lint/performance/noReExportAll: This is not a frontend app | ||||
| // biome-ignore lint/performance/noBarrelFile: This is not a frontend app | ||||
| export * as Schema from './schema'; | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| import { HttpException, type INestApplication, Inject, Injectable, Logger } from '@nestjs/common'; | ||||
| import { captureException } from '@sentry/bun'; | ||||
| // biome-ignore lint/style/noNamespaceImport: This is not a frontend app | ||||
| import * as trpcExpress from '@trpc/server/adapters/express'; | ||||
| import cors from 'cors'; | ||||
| import { ConfigService } from '../config/config.service'; | ||||
|   | ||||
| @@ -7,7 +7,6 @@ const API_URL = process.env.NEXT_PUBLIC_API_URL; | ||||
|  | ||||
| assert(API_URL, 'Missing NEXT_PUBLIC_API_URL env var'); | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default async function UrlSubpathPage({ | ||||
| 	params: rawParams, | ||||
| 	searchParams: rawSearchParams, | ||||
|   | ||||
| @@ -2,7 +2,6 @@ import { ArrowRightIcon } from '@heroicons/react/20/solid'; | ||||
| import { Button } from '../components/button'; | ||||
| import { H1 } from '../components/headings/h1'; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function UrlBlockedPage() { | ||||
| 	return ( | ||||
| 		<main className='flex flex-col items-center justify-center gap-y-4 max-md:pt-48 max-sm:pt-32 md:pt-72'> | ||||
|   | ||||
| @@ -13,7 +13,6 @@ export const metadata: Metadata = { | ||||
| 	}, | ||||
| }; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function ApiSchemaPage() { | ||||
| 	return ( | ||||
| 		<main className='flex flex-col items-center justify-center gap-y-4'> | ||||
|   | ||||
| @@ -10,7 +10,6 @@ const GITHUB_STARGAZERS_LINK_HEADER_REGEXP = /^.+,.+page=(?<stars>\d+).+$/; | ||||
|  | ||||
| async function getGitHubStars(): Promise<number> { | ||||
| 	const query = new URLSearchParams({ | ||||
| 		// biome-ignore lint/style/useNamingConvention: Can't use camelcase here | ||||
| 		per_page: (1).toString(), | ||||
| 	}); | ||||
| 	const response = await fetch(`https://api.github.com/repos/zws-im/zws/stargazers?${query}`, { | ||||
|   | ||||
| @@ -5,7 +5,6 @@ import { ArrowPathIcon, CheckIcon } from '@heroicons/react/20/solid'; | ||||
| import va from '@vercel/analytics'; | ||||
| import clsx from 'clsx'; | ||||
| import { type ChangeEvent, FormEvent, useEffect, useState } from 'react'; | ||||
| // biome-ignore lint/style/noNamespaceImport: Importing this as a namespace is fine and more readable | ||||
| import * as motion from '../../motion'; | ||||
|  | ||||
| import { trpc } from '@/app/trpc'; | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| 'use client'; | ||||
| // biome-ignore lint/style/useNamingConvention: This is a React component | ||||
| import SwaggerUI from 'swagger-ui-react'; | ||||
| import 'swagger-ui-react/swagger-ui.css'; | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,6 @@ import { H1 } from './components/headings/h1'; | ||||
|  | ||||
| const SHOULD_REPORT_ERROR = process.env.NODE_ENV !== 'development'; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function ErrorPage({ error, reset }: { error: Error; reset: () => void }) { | ||||
| 	useEffect(() => { | ||||
| 		if (SHOULD_REPORT_ERROR) { | ||||
|   | ||||
| @@ -35,7 +35,6 @@ export const viewport: Viewport = { | ||||
|  | ||||
| const inter = Lato({ weight: ['400', '700'], subsets: ['latin'] }); | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function RootLayout({ children }: { children: React.ReactNode }) { | ||||
| 	return ( | ||||
| 		<> | ||||
|   | ||||
| @@ -13,7 +13,6 @@ export const metadata: Metadata = { | ||||
| 	}, | ||||
| }; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function NotFound() { | ||||
| 	return ( | ||||
| 		<main className='flex flex-col items-center justify-center gap-4 sm:pt-16 md:pt-36'> | ||||
|   | ||||
| @@ -14,7 +14,6 @@ export const metadata: Metadata = { | ||||
| 	}, | ||||
| }; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function HomePage() { | ||||
| 	return ( | ||||
| 		<main className='flex flex-col gap-8 md:gap-16 lg:gap-24'> | ||||
|   | ||||
| @@ -22,7 +22,6 @@ export const metadata: Metadata = { | ||||
| 	}, | ||||
| }; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function StatsPage() { | ||||
| 	return ( | ||||
| 		<main> | ||||
|   | ||||
| @@ -11,7 +11,6 @@ const apiUrl = new URL(API_URL); | ||||
|  | ||||
| const API_PATH_PREFIX = '/api/'; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default function middleware(request: NextRequest): Response { | ||||
| 	if (request.nextUrl.pathname.startsWith(API_PATH_PREFIX)) { | ||||
| 		// Redirect to API subdomain | ||||
|   | ||||
| @@ -7,9 +7,7 @@ dotenv.config({ path: path.join(__dirname, '..', '..', '.env') }); | ||||
| /** @type {import('next').NextConfig} */ | ||||
| const nextConfig = withPlausibleProxy()({ | ||||
| 	env: { | ||||
| 		// biome-ignore lint/style/useNamingConvention: Must use this naming convention for environment variables | ||||
| 		NEXT_PUBLIC_WEBSITE_URL: process.env.WEBSITE_URL, | ||||
| 		// biome-ignore lint/style/useNamingConvention: Must use this naming convention for environment variables | ||||
| 		NEXT_PUBLIC_API_URL: process.env.API_URL, | ||||
| 	}, | ||||
| 	productionBrowserSourceMaps: true, | ||||
|   | ||||
| @@ -30,5 +30,4 @@ const config: Config = { | ||||
| 	plugins: [], | ||||
| }; | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default config; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
| 	"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json", | ||||
| 	"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", | ||||
| 	"files": { | ||||
| 		"ignore": [".next", "node_modules", ".vercel", "**/package.json"] | ||||
| 	}, | ||||
| @@ -24,22 +24,15 @@ | ||||
| 	}, | ||||
| 	"linter": { | ||||
| 		"rules": { | ||||
| 			"all": true, | ||||
| 			"complexity": { | ||||
| 				"all": true, | ||||
| 				"noStaticOnlyClass": "off", | ||||
| 				"useLiteralKeys": "off" | ||||
| 			}, | ||||
| 			"nursery": { | ||||
| 				"all": false | ||||
| 			}, | ||||
| 			"style": { | ||||
| 				"all": true, | ||||
| 				"noParameterProperties": "off", | ||||
| 				"useImportType": "off" | ||||
| 			}, | ||||
| 			"suspicious": { | ||||
| 				"all": true, | ||||
| 				"noEmptyBlockStatements": "off" | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
| @@ -2,11 +2,9 @@ import type { Config } from 'drizzle-kit'; | ||||
| import { cleanEnv, str } from 'envalid'; | ||||
|  | ||||
| const env = cleanEnv(process.env, { | ||||
| 	// biome-ignore lint/style/useNamingConvention: This is an environment variable | ||||
| 	DATABASE_URL: str({ desc: 'PostgreSQL URL' }), | ||||
| }); | ||||
|  | ||||
| // biome-ignore lint/style/noDefaultExport: This must be a default export | ||||
| export default { | ||||
| 	schema: 'apps/api/src/db/schema.ts', | ||||
| 	dialect: 'postgresql', | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| 		"format": "prettier --check .", | ||||
| 		"format:write": "bun run format --write", | ||||
| 		"lint": "biome check .", | ||||
| 		"lint:fix": "biome check . --apply-unsafe", | ||||
| 		"lint:fix": "biome check . --write --unsafe", | ||||
| 		"migrate": "drizzle-kit migrate", | ||||
| 		"migrate:create": "drizzle-kit generate", | ||||
| 		"test": "bun run lint && bun run format && turbo run build type-check", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user