Lint rule · ADN0005

adorn/relation-in-signature

Arg(i, ...path) names a parameter of the signature and a property its type has.

IdADN0005, the prefix of every message
recommendederror
stricterror
Fixableno
Needs type informationyes: 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

reported by adorn/relation-in-signature
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

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 idText
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}}'.

All rules · the adorn/eslint guide