Skip to content

No Identity Map

SuggestionAuto-fixable
small-rules/no-identity-map

Disallow pointless identity `.map()` calls that return the parameter unchanged

Diagnostic Messages

identityArrayMap
Pointless identity `.map()` call on Array. Use `table.clone(array)` or `[...array]` instead.
identityBindingMap
Pointless identity `.map()` call on Binding. Use the original binding directly.

Configuration

This rule accepts one options object after the severity.

bindingPatternsOptional

Variable name patterns to recognize as Bindings (case insensitive)

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-identity-map": [
"error",
{
"bindingPatterns": [
"binding"
]
}
]
}
}

Examples

Identity binding map
scaleBinding.map(v => v)

After auto-fix

scaleBinding
Transforming map callback
binding.map(v => v + 1)