Lint · adorn/eslint

Contract mistakes, caught at build time.

A typed typescript-eslint plugin that ships inside adorn as the adorn/eslint subpath. It moves adorn's runtime refusals, and the contracts that would silently go unenforced, into the editor and CI. Every message starts with an ADN id, the same id the runtime's development diagnostic for that problem carries.

Setup

terminal
npm i -D eslint typescript-eslint
eslint.config.mjs
import tseslint from 'typescript-eslint';
import adorn from 'adorn/eslint';

export default tseslint.config(
    ...tseslint.configs.recommended,
    { languageOptions: { parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname } } },
    adorn.configs.recommended, // or adorn.configs.strict, or ...adorn.boundary(['src/api/**', 'src/tools/**'])
);

Several rules read the type checker, so the config must be typed (projectService or project). A rule decides what is adorn's from adorn's own declared types and exported names, resolved through the checker, so an import alias still counts and a local function that happens to be called Contract does not. eslint and @typescript-eslint/utils are optional peers: only this subpath loads them, and import 'adorn' never does.

Presets

PresetWhat it is for
configs.recommendedCode that is wrong whatever your style: each rule moves a runtime refusal, or a contract that would silently go unenforced, to build time. The opt-out reason and @Optional() on a TypeScript-required parameter warn; contract coverage is off.
configs.strictrecommended plus the paradigm: every rule is an error, a TypeScript default must be published with @Default(), and every export that takes input has a contract. adorn's own examples and tests pass it in CI.
boundary(globs)recommended everywhere and strict on the files you name, such as API handlers and LLM tool modules. Spread it: ...adorn.boundary(['src/api/**']).

Rules

Each rule has its own page. Levels, fixes and descriptions are read from the plugin.

RuleIdrecommendedstrictFixChecks that
typed-parametersADN0001errorerrorEvery parameter of a contracted method carries a type-bearing decorator.
relation-in-signatureADN0005errorerrorArg(i, ...path) names a parameter of the signature and a property its type has.
optional-matches-tsADN0008error, {defaults: false}error, {defaults: true}A contracted method's optional parameters are optional to both TypeScript and adorn.
no-optional-on-requiredADN0008warnerroryes@Optional()/@Default() sits on a parameter TypeScript also lets a caller omit.
shape-fields-typedADN0010errorerrorA class used as an exact @Shape declares every instance field with a field decorator.
justify-opt-outADN0099warnerrorAn opt-out of a strict default carries an adorn-allow: <reason> comment.
clause-below-validateADN0501errorerroryesA clause decorator above @Validate() records after the install and is never enforced.
contract-spec-shapeADN0502errorerrorcontract() params are typed slots matching the function.
installer-presentADN0503errorerrorParameter constraints and clauses sit on a class with @Contract() or a method with @Validate().
no-sensitive-to-adorn-sinkADN0505errorerrorReport where a @Sensitive value reaches one of adorn's own emitters (@Log, a violation-message parameter). Report-only: adorn secures its own emissions, not a raw console.log.
contract-coverageADN0506offerrorEvery exported function and public method of an exported class that takes input has a contract.

Opt-outs say why

adorn is strict by default, with explicit opt-outs: {extra: 'allow'} on an object, extraArgs: 'allow' on a signature, and disableGuardEnforcement(). Each one carries its reason in an adorn-allow comment, on the opt-out's own lines or the line above it. The lint checks it; the runtime never reads it, and the contract never stores it, so a reason changes no snapshot or diff.

an opt-out with its reason
import { ObjectContracts, StringContracts } from 'adorn';

// adorn-allow: the upstream webhook adds fields we do not read
const payload = ObjectContracts.Fields({ id: StringContracts.NotEmpty() }, { extra: 'allow' });

A finding you keep on purpose is disabled with ESLint's own description, which the same rule checks: // eslint-disable-next-line adorn/installer-present -- <why>. See justify-opt-out.

Runtime diagnostic codes

In development, adorn reports problems it can only see at runtime through setContractDiagnosticsSink. Each diagnostic carries a stable code as data, beside the unchanged message: setContractDiagnosticsSink((message, { code }) => …). Where a lint rule finds the same problem, it carries the same id.

CodeProblemLint rule
ADN0001An untyped defaulted or rest parameter past the signature of a contracted method.typed-parameters
ADN0002An unsatisfiable constraint stack, on the installer and on toolSchemaFrom.runtime only
ADN0502A contract() required slot a default can never reach.contract-spec-shape
ADN0503Constraints that nothing installs: no @Contract(), no @Validate().installer-present
ADN0507A @Telemetry opt-in vetoed by @Sensitive.runtime only
ADN0508A parameter decorator on a rest parameter, which types only the first argument it collects.runtime only
ADN0509A field contract on a class no construction wrapper covers, whose field is defined with [[Define]] semantics (useDefineForClassFields), so assignments skip the contract.runtime only
ADN0510An instance of the class held by one of its own static data properties (directly or in an array): a static initialiser or static {} block constructed it before @Contract() wrapped the class, so it was not checked.runtime only