no-param-reassign : recommended approach?
See original GitHub issueI’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:
- Created 6 years ago
- Comments:8
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was aware, but I find the Array spread a bit nicer/easier to read, more concise…
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.