| Id | ADN0005, the prefix of every message |
|---|---|
recommended | error |
strict | error |
| Fixable | no |
| Needs type information | yes: a typed config (parserOptions.projectService) |
What it reports
An Arg(i) in a relation clause (@Requires, @Ensures, or a contract() spec's requires/ensures) that is past the signature, and an Arg(i, ...path) whose path names a property the parameter's TypeScript type does not have.
Why
Past the signature, that argument is undefined in every call adorn accepts, so the clause is decided by absence alone; the runtime refuses such a clause at declaration, and the lint says so in the editor. A misspelt path reads undefined too, and an ordering with an undefined operand never holds, so the clause no longer says what it reads as. adorn has no data for a TypeScript type, so the path is checked through the type checker. For a contract() function the signature is its params, not the function's own parameter list; for a decorated method, its declared parameters.
Examples
Reported
import { Contract, Defined, GreaterThan, Requires, RelationContracts as R } from 'adorn';
@Contract()
class Packer {
@Requires(R.GreaterThan(R.Arg(1, 'sise'), 0)) // 'sise' is not on { size: number }
pack(@GreaterThan(0) n: number, @Defined() box: { size: number }) {
return n * box.size;
}
}
Accepted
import { Contract, Defined, GreaterThan, Requires, RelationContracts as R } from 'adorn';
@Contract()
class Packer {
@Requires(R.GreaterThan(R.Arg(1, 'size'), 0))
pack(@GreaterThan(0) n: number, @Defined() box: { size: number }) {
return n * box.size;
}
}
Details
With extraArgs: 'allow' an index past the signature is not reported: the extra argument can then be present.
To keep a finding on purpose, disable it with a reason, which justify-opt-out checks: // eslint-disable-next-line adorn/relation-in-signature -- <why>.
Messages
The text ESLint prints, read from the rule itself. {{…}} is filled in for each finding.
| Message id | Text |
|---|---|
past | [ADN0005] Arg({{i}}) is past the signature ({{n}} parameters): that argument is undefined in every accepted call, so the clause is decided by absence alone. Give it a parameter, or pass extraArgs: 'allow'. |
path | [ADN0005] Arg({{i}}, ...): '{{segment}}' is not a property of '{{type}}'. |