unnecessary parens in while with assign
See original GitHub issuePrettier 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:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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