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.

no-param-reassign : recommended approach?

See original GitHub issue

I’m doing the following :

  [...document.querySelectorAll('.selection')].forEach((element) => {
    element.textContent = 'all';
  });

and naturally I get

  27:5  error  Assignment to property of function parameter 'element'  no-param-reassign

Besides adding a manual comment exception, is there any other way to avoid this? Thanks in advance for any answer

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
gkatsanoscommented, Feb 11, 2020

I was aware, but I find the Array spread a bit nicer/easier to read, more concise…

0reactions
ljharbcommented, Feb 12, 2020

That’s fair; the result is the same, but it takes more steps to get there. Also, NodeLists have a forEach method on them directly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid no-param-reassign when setting a property on a ...
Personally, I would just use the "no-param-reassign": ["error", { "props": false }] approach a couple of other answers mentioned. Modifying a property of...
Read more >
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 >
What is the recommended way to deal with no-param ... - GitHub
This problem has been discussed before, but I haven't seen a general agreement on the best way to solve it. ... Option 1...
Read more >
Airbnb JavaScript Style Guide()
A mostly reasonable approach to JavaScript. ... 7.12 Never mutate parameters. eslint: no-param-reassign. Why? Manipulating objects passed in as parameters ...
Read more >
Why eslint throws "Assignment to property of function ... - Reddit
Reassigning arguments is considered harmful so there's and ESlint rule ... Argument of type 'string' is not assignable to parameter of type.
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