question-mark
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.

Why assignment to property of function parameter is bad style.

See original GitHub issue

Node.js web service

(req, res, next) => {
  req.user = Guest;
  return next();
};

Often used, can not be avoided. How should I do?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
ljharbcommented, Mar 16, 2017

The next release of eslint-config-airbnb-base, and likely eslint-config-airbnb, will include this loosening of no-param-reassign.

5reactions
shanevcommented, Mar 7, 2017

Another example is ctx in Koa routing:

router.get('/', (ctx) => {
  ctx.status = 200;
});
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 >
Why eslint throws "Assignment to property of function ... - Reddit
Reassigning arguments is considered harmful so there's and ESlint rule for that. But mutating object properties is fine in some cases, ...
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 >
object oriented - Parameterizing vs property assignment
Nope. Your way is better. Here's why: the variables are properly confined to only the scope in which they are used.
Read more >
JavaScript: Don't Reassign Your Function Arguments
The numbered properties of the Arguments Object are synonymous with the local variables that hold the named function parameters.
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found