I am using prettier --debug-check and it is producing the following error information...
[error] my.js: ast(input) !== ast(prettier(input))
[error] Index:
[error] ===================================================================
[error] ---
[error] +++
[error] @@ -3497,8 +3497,6 @@
[error] "argument": {
[error] "type": "LogicalExpression",
[error] - "operator": "&&",
[error] "left": {
[error] "type": "LogicalExpression",
[error] - "operator": "&&",
[error] "left": {
[error] "type": "LogicalExpression",
[error] @@ -3529,4 +3527,5 @@
[error] }
[error] },
[error] + "operator": "&&",
[error] "right": {
[error] "type": "Identifier",
[error] @@ -3534,4 +3533,5 @@
[error] }
[error] },
[error] + "operator": "&&",
[error] "right": {
[error] "type": "BinaryExpression",
[error]
[error] Index:
[error] ===================================================================
...
... below this appears to be a diff between the original file and the
... prettier output...there is a huge difference between them.
I am having a hard time determining what in the original file is resulting in this error being produced. I assume that the error information is trying to tell me where to look...is it?
How can I resolve this error so prettier can be used to format the file?
Perhaps someone else will be able to provide a better answer.
The error output provided by --debug-check is uninterpretable.
To resolve the issue, a method that worked was to comment out code until I was able to narrow it down to the line that Pettier was complaining about.
The line had the form:
return (a && a.length > 0) && (b && b.length > 0);
Now, clearly the parenthesis are not needed, but including them leads to two different ASTs.
The solution was to write the line without the parenthesis:
return a && a.length > 0 && b && b.length > 0;
Doing so stops Prettier from complaining.