From 8a029ed0dc5f7d16fd9b8e1b6a7942eef99b47fd Mon Sep 17 00:00:00 2001 From: Hong Minhee Date: Tue, 23 Jun 2026 23:09:09 +0900 Subject: [PATCH 01/13] Switch init templates to Oxfmt and Oxlint Generated Node.js and Bun projects now share the Oxc toolchain for formatting and linting. The generated Oxlint config loads Fedify's rules through @fedify/lint/oxlint, and generated projects get Oxc editor recommendations and package scripts for format, format:check, and lint. The init test harness now runs the generated formatter and linter for hydrated Node.js and Bun projects. Framework scaffolders that produce conflicting ESLint artifacts or unformatted files are cleaned up before Fedify writes its files. Closes https://github.com/fedify-dev/fedify/issues/703 Assisted-by: Codex:gpt-5.5 --- CHANGES.md | 14 ++ docs/cli.md | 4 +- docs/install.md | 46 ++-- docs/tutorial/astro-blog.md | 11 +- docs/tutorial/content-sharing.md | 12 +- docs/tutorial/microblog.md | 25 +- docs/tutorial/threadiverse.md | 81 ++---- packages/init/src/action/cleanup.ts | 53 ++++ packages/init/src/action/configs.test.ts | 235 +++++++++++++++--- packages/init/src/action/configs.ts | 15 +- packages/init/src/action/deps.ts | 2 +- packages/init/src/action/mod.ts | 2 + packages/init/src/action/patch.ts | 3 +- packages/init/src/action/templates.ts | 17 +- packages/init/src/json/biome.json | 19 -- packages/init/src/json/deps.json | 4 +- packages/init/src/json/oxfmt.json | 17 ++ packages/init/src/json/oxlint.json | 40 +++ packages/init/src/json/vscode-settings.json | 21 +- .../src/templates/bare-bones/main/bun.ts.tpl | 6 +- .../src/templates/bare-bones/main/node.ts.tpl | 15 +- .../templates/defaults/eslint.config.ts.tpl | 3 - .../templates/defaults/federation.oxc.ts.tpl | 21 ++ .../src/templates/elysia/index/bun.ts.tpl | 2 +- .../src/templates/elysia/index/node.ts.tpl | 4 +- .../init/src/templates/hono/index/node.ts.tpl | 3 +- .../init/src/templates/next/middleware.ts.tpl | 6 +- .../src/templates/nitro/nitro.config.ts.tpl | 4 +- .../src/templates/nitro/server/error.ts.tpl | 2 +- .../nitro/server/middleware/federation.ts.tpl | 8 +- .../nitro/server/routes/index.ts.tpl | 11 + packages/init/src/test/create.ts | 33 +++ packages/init/src/types.ts | 8 + packages/init/src/utils.ts | 54 +++- packages/init/src/webframeworks.test.ts | 34 ++- packages/init/src/webframeworks/astro.ts | 9 +- packages/init/src/webframeworks/bare-bones.ts | 9 +- packages/init/src/webframeworks/const.ts | 4 +- packages/init/src/webframeworks/elysia.ts | 9 +- packages/init/src/webframeworks/express.ts | 11 +- packages/init/src/webframeworks/hono.ts | 11 +- packages/init/src/webframeworks/next.ts | 14 +- packages/init/src/webframeworks/nitro.ts | 35 ++- packages/init/src/webframeworks/nuxt.ts | 9 +- packages/init/src/webframeworks/solidstart.ts | 9 +- packages/init/src/webframeworks/utils.ts | 10 + 46 files changed, 666 insertions(+), 299 deletions(-) create mode 100644 packages/init/src/action/cleanup.ts delete mode 100644 packages/init/src/json/biome.json create mode 100644 packages/init/src/json/oxfmt.json create mode 100644 packages/init/src/json/oxlint.json delete mode 100644 packages/init/src/templates/defaults/eslint.config.ts.tpl create mode 100644 packages/init/src/templates/defaults/federation.oxc.ts.tpl create mode 100644 packages/init/src/templates/nitro/server/routes/index.ts.tpl diff --git a/CHANGES.md b/CHANGES.md index e31c26545..db42f5448 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -296,6 +296,12 @@ To be released. corresponding `@fedify/init` update, which skips automatic dependency installation after scaffolding. [[#720], [#776] by fru1tworld] + - Switched Node.js and Bun projects generated by `fedify init` from Biome + plus ESLint to Oxfmt plus Oxlint. New projects now get *.oxfmtrc.json*, + *.oxlintrc.json*, Oxc editor recommendations, and package scripts for + `format`, `format:check`, and `lint`; the Oxlint config loads Fedify's + rules through `@fedify/lint/oxlint`. [[#703], [#818]] + - Added the `fedify bench` command for benchmarking Fedify federation workloads. It acts as a synthetic remote actor that drives ActivityPub-specific load (signed inbox deliveries and WebFinger lookups) @@ -328,6 +334,7 @@ To be released. results. This change is published as benchmark report schema version 3 and comparison report schema version 1. [[#744], [#786], [#804]] +[#703]: https://github.com/fedify-dev/fedify/issues/703 [#720]: https://github.com/fedify-dev/fedify/issues/720 [#776]: https://github.com/fedify-dev/fedify/pull/776 [#783]: https://github.com/fedify-dev/fedify/issues/783 @@ -337,6 +344,7 @@ To be released. [#801]: https://github.com/fedify-dev/fedify/pull/801 [#802]: https://github.com/fedify-dev/fedify/pull/802 [#804]: https://github.com/fedify-dev/fedify/pull/804 +[#818]: https://github.com/fedify-dev/fedify/pull/818 ### @fedify/fixture @@ -390,6 +398,12 @@ To be released. root, or when you want to inspect the generated files before installing. [[#720], [#776] by fru1tworld] + - Switched generated Node.js and Bun projects from Biome plus ESLint to + Oxfmt plus Oxlint. New projects now get *.oxfmtrc.json*, + *.oxlintrc.json*, Oxc editor recommendations, and package scripts for + `format`, `format:check`, and `lint`; the Oxlint config loads Fedify's + rules through `@fedify/lint/oxlint`. [[#703], [#818]] + ### @fedify/lint - Added official Oxlint support through a new `@fedify/lint/oxlint` subpath diff --git a/docs/cli.md b/docs/cli.md index 394ebf845..588803b74 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -250,8 +250,8 @@ project. It will ask you a few questions to set up the project: > [!TIP] > Projects created with `fedify init` automatically include [`@fedify/lint`] > for consistent code linting. Deno projects get a lint plugin configured in -> *deno.json*, while Node.js and Bun projects get an *eslint.config.ts* with -> `@fedify/lint`. +> *deno.json*, while Node.js and Bun projects get an *.oxlintrc.json* with +> `@fedify/lint/oxlint`. > [!NOTE] > If you find the full `@fedify/cli` toolchain too heavy for your needs, you diff --git a/docs/install.md b/docs/install.md index e41382153..ab767d3e9 100644 --- a/docs/install.md +++ b/docs/install.md @@ -230,37 +230,21 @@ it as the default formatter for JavaScript and TypeScript: Deno's [*Set up your environment*] guide covers other editors and shells. *For Node.js/Bun projects*, `fedify init` writes a *.vscode/extensions.json* -that recommends the [Biome extension] and the [ESLint extension]: +that recommends the [Oxc extension]: ~~~~ json [.vscode/extensions.json] -{ "recommendations": ["biomejs.biome", "dbaeumer.vscode-eslint"] } +{ "recommendations": ["oxc.oxc-vscode"] } ~~~~ -The matching *.vscode/settings.json* sets Biome as the default formatter and -runs Biome's import organiser on save: +The matching *.vscode/settings.json* sets Oxfmt as the default formatter and +enables Oxc's fix-all action on save: ~~~~ jsonc [.vscode/settings.json] { "editor.detectIndentation": false, "editor.indentSize": 2, "editor.insertSpaces": true, - "[typescript]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports.biome": "always" - } - } - // The same block applies to [javascript], [javascriptreact], - // [typescriptreact], [json], and [jsonc]. -} -~~~~ - -If you prefer [Oxc] over Biome and ESLint, install the [oxc-vscode] -extension and swap the formatter: - -~~~~ jsonc [.vscode/settings.json] -{ + "oxc.fmt.configPath": ".oxfmtrc.json", "[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode", "editor.formatOnSave": true, @@ -268,15 +252,14 @@ extension and swap the formatter: "source.fixAll.oxc": "always" } } + // The same block applies to [javascript], [javascriptreact], + // [typescriptreact], [json], and [jsonc]. } ~~~~ [Deno extension]: https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno [*Set up your environment*]: https://docs.deno.com/runtime/getting_started/setup_your_environment/ -[Biome extension]: https://marketplace.visualstudio.com/items?itemName=biomejs.biome -[ESLint extension]: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint -[Oxc]: https://oxc.rs/ -[oxc-vscode]: https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode +[Oxc extension]: https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode ### Zed @@ -319,10 +302,9 @@ Zed's [Deno language docs][zed-deno] cover the available options. [Hackers' Pub] is a real-world reference. *For Node.js/Bun projects*, Zed enables its bundled TypeScript language -server out of the box; the typical addition is wiring up Biome (or the -formatter you chose) for `editor.formatOnSave`-style behaviour. See Zed's -[TypeScript language docs][zed-ts] for setup. If you prefer [Oxc] instead, -set Oxc as the language server and turn on its fix-all action on format: +server out of the box; the typical addition is wiring up Oxc for formatting +and lint fixes. See Zed's [TypeScript language docs][zed-ts] for setup. +Set Oxc as the language server and turn on its fix-all action on format: ~~~~ jsonc [.zed/settings.json] { @@ -343,9 +325,9 @@ Linting `fedify init` configures the [`@fedify/lint`] plugin automatically: Deno projects pick it up through `lint.plugins` in *deno.json*, and Node.js/Bun -projects through a generated *eslint.config.ts*. For the full rule list, -configuration options, and how to run the linter, see the -[*Linting*](./manual/lint.md) chapter. +projects through a generated *.oxlintrc.json* using `@fedify/lint/oxlint`. +For the full rule list, configuration options, and how to run the linter, see +the [*Linting*](./manual/lint.md) chapter. [`@fedify/lint`]: https://jsr.io/@fedify/lint diff --git a/docs/tutorial/astro-blog.md b/docs/tutorial/astro-blog.md index c83e3515e..832daf37a 100644 --- a/docs/tutorial/astro-blog.md +++ b/docs/tutorial/astro-blog.md @@ -198,7 +198,8 @@ After a moment, you'll have a working project with the following structure: - *middleware.ts* — Connects Fedify to Astro's request pipeline - *public/* — Files served as-is (favicon, etc.) - *astro.config.ts* — Astro configuration - - *biome.json* — Code formatter and linter settings + - *.oxfmtrc.json* — Code formatter settings + - *.oxlintrc.json* — Code linter settings - *package.json* — Package metadata and scripts - *tsconfig.json* — TypeScript settings @@ -215,9 +216,9 @@ includes settings for it. After [installing VS Code], open the project folder: *File* → *Open Folder…*. If a popup asks you to install the recommended extensions, click *Install -All*. This installs the [Biome extension] (formats and lints your code on -save) and the [Astro extension] (syntax highlighting and IntelliSense for -*.astro* files). +All*. This installs the [Oxc extension] (formats and lints JavaScript and +TypeScript on save) and the [Astro extension] (syntax highlighting and +IntelliSense for *.astro* files). Let's verify the project works. First, install the dependencies: @@ -284,7 +285,7 @@ Stop the dev server with Ctrl+C for now. [Visual Studio Code]: https://code.visualstudio.com/ [installing VS Code]: https://code.visualstudio.com/docs/setup/setup-overview -[Biome extension]: https://marketplace.visualstudio.com/items?itemName=biomejs.biome +[Oxc extension]: https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode [Astro extension]: https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode [actor]: https://www.w3.org/TR/activitypub/#actors diff --git a/docs/tutorial/content-sharing.md b/docs/tutorial/content-sharing.md index 9967007a2..eef00b083 100644 --- a/docs/tutorial/content-sharing.md +++ b/docs/tutorial/content-sharing.md @@ -223,7 +223,8 @@ The most interesting files and directories are: - *nuxt.config.ts*: Nuxt's configuration file; already has `@fedify/nuxt` wired up as a module. - *package.json*: npm metadata and dependencies. - - *biome.json*: [Biome] formatter and import-sorting configuration. + - *.oxfmtrc.json*: [Oxfmt] formatter configuration. + - *.oxlintrc.json*: [Oxlint] configuration, including Fedify lint rules. - *tsconfig.json*: TypeScript compiler references to the generated Nuxt type files. @@ -233,7 +234,8 @@ TypeScript in their `