Skip to content

No Reflect Get

Error
small-rules/no-reflect-get

Disallow Reflect.get; use typed property access or parse dynamic input into a domain type.

Rationale

Ported from dmmulroy/anti-slop. Prefer typed property access. If the key or owner is dynamic, parse it into a domain type before reading it.

Diagnostic Messages

reflectGet
Replace `Reflect.get` with typed property access. Parse dynamic input into a named domain type before reading it.

Configuration

This rule does not accept options.

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

Examples

Reflect.get call
const value = Reflect.get(owner, key);
typed property access
const value = owner[key];