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.

unnecessary parens in while with assign

See original GitHub issue

Prettier 1.14.2 Playground link

--parser babylon

Input:

while ($var = 1) {}

Output:

while (($var = 1)) {}

Expected behavior:

while ($var = 1) {}

Edge case.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
vjeuxcommented, Sep 7, 2018

This is to prevent the mistake of trying to do “a == 1” but writing “a = 1” and subtly getting it wrong. If you see a double parenthesis then it’s obvious that you are doing an assignment.

3reactions
lydellcommented, Sep 7, 2018

As far as I remember, this is intended to show that you actually intended to do assignment and not comparison. See also: https://eslint.org/docs/rules/no-cond-assign

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assignment Expression Reports superfluous-parens False ...
Pylint reports superfluous-parens:Unnecessary parens after 'not' keyword . Expected behavior. Pylint should not report about this syntax.
Read more >
pylint says "Unnecessary parens after %r keyword"
To make pylint aware that you want to use the new print statement and not put erroneous brackets simply use
Read more >
superfluous-parens / C0325 - Pylint 2.16.0-dev documentation
Unnecessary parens after %r keyword. Description: Used when a single item in parentheses follows an if, for, or other keyword. Problematic code:.
Read more >
no-extra-parens - ESLint - Pluggable JavaScript Linter
This rule restricts the use of parentheses to only where they are necessary. Rule Details. This rule always ignores extra parentheses around the...
Read more >
no-extra-parens - Rules - ESLint - Pluggable JavaScript linter
This rule has a string option: "all" (default) disallows unnecessary parentheses around any expression; "functions" disallows unnecessary parentheses only ...
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