Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule suggestion: Don't reassign function parameters

See original GitHub issue

Reusing function parameters feels often like a code smell for me. If you consider something like the following example it could even cost you some debugging time (especially if you have long legacy functions):

function foo (bar) {
    bar = 13;
    // now we accidentally overwrote the function parameter which is most likely not good

I suggest the implementation of a rule that is similar to no-ex-assign but for functions instead of try-catch-blocks and is turned off by default.

What do you think about it?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:28 (21 by maintainers)

github_iconTop GitHub Comments

idchlifecommented, Apr 8, 2016

@xjamundx oh, I see. I did not know about () around {} when returning object in short function.

That’s actually just flowtype, not typescript.

xjamundxcommented, Apr 8, 2016

@idchlife this is valid ES6 [1,2].map(c => ({a: 1})) not sure about TypeScript?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid no-param-reassign when setting a property on a ...
If you assign to a parameter and then try and access some of the parameters via the arguments object, it can lead to...
Read more >
no-param-reassign - ESLint - Pluggable JavaScript Linter
Rule Details​​ This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.
Read more >
Why it's bad practice to reassign function params - Medium
Reassigning the value of an argument variable mutates the arguments object. Mutation is the act of changing the source or the original element....
Read more >
Effective Go - The Go Programming Language
The return or result "parameters" of a Go function can be given names and used as regular variables, just like the incoming parameters....
Read more >
Google C++ Style Guide
Comment Style; File Comments; Class Comments; Function Comments ... This principle mostly explains the rules we don't have, rather than the rules we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found