| Id | ADN0503, the prefix of every message |
|---|---|
recommended | error |
strict | error |
| Fixable | no |
| Needs type information | no: it also runs in an untyped config |
What it reports
Parameter constraints or clauses on a method of a class with no @Contract(), when the method has no @Validate() either. Also a constructor contract (a parameter constraint, or @Requires/@Ensures on the class) on a class with no @Contract().
Why
Decorators only record; an installer enforces. With nothing to install them, the constraints are never enforced and are missing from every projection, and nothing fails. The runtime reports the same problem in development as diagnostic ADN0503; the lint reports it before the code runs.
Examples
Reported
import { GreaterThan } from 'adorn';
class Billing {
charge(@GreaterThan(0) cents: number) { return cents; }
}
Accepted
import { Contract, GreaterThan } from 'adorn';
@Contract()
class Billing {
charge(@GreaterThan(0) cents: number) { return cents; }
}
Details
Markers alone record no contract, so @Sensitive() or @Telemetry.value() under @Observe() or @Log() needs no installer. A constructor contract is installed only by @Contract() on the class: @Validate() is a method decorator.
To keep a finding on purpose, disable it with a reason, which justify-opt-out checks: // eslint-disable-next-line adorn/installer-present -- <why>.
Messages
The text ESLint prints, read from the rule itself. {{…}} is filled in for each finding.
| Message id | Text |
|---|---|
missing | [ADN0503] '{{method}}' declares {{what}}, but {{cls}} has no @Contract() and the method has no @Validate(), so nothing installs it: it is never enforced and is missing from every projection. |
missingConstructor | [ADN0503] The constructor of {{cls}} declares a constructor contract, but the class has no @Contract(), so nothing installs it: it is never enforced and is missing from every projection (DEC-128). |