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.
Examples
Section titled “Examples”function process(value: string) { value = value.trim(); return value;}const fn = (count: number) => { count = count + 1; return count;};function process(value: string) { const trimmed = value.trim(); return trimmed;}const fn = (count: number) => { const incremented = count + 1; return incremented;};Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noParameterAssign - ESLint:
no-param-reassign
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.