| Id | ADN0506, the prefix of every message |
|---|---|
recommended | off |
strict | error |
| Fixable | no |
| Needs type information | no: it also runs in an untyped config |
What it reports
An exported function, or a public method of an exported class, that takes input and has no contract. It covers exported function declarations, exported const function literals, export {local} lists and default exports; a contract() or contract.checked() call counts as covered.
Why
At a boundary (an API handler, an LLM tool module) every input should be checked by a contract that also projects to the schema, docs and tests. This rule is the paradigm rather than a bug check, so it is off in recommended and an error in strict. boundary(globs) turns it on for just the files you name.
Examples
Reported
export function quote(city: string, days: number) {
return city + ': ' + days + ' days';
}
Accepted
import { contract, Contracts } from 'adorn';
export const quote = contract(
{ params: [Contracts.string.notEmpty(), Contracts.number.between(1, 14)] },
function quote(city: string, days: number) {
return city + ': ' + days + ' days';
},
);
Details
Skipped: functions and methods with no parameters, constructors (a constructor contract is optional), accessors, overload signatures, and private, protected or # members. To keep an uncovered export on purpose: // eslint-disable-next-line adorn/contract-coverage -- <why>.
To keep a finding on purpose, disable it with a reason, which justify-opt-out checks: // eslint-disable-next-line adorn/contract-coverage -- <why>.
Messages
The text ESLint prints, read from the rule itself. {{…}} is filled in for each finding.
| Message id | Text |
|---|---|
uncoveredFunction | [ADN0506] Exported function '{{name}}' takes input but has no contract. Wrap it in contract({params: [...]}, ...), or say why not: // eslint-disable-next-line adorn/contract-coverage -- <why>. |
uncoveredMethod | [ADN0506] Public method '{{cls}}.{{name}}' of an exported class takes input but has no contract. Type its parameters and add @Contract() to the class (or @Validate() to the method). |