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-mutating-assign and functions

See original GitHub issue

This doesn’t pass the no-mutating-assign rule:

Object.assign(() => {}, {foo:1});

Should it be allowed?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
graingertcommented, Feb 21, 2018

I can see:

const foo = Object.assign(function foo(ham) { }, { $inject: ['ham'] });

being preferred to:

const foo = function foo(ham) { };
foo.$inject = ['ham'];
1reaction
jdiamondcommented, Jan 2, 2017

Hey thanks! I upgraded and was able to remove my comments disabling the rule.

You’re right that no-mutation is the error I get when trying to assign propTypes the old-fashioned way. I think I assumed no-unused-expression because that’s the error I’ve been seeing the most lately as I try to write in a more functional style.

I didn’t know about the exceptions property so thanks for that. I agree that passing an arrow function to Object.assign looks very funny. Just trying it out for now.

Thanks again for the awesome plugin!

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-fp - npm
ESLint rules for functional programming. ... no-mutating-assign - Forbid the use of Object.assign() with a variable as first argument.
Read more >
Found the ESLint plugin preventing mutation in Object.assign ...
Use JS object spread operator instead of Object.assign() pattern in Node 8. One of the best features of Node 8.6+ is the ability...
Read more >
Eslint-plugin-fp NPM - npm.io
ESLint rules for functional programming ... no-mutating-assign - Forbid the use of Object.assign() with a variable as first argument. no-mutating-methods ...
Read more >
Functional Fashion in JavaScript | Blog - Fluid Attacks
Now we rewrite this code in a functional way. Cilinder class in a functional approach. function cilinder(radius, height) { return { " ...
Read more >
Here's How Not to Suck at JavaScript - Agile Actors #learning
Although I'm a strong believer in Functional Programming, I'm not going ... rules: fp/no-mutating-assign: warn fp/no-mutating-methods: warn ...
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