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-parens: add ability to allow chained prop/method access

See original GitHub issue

What rule do you want to change? new-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.)? New option

Please provide some example code that this change will affect:

let year = new Date().getFullYear();

What does the rule currently do for this code? Displays an error

What will the rule do after it’s changed? Allow this code new Date().getFullYear() and disallow this code new Date()

Are you willing to submit a pull request to implement this change? No

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Nov 25, 2019

This makes sense to me. An option to allow only necessary parens (those that wouldn’t require adding outer parens instead), either as an additional modifier for the "never" option or maybe as a new value for the string option (something like "as-needed").

I left 👍 for the proposal. A rule enhancement needs 3 votes from the team and a champion to be accepted.

0reactions
mdjermanoviccommented, Nov 26, 2019

I’ll champion and I could work on this. Removed my vote to avoid confusion, so this now needs two more 👍 from the team to be accepted.

In favor of the proposal, the same code which would be added for this enhancement can be also used to improve the fixer for the existing behavior. In particular, to avoid unnecessary parens in the autofix when the option is "never". In the actual version, the fixer always wraps the new expression in parens.

For example, const foo = new Bar(); becomes const foo = (new Bar); like in this demo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use parental controls on your child's iPhone, iPad, and iPod ...
Choose Unrestricted Access, Limit Adult Websites, or Allowed Websites. Depending on the access you allow, you might need to add information, ...
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