diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index eb99357..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable unicorn/no-empty-file */ -/* eslint-disable unicorn/prefer-module */ -module.exports = { - root: true, - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint", "prefer-let", "import", "promise", "unicorn"], - extends: [ - "prettier", - "plugin:@typescript-eslint/recommended", - "plugin:import/errors", - "plugin:import/typescript", - "plugin:import/warnings", - "plugin:promise/recommended", - "plugin:unicorn/recommended", - ], - settings: { - "import/resolver": { typescript: {} }, - }, - rules: { - "@typescript-eslint/explicit-module-boundary-types": "off", - - "no-unused-vars": "off", - "no-var": "off", - "prefer-const": "off", - - "prefer-let/prefer-let": 2, - - "unicorn/prevent-abbreviations": "off", - - "import/order": [ - "error", - { - alphabetize: { - order: "asc", - }, - groups: [ - "type", - "builtin", - "external", - "internal", - "parent", - ["sibling", "index"], - ], - "newlines-between": "always", - pathGroups: [], - pathGroupsExcludedImportTypes: [], - }, - ], - }, -}; diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..d6a3498 --- /dev/null +++ b/biome.json @@ -0,0 +1,55 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json", + "organizeImports": { + "enabled": true + }, + "files": { + "ignore": ["src/server/json-hash.ts"] + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "useHookAtTopLevel": "error" + }, + "performance": { + "noBarrelFile": "error", + "noReExportAll": "error" + }, + "style": { + "noNegationElse": "error", + "useConst": "off", + "useExportType": "off", + "useImportType": "off" + }, + "suspicious": { + "noConsoleLog": "warn", + "noEmptyBlockStatements": "warn", + "noSkippedTests": "error" + }, + "nursery": { + "useSortedClasses": { + "level": "error", + "options": { + "attributes": ["className", "class"], + "functions": ["cn", "tv"] + } + } + } + } + }, + "formatter": { "enabled": true }, + "vcs": { + "enabled": true, + "clientKind": "git", + "defaultBranch": "main", + "useIgnoreFile": true + }, + "overrides": [ + { + "include": ["**/*.md"], + "formatter": { "indentStyle": "tab" } + } + ] +} diff --git a/bun.lockb b/bun.lockb index c8aea11..af63e38 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 419c9f7..243f61b 100644 --- a/package.json +++ b/package.json @@ -62,12 +62,7 @@ "sponsor": { "url": "https://github.com/sponsors/sergiodxa" }, - "files": [ - "src", - "build", - "package.json", - "README.md" - ], + "files": ["src", "build", "package.json", "README.md"], "scripts": { "build": "tsc", "typecheck": "tsc --noEmit", @@ -102,28 +97,17 @@ } }, "devDependencies": { + "@biomejs/biome": "^1.9.4", "@cloudflare/workers-types": "^4.20241112.0", "@react-router/cloudflare": "^7.0.1", "@total-typescript/tsconfig": "^1.0.4", "@types/bun": "^1.1.14", - "@types/node": "^20.11.28", - "@typescript-eslint/eslint-plugin": "^7.2.0", - "@typescript-eslint/parser": "^7.2.0", - "eslint": "^8.57.0", - "eslint-config-prettier": "^9.1.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-prefer-let": "^3.0.1", - "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-testing-library": "^6.2.0", - "eslint-plugin-unicorn": "^53.0.0", "i18next": "^23.10.1", - "prettier": "^3.2.4", "remix-i18next": "^7.0.0", "typescript": "^5.7.2", "vite": "^5.4.11", "vite-tsconfig-paths": "^5.1.3", "zod": "^3.22.4" - } + }, + "trustedDependencies": ["@biomejs/biome"] } diff --git a/prettier.config.mjs b/prettier.config.mjs deleted file mode 100644 index f5e5a30..0000000 --- a/prettier.config.mjs +++ /dev/null @@ -1,9 +0,0 @@ -/** @type {import("prettier").Options} */ -const config = { - trailingComma: "all", - tabWidth: 2, - useTabs: true, - proseWrap: "always", -}; - -export default config; diff --git a/src/cloudflare.ts b/src/cloudflare.ts index 1859a2f..d38d6fe 100644 --- a/src/cloudflare.ts +++ b/src/cloudflare.ts @@ -1,11 +1,10 @@ import type { Fetcher, - RequestInit, KVNamespace, + RequestInit, } from "@cloudflare/workers-types"; -import type { Context } from "hono"; - import { createWorkersKVSessionStorage } from "@react-router/cloudflare"; +import type { Context } from "hono"; import { createMiddleware } from "hono/factory"; import { cacheHeader } from "pretty-cache-header"; import { @@ -13,7 +12,6 @@ import { type SessionData, createCookieSessionStorage, } from "react-router"; - import { session } from "./session.js"; interface StaticAssetsOptions { diff --git a/src/handler.ts b/src/handler.ts index fb0f798..d4c0503 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -1,7 +1,6 @@ import type { Context } from "hono"; -import type { AppLoadContext, ServerBuild } from "react-router"; - import { createMiddleware } from "hono/factory"; +import type { AppLoadContext, ServerBuild } from "react-router"; import { createRequestHandler } from "react-router"; export interface ReactRouterMiddlewareOptions { diff --git a/src/i18next.ts b/src/i18next.ts index 4fe8114..912cc92 100644 --- a/src/i18next.ts +++ b/src/i18next.ts @@ -1,8 +1,7 @@ import type { Context } from "hono"; +import { createMiddleware } from "hono/factory"; import type { FlatNamespace, TFunction } from "i18next"; import type { RemixI18NextOption } from "remix-i18next/server"; - -import { createMiddleware } from "hono/factory"; import { RemixI18Next } from "remix-i18next/server"; const i18nSymbol = Symbol().toString(); diff --git a/src/session.ts b/src/session.ts index 0af284e..c4a7549 100644 --- a/src/session.ts +++ b/src/session.ts @@ -1,7 +1,6 @@ import type { Context } from "hono"; -import type { Session, SessionData, SessionStorage } from "react-router"; - import { createMiddleware } from "hono/factory"; +import type { Session, SessionData, SessionStorage } from "react-router"; type Env = { Variables: Record; diff --git a/src/typed-env.ts b/src/typed-env.ts index ee7b5ff..839d6b5 100644 --- a/src/typed-env.ts +++ b/src/typed-env.ts @@ -1,7 +1,6 @@ import type { Context } from "hono"; -import type { z } from "zod"; - import { env } from "hono/adapter"; +import type { z } from "zod"; export function typedEnv( c: Context, diff --git a/test/cloudflare.test.ts b/test/cloudflare.test.ts index 86e1f8f..8f89826 100644 --- a/test/cloudflare.test.ts +++ b/test/cloudflare.test.ts @@ -1,8 +1,7 @@ +import { afterAll, describe, expect, mock, test } from "bun:test"; import { createWorkersKVSessionStorage } from "@react-router/cloudflare"; -import { describe, test, expect, mock, afterAll } from "bun:test"; import { Context } from "hono"; import { createCookieSessionStorage } from "react-router"; - import { cookieSession, staticAssets, diff --git a/test/handler.test.ts b/test/handler.test.ts index 5eeeda3..be55ce0 100644 --- a/test/handler.test.ts +++ b/test/handler.test.ts @@ -1,8 +1,6 @@ -import type { ServerBuild } from "react-router"; - -import { describe, test, expect, mock, afterAll } from "bun:test"; +import { afterAll, describe, expect, mock, test } from "bun:test"; import { Hono } from "hono"; - +import type { ServerBuild } from "react-router"; import { reactRouter } from "../src/handler"; const build = { diff --git a/test/security.test.ts b/test/security.test.ts index 2f237a3..f801434 100644 --- a/test/security.test.ts +++ b/test/security.test.ts @@ -1,6 +1,5 @@ -import { describe, test, expect, mock, afterAll } from "bun:test"; +import { afterAll, describe, expect, mock, test } from "bun:test"; import { Context } from "hono"; - import { httpsOnly } from "../src/security"; describe(httpsOnly.name, () => { diff --git a/test/session.test.ts b/test/session.test.ts index 17a5187..4ac2e28 100644 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -1,7 +1,6 @@ -import { describe, test, expect, mock, afterAll, spyOn } from "bun:test"; +import { afterAll, describe, expect, mock, spyOn, test } from "bun:test"; import { Context } from "hono"; import { createCookieSessionStorage } from "react-router"; - import { getSession, getSessionStorage, session } from "../src/session"; const sessionStorage = createCookieSessionStorage({ @@ -75,7 +74,6 @@ describe(session.name, () => { }); await middleware(c, next); - console.log("here"); expect(createSessionStorage).toHaveBeenCalledTimes(2); expect(c.set).toHaveBeenNthCalledWith( diff --git a/test/setup.ts b/test/setup.ts index e2f4f7c..d759d41 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -1,7 +1,6 @@ -import { createWorkersKVSessionStorage } from "@react-router/cloudflare"; import { mock } from "bun:test"; +import { createWorkersKVSessionStorage } from "@react-router/cloudflare"; import { createCookieSessionStorage } from "react-router"; - import * as session from "../src/session"; mock.module("@react-router/cloudflare", () => { diff --git a/test/trailing-slash.test.ts b/test/trailing-slash.test.ts index 66a1bc5..d03bfbc 100644 --- a/test/trailing-slash.test.ts +++ b/test/trailing-slash.test.ts @@ -1,6 +1,5 @@ -import { describe, test, expect, mock, afterAll } from "bun:test"; +import { afterAll, describe, expect, mock, test } from "bun:test"; import { Context } from "hono"; - import { trailingSlash } from "../src/trailing-slash"; describe(trailingSlash.name, () => {