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 says that a value is non-primitive but says nothing useful about its contract. Accept the owner type you need and parse external input before this function is called.

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) {}