Skip to content

No Unknown Parameters

Error
small-rules/no-unknown-parameters

Disallow explicitly unknown function parameters except `cause` and the parameter named by a type predicate; decode unknown input at its I/O boundary instead.

Rationale

Ported from dmmulroy/anti-slop. Unknown input belongs at the boundary where you can decode it. The sole exception is an explicitly named cause, which follows the normal error-enrichment convention.

Diagnostic Messages

unknownParameter
Parameter `{{parameter}}` leaves input unparsed. Accept a named domain type; run the expected schema or parser at the I/O boundary before calling this function.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-unknown-parameters": "error"
}
}

Examples

unknown function parameter
function handle(input: unknown) {}
type-guard boundary parameter
export function isNode(value: unknown): value is ESTree.Node {}