Advanced

Formatting

Keep Routecraft DSL chains compact with the Prettier plugin.

Routecraft recommends formatting projects with @routecraft/prettier-plugin-routecraft. It overrides Prettier's layout for fluent builder closures so nested .choice(), .when(), and .otherwise() chains stay shallow instead of indenting a level for every closure:

.choice((c) => c
  .when(isUrgent, (b) => b.to(urgent))
  .otherwise((b) => b))

Installation

bun add -d prettier @routecraft/prettier-plugin-routecraft

Configuration

Add the plugin to your Prettier config:

// prettier.config.mjs
export default {
  plugins: ['@routecraft/prettier-plugin-routecraft'],
}

Or in .prettierrc:

{
  "plugins": ["@routecraft/prettier-plugin-routecraft"]
}

Then format as usual:

bunx prettier --write .

The plugin only adjusts Routecraft builder closures; everything else is left to Prettier's defaults.

Linting

Enforce Routecraft authoring best practices with ESLint.

Operations reference

The choice, split, and aggregate operations the plugin formats.

Previous
Linting