Skip to content

No Object Parameters

Error
small-rules/no-object-parameters

Disallow object function parameters; inputs must use an owner-provided type and be parsed at their boundary.

Rationale

Ported from dmmulroy/anti-slop. object excludes null and the scalar types, and says nothing useful about the value’s contract. Accept the owner type you need, and parse external input before you call this function.

Diagnostic Messages

objectParameter
Parameter `{{parameter}}` uses the broad `object` type. Accept a named owner type; parse external input at its boundary before calling this function.

Configuration

This rule does not accept options.

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

Examples

broad object parameter
function save(value: object) {}
named owner contract
interface Owner { readonly id: string }
function save(value: Owner) {}