eslint: Rule suggestion: Don't reassign function parameters
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?
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 28 (21 by maintainers)
Commits related to this issue
- New: no-param-reassign rule (fixes #1599) — committed to burnnat/eslint by burnnat 9 years ago
- New: no-param-reassign rule (fixes #1599) — committed to burnnat/eslint by burnnat 9 years ago
- New: no-param-reassign rule (fixes #1599) — committed to burnnat/eslint by burnnat 9 years ago
- Merge pull request #2036 from burnnat/no-param-reassign New: no-param-reassign rule (fixes #1599) — committed to eslint/eslint by nzakas 9 years ago
@xjamundx oh, I see. I did not know about () around {} when returning object in short function.
That’s actually just flowtype, not typescript.
@idchlife this is valid ES6
[1,2].map(c => ({a: 1}))
not sure about TypeScript?