Closed ripperdoc closed 1 year ago
I believe I'm encountering the same problem:
I'm pretty suspicious of this commit: https://github.com/prettier/prettier-vscode/commit/be790ca13b85b26196340ce2a89a1f8a47545605
Indeed, if I change my "on save" mode to "whole file" instead of "modifications", everything works again, no extra semi colon.
I'm pretty suspicious of this commit: be790ca
Indeed, if I change my "on save" mode to "whole file" instead of "modifications", everything works again, no extra semi colon.
So what that commit does is reports to VS Code just the changed portion of the file, but it shouldn’t cause this sort of problem.
i’m guessing the issue is this or similar: https://github.com/prettier/prettier/issues/12540
Is this still an issue? I've had to disable prettier entirely because it's adding needless semicolons to my work and causing the compiler to break on every save.
It's a bug in Prettier itself. Here it is reproduced in the Prettier playground.
This is NOT fixed by https://github.com/prettier/prettier/pull/12563. I opened a new issue here: https://github.com/prettier/prettier/issues/12964
This is an issue or feature request for the Prettier library itself rather than the VS Code extension for prettier. Please open an issue at https://github.com/prettier/prettier.
This is an issue or feature request for the Prettier library itself rather than the VS Code extension for prettier. Please open an issue at https://github.com/prettier/prettier.
Isolated issue already open at https://github.com/prettier/prettier/issues/12964
any news ? This is annoying.
one thing I noted is, when i remove return from this code
{aniList.map(aniList => { return <Search aniList={aniList} key={aniList.id} /> })}
it adds a semicolon like this
{aniList.map(aniList => { ;<Search aniList={aniList} key={aniList.id} /> })}
I don't know if this is intended or a bug
one thing I noted is, when i remove return from this code
{aniList.map(aniList => { return <Search aniList={aniList} key={aniList.id} /> })}
it adds a semicolon like this
{aniList.map(aniList => { ;<Search aniList={aniList} key={aniList.id} /> })}
I don't know if this is intended or a bug
I confirm I see the same behavior. Adding the return seems to prevent the semicolon from being added but it ruins the code cleaning purpose of the syntax
I am still seeing this issue as well. Adds a semicolon after every save to the end of my react component.
export const MyComponent = () => {
return (
<div>
...
</div>
);
};;;;;;
Worth mentioning that I have "editor.formatOnSaveMode": "modifications"
and the line with the semicolons being added has not been modified.
@jmadsenccri, @robertocinetto see if you can reproduce it in the Prettier Playground using the range option.
@rotu yes I can replicate it. Please check this in this Prettier Playground
The issue happens with the --no-semi option turned on.
same issue
anyway to update the prettier used to latest code? main repo is updated with the fix.
anyway to update the prettier used to latest code? main repo is updated with the fix.
I think npm install -g prettier@next
should do it. You may also need to update the path in vscode settings.
I'm getting this issue now and then (haven't figured out the pattern yet), primarily when I comment code inside a functional component or inside the JSX block. Usually, as soon as I remove the commented code, it stops adding semicolons, but not always.
Very, very annoying. Changed "editor.formatOnSaveMode
to file
.
Why is this closed?
Why is this closed?
Now that it’s fixed in prettier v3, it’s waiting on this: https://github.com/prettier/prettier-vscode/issues/2762
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Summary
A certain combination of code and modifications to that code will cause a semicolon to be added on every save, causing syntax error.
This issue was first raised on vscode here but re-directed here. VS Code system info can be found there.
Github Repository to Reproduce Issue
Link to a Github repo that can be used to reproduce the issue.
Steps To Reproduce:
"editor.formatOnSaveMode": "modificationsIfAvailable"
or"editor.formatOnSaveMode": "modifications"
.Expected result
No invalid semicolons added.
Additional information
This only happens on the two mentioned formatOnSaveMode modes. If the format on save is changed to
"editor.formatOnSaveMode": "file"
the error doesn't appear. So it seems to be an interplay between the way VS Code formats only the diffing parts (the diff is compared with what's in the Git repo, see Test commit in the reproduction repo). The error doesn't appear if there is no Git history to diff to.Extension bisect was used to find that this error appears only with Prettier.
VS Code Version: Code 1.66.0 (https://github.com/microsoft/vscode/commit/e18005f0f1b33c29e81d732535d8c0e47cafb0b5, 2022-03-30T05:50:04.419
Prettier Extension Version: 9.5.0
OS and version: Darwin x64 18.7.0
Prettier Log Output