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
function process(value: string): string
process
(
value: string
value
: string) {
value: string
value
=
value: string
value
.
String.trim(): string

Removes the leading and trailing white space and line terminator characters from a string.

trim
();
return
value: string
value
;
}
const
const fn: (count: number) => number
fn
= (
count: number
count
: number) => {
count: number
count
=
count: number
count
+ 1;
return
count: number
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 ❤️‍🔥 around the world by the Flint team and contributors.