New rule: no-mutating-assign
See original GitHub issueDescription:
Warns when Object.assign
is used with the first parameter anything else than object initialisation.
Will warn:
const foo = {};
Object.assign(foo, {bar: 'BAR'});
Will not warn:
const foo = {};
Object.assign({}, foo, {bar: 'BAR'});
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
jfmengels/eslint-plugin-fp - no-mutating-assign and functions
I have the "no-unused-expression" rule turned on which prevents me from mutating MyComponent with that assignment statement so I changed my ...
Read more >Found the ESLint plugin preventing mutation in Object.assign ...
... mutation in Object.assign()call if anyone is interested:. https://github.com/jfmengels/eslint-plugin-fp/blob/master/docs/rules/no-mutating-assign.md.
Read more >eslint-plugin-fp | Yarn - Package Manager
no-let - Forbid the use of let . no-loops - Forbid the use of loops. no-mutating-assign - Forbid the use of Object.assign() with...
Read more >Proposed Rules - GovInfo
The proposed rule would rescind certain regulatory changes made effective on November. 16, 2020 and implements new statutory.
Read more >eslint-plugin-fp-jxl - npm
ESLint rules for functional programming. Latest version: 3.1.0, last published: 4 years ago. Start using eslint-plugin-fp-jxl in your ...
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 Free
Top 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
Seeing as there is no maintenance of the plugin, I’ve written my own that has this rule.
Object.assign
does return a value - the first argument. In addition, spread syntax is not yet standard - it’s only stage 1.I would love this rule, as we use
Object.assign({}, …)
all the time, but never want the first argument to be anything but a new empty object.