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.

update documentation re no-param-reassign

See original GitHub issue

Great tool. I hope this idea might help.

no-param-reassign is a solid rule for good reason (it’s not intuitive that a function’s arguments is recorded as an array, not a key-value).

However, may I suggest the one time the user can safely ignore this rule: creating an object from an array using reduce. I use the eslint-rules for three reasons (loosely speaking):

  1. safety that includes consistent, clean design
  2. idiomatic to plug-into norms and thus increase speed of understanding
  3. performance without sacrificing on safety

My recommendation would be to describe how avoiding a destructuring call on every iteration of the reducing function likely provides a net benefit when building an object from an array using reduce.

This is such an often used function (reduce), that I believe it merits this special “calling out”.

What do you all think?

- E

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Aug 13, 2020

It’s also worthwhile to note that this is a pretty good use case for inline disable comments. You could use those comments in the cases where acc is a real accumulator in a reduce function, but not allow mutations of acc parameters in other contexts.

That said, I wouldn’t oppose improving the docs with a reduce example.

0reactions
eslint-deprecated[bot]commented, Sep 14, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-param-reassign - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How to avoid no-param-reassign when setting a property on a ...
This answer should be the accepted answer since it's pointing to the official documentation and is well explained. Most of the other answers...
Read more >
Do we want to recommend the `no-param-reassign` eslint rule ...
I just had this idea when another user tried to assign to the state function argument. There is actually an eslint rule for...
Read more >
What the Heck is the deal with no-param-reassign
When a variable holds a primitive (Number or String) and you re-assign its value your pointing it to a new memory location. view...
Read more >
Update eslintrc no-param-reassign to allow props reassignment
I updated the .eslintry.yml with a draft ignorePropertyModificationsFor list. I think there are some good reasons to include entries for the ...
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