Skip to content

parameterReassignments

Disallow reassignment of function parameters.

✅ This rule is included in the ts logical presets.

Reassigning function parameters can make code harder to understand and debug. The parameter’s original value becomes lost, making it difficult to trace what value the parameter had at different points in the function.

Using a new variable instead makes the intent clearer and preserves the original parameter value.

function process(value: string) {
value = value.trim();
return value;
}
const fn = (count: number) => {
count = count + 1;
return count;
};

This rule is not configurable.

If your codebase intentionally reuses parameter variables for intermediate calculations, this rule might no be for you. For example, if you prefer writing very small functions and feel confident you and any fellow developers won’t misunderstand the code, you might prefer to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.