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-extra-parens does not allow conditional object spread

See original GitHub issue

What rule do you want to change? no-extra-parens

Does this change cause the rule to produce more or fewer warnings? Fewer

How will the change be implemented? (New option, new default behavior, etc.)? The best approach for this might be a new option, because the actual code without the parentheses still works, but can quickly become a real mess.

Please provide some example code that this change will affect:

const obj = {
  ...(true ? { foo: 'bar' } : { bar: 'foo' }),
};

What does the rule currently do for this code? Shows an error when wrapping a conditional object spread with parentheses.

What will the rule do after it’s changed? Allow extra parentheses around conditional object spread.

Are you willing to submit a pull request to implement this change? I’m not familiar with the eslint parser at all, so if someone is better at this please be my guest, otherwise I’ll try to learn new things ✨

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
kaicataldocommented, Jun 11, 2020

@anikethsaha Go for it!

2reactions
anikethsahacommented, Jun 11, 2020

I can work on this if no one is taking this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-extra-parens and spread operator · Issue #13691 - GitHub
no -extra-parens and spread operator #13691 ... Global ESLint version: Not found ... The rule is correct, the parens are not necessary:.
Read more >
Conditional Object Properties Using Spread in JavaScript
The line 2 expression omits a name from being applied if the condition fails. This works because the spread operator ignores values without...
Read more >
Can't use spread operator with ternary operator - Stack Overflow
From my point of view, it is only logical, as we spread a single thing (a ternary operator). Of course, it is not...
Read more >
no-extra-parens - 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 >
tslint-eslint-rules - npm Package Health Analysis | Snyk
Looks like tslint-eslint-rules is missing a security policy. ... no-obj-calls, Not applicable, disallow the use of object properties of the global object ......
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