Skip to content

no-identity-map

Disallow .map() calls where the callback returns its input unchanged.

This rule reports calls such as items.map((item) => item) and fixes them by replacing the full call with the original object expression.

It covers arrow functions and function expressions with exactly one parameter. The callback can return the parameter directly or from a single return statement in a block.

The rule also tries to tell the difference between normal arrays and Roblox bindings. By default it treats names that contain binding as bindings, and it also detects values created with useBinding, joinBindings, or another binding .map() call.

bindingPatterns is a list of case-insensitive name fragments used to guess whether .map() is operating on a binding. The default is ['binding'].

eslint.config.ts
import plugin from "eslint-plugin-cease-nonsense";
export default [
{
plugins: { "cease-nonsense": plugin },
rules: {
"cease-nonsense/no-identity-map": [
"warn",
{ bindingPatterns: ["binding", "spring"] },
],
},
},
];
Incorrect
const copied = items.map((item) => item);
const list = data.map(function (x) {
return x;
});
const next = healthBinding.map((value) => value);
Correct
const result = items;
const copied = [...items];
const doubled = numbers.map((n) => n * 2);
const values = items.map(identity);