| Id | ADN0501, the prefix of every message |
|---|---|
recommended | error |
strict | error |
| Fixable | yes (--fix) |
| Needs type information | no: it also runs in an untyped config |
What it reports
A @Requires, @Ensures, @Returns or @EnabledWhen written above @Validate() on the same method.
Why
Method decorators apply bottom up, so a clause above @Validate() records after @Validate() has installed the wrapper, and is never enforced. The runtime refuses it at declaration; the lint moves the clause for you.
Examples
Reported
import { Ensures, GreaterThan, Validate, RelationContracts as R } from 'adorn';
class Counter {
@Ensures(R.GreaterThan(R.Result(), 0))
@Validate()
next(@GreaterThan(0) n: number) { return n + 1; }
}
Accepted
import { Ensures, GreaterThan, Validate, RelationContracts as R } from 'adorn';
class Counter {
@Validate()
@Ensures(R.GreaterThan(R.Result(), 0))
next(@GreaterThan(0) n: number) { return n + 1; }
}
Details
Class-level @Contract() runs after every member decorator, so its order never matters. A clause above a decorator that is not adorn's Validate is not reported.
To keep a finding on purpose, disable it with a reason, which justify-opt-out checks: // eslint-disable-next-line adorn/clause-below-validate -- <why>.
Messages
The text ESLint prints, read from the rule itself. {{…}} is filled in for each finding.
| Message id | Text |
|---|---|
above | [ADN0501] @{{clause}} sits above @Validate(): it records after @Validate() installs, so it is never enforced. Move it below @Validate(), or use class-level @Contract(). |