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.

New rule: no-mutating-assign

See original GitHub issue

Description:

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:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
jfmengelscommented, Jun 20, 2016

Seeing as there is no maintenance of the plugin, I’ve written my own that has this rule.

2reactions
ljharbcommented, May 1, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

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