Docs

Guide 09

LintingBailiff

09. Bailiff

Bailiff is an ESLint plugin plus a CLI wrapper. Violations show up as editor squiggles, so nobody has to remember to leave a code review comment.

This is the feature that separates Avelon from a boilerplate. A template is advice. A linter is a decision.


Rules

Every rule ships with a documented reason, and an autofix or codemod where one is possible. A rule you can't explain in 1 sentence doesn't belong in the set.

Every rule is an error except controller-thinness, which is a warning:

  • no-vendor-import - no vendor SDK imported outside a driver package or avelon.config.ts
  • no-cross-layer - Views can't import Models. Controllers can't import Controllers. Models can't import anything under Http/
  • no-orphan-query - database access only in Models, Actions, Errands, and seeds. Never in a component or a page
  • no-unwarded - Scrivener.unwarded() only in app/Errands/ and database/seeds/
  • require-ward - every model has a ward
  • no-raw-outside-drivers - driver.raw() only in app/Drivers/, avelon.config.ts, or behind an explicit disable comment
  • no-hand-edited-generated - any diff to generated paths that didn't come from a generator
  • no-bun-in-core - @avelonjs/core and @avelonjs/orm may not import bun:*
  • no-model-across-boundary - a model instance passed to view() instead of a serializer
  • require-request - a write action validates through a Request
  • no-fake-transaction - sequential writes wrapped in try/catch and named like a transaction
  • relation-depth - .with() chains past the configured driver's maxRelationDepth
  • no-lib-dumping - there is no lib/. A file has a home or it doesn't exist
  • no-not-supported-error - throwing on an unsupported capability instead of typing it away
  • attribute-schema-match - model attribute declarations match database/types.ts
  • controller-thinness - a controller action past N statements suggests an Action
  • no-any-public - any in an exported signature
  • require-disable-reason - a bailiff-disable-next-line comment names the rule and a reason after --

Why Each Error Rule Exists

no-vendor-import

This is the whole driver system. One import in a controller and the abstraction is decorative.

no-cross-layer

Keeps the structure legible after the person who set it up leaves. A view importing a model is how "just this once" becomes an architecture.

no-orphan-query

Stops the pattern where a component fetches its own data. That's how you get 40 queries on a page and no way to see them.

no-unwarded and require-ward

Data leak prevention. A model without a ward is a table anybody can read.

no-hand-edited-generated

Protects the upgrade path. A hand-edit to a generated router silently disappears at the next sync, and the person who made it won't connect the two events.

no-model-across-boundary

Turns a confusing serialization error at runtime into a clear one at authoring time.

no-fake-transaction

Subtle, and worth the rule. Code that reads as atomic and isn't produces partial writes under failure. Reviewers don't catch it because it looks correct.

attribute-schema-match

Makes a column rename a type error rather than an incident.


Escape Hatches

Every rule can be disabled inline, and every disable needs a reason:

// bailiff-disable-next-line no-raw-outside-drivers -- pgvector similarity, no IR support yet
const sql = DB.raw()

A bare // bailiff-disable-next-line with no reason is itself an error.

This matters more than the rules do. A linter with no escape hatch gets disabled wholesale, and then you lose the entire thesis.

A disable with a reason is a searchable list of everywhere the framework wasn't good enough. That's a roadmap.


Running It

reeve bailiff
reeve bailiff --fix
reeve bailiff --explain no-orphan-query
  • reeve bailiff runs all rules
  • --fix runs the autofixable rules only

What a Scan Skips

A default scan skips:

  • node_modules
  • .next
  • dist
  • archive/
  • spikes/

Archive trees are history and spikes are throwaway, so neither is product code. Application and library code still has to obey the rules.

Tests under @avelonjs/core and @avelonjs/orm may import bun:test, because they aren't the runtime graph. bun:* in those packages' src/ is still an error.

Where It Runs

Bailiff ships in reeve doctor and in the default CI workflow.

Editor integration is the ESLint plugin, so you don't need a separate extension.


Configuration

Rules are on by default.

A project that lints with ESLint directly can downgrade a rule to warn or disable it. Do that in its ESLint config, after bailiff.configs.recommended.

reeve bailiff always lints with the recommended config, so CI reports every rule at its default severity.

A project-specific rule uses the same plugin API the built-in rules use.