feat: use biome

This commit is contained in:
hamster1963 2024-12-26 14:36:51 +08:00
parent 8575aee27e
commit 8a93bda5b6
9 changed files with 95 additions and 45 deletions

View File

@ -1,8 +0,0 @@
{
"extends": ["next/core-web-vitals", "next/typescript"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@next/next/no-img-element": "off",
"react-hooks/exhaustive-deps": "off"
}
}

View File

@ -23,11 +23,8 @@ jobs:
- name: Install dependencies
run: bun install
- name: Run linter and fix issues
run: bun run lint:fix
- name: Run formatter
run: bun run format
- name: Run linter & formatter and fix issues
run: bun run check:fix
- name: Check for changes
id: check_changes

View File

@ -1,12 +0,0 @@
{
"semi": false,
"singleQuote": false,
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "all",
"importOrder": ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"endOfLine": "auto",
"plugins": ["prettier-plugin-tailwindcss", "@trivago/prettier-plugin-sort-imports"]
}

View File

@ -1,11 +1,11 @@
import fs from "fs"
import path from "path"
import { auth } from "@/auth"
import getEnv from "@/lib/env-entry"
import { GetServerIP } from "@/lib/serverFetch"
import fs from "fs"
import { AsnResponse, CityResponse, Reader } from "maxmind"
import { redirect } from "next/navigation"
import { NextRequest, NextResponse } from "next/server"
import path from "path"
export const dynamic = "force-dynamic"

85
biome.json Normal file
View File

@ -0,0 +1,85 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": { "ignoreUnknown": false, "ignore": [".next", "public"] },
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": { "noUselessTypeConstraint": "error" },
"correctness": {
"noUnusedVariables": "error",
"useArrayLiterals": "off",
"useExhaustiveDependencies": "off"
},
"style": { "noNamespace": "error", "useAsConstAssertion": "error" },
"suspicious": {
"noExplicitAny": "off",
"noExtraNonNullAssertion": "error",
"noMisleadingInstantiator": "error",
"noUnsafeDeclarationMerging": "error",
"useNamespaceKeyword": "error"
}
}
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "asNeeded",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": true
}
},
"overrides": [
{
"include": ["*.ts", "*.tsx", "*.mts", "*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidBuiltinInstantiation": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useConst": "error"
},
"suspicious": {
"noClassAssign": "off",
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off"
}
}
}
}
]
}

BIN
bun.lockb

Binary file not shown.

View File

@ -1,2 +0,0 @@
[install]
registry = "https://registry.npmmirror.com/"

View File

@ -6,19 +6,6 @@ export const localeItems = [
{ code: "ja", name: "日本語" },
{ code: "zh-t", name: "中文繁體" },
{ code: "zh", name: "中文简体" },
//{code: 'ar', name: 'العربية'},
//{code: 'de', name: 'Deutsch'},
//{code: 'es', name: 'Español'},
//{code: 'fr', name: 'Français'},
//{code: 'hi', name: 'हिन्दी'},
//{code: 'id', name: 'Bahasa Indonesia'},
//{code: 'it', name: 'Italiano'},
//{code: 'ko', name: '한국어'},
//{code: 'ms', name: 'Bahasa Melayu'},
//{code: 'pt', name: 'Português'},
//{code: 'ru', name: 'Русский'},
//{code: 'th', name: 'ไทย'},
//{code: 'vi', name: 'Tiếng Việt'},
]
export const locales = localeItems.map((item) => item.code)

View File

@ -5,9 +5,11 @@
"scripts": {
"dev": "next dev -p 3040",
"start": "node .next/standalone/server.js",
"lint": "next lint",
"lint:fix": "next lint --fix",
"format": "prettier --write .",
"lint": "biome lint",
"lint:fix": "biome lint --fix",
"format": "biome format --write .",
"check": "biome check",
"check:fix": "biome check --fix",
"build": "next build && cp -r .next/static .next/standalone/.next/ && cp -r public .next/standalone/",
"build-dev": "next build",
"start-dev": "next start"
@ -60,6 +62,7 @@
"typescript-eslint": "^8.18.2"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@next/bundle-analyzer": "^15.1.2",
"@tailwindcss/postcss": "^4.0.0-beta.8",
"@types/node": "^22.10.2",