no-param-reassign should not throw error when using Object destructuring on parameters
See original GitHub issueTell us about your environment
- ESLint Version: 5.9.0
- Node Version: v8.11.3
- npm Version: 5.6.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
{
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-param-reassign": [
"error",
{
"props": true
}
]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
const obj = { key: [1, 2, 3] };
function foo({ key }) {
key = [4, 5, 6];
return key;
}
function bar(qux) {
let { key } = qux;
key = [4, 5, 6];
return key;
}
node_modules/eslint/bin/eslint.js demo.js
What did you expect to happen? 0 error
What actually happened? Please include the actual, raw output from ESLint.
4:3 error Assignment to function parameter 'key' no-param-reassign
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Resolving ESLint error due to `no-param-reassign` and `prefer ...
The first error is here because in your eslint configuration you use the following: no-param-reassign: ["error", { "props": true }].
Read more >Prevent Error with Default {} when Destructuring
When you use destructuring, make sure to set a default value of empty {} to prevent it from throwing an error! function hi(person)...
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 >Destructuring assignment - JavaScript - MDN Web Docs
Here we show how to unpack a property of the passed object into a variable with the same name. The parameter value {...
Read more >eslint-config-airbnb - Awesome JS
2.2 If you must reassign references, use let instead of var . eslint: no-var ... 5.3 Use object destructuring for multiple return values,...
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
@pantoninho Possible misreading on my part:
Guess I took that out of context and read that as an assertion about the leakage of assignments to an object property “through” an assignment to a destructured value. My mistake.
In any case, I still recommend creating a new issue, so that you can provide full context for your use case.
@platinumazure I can understand why it was easy to misread, sorry.
I will follow your advice. Thanks