Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with Prettier 2.0 because of parser option babylon which has been removed (replaced by babel) #1794

Closed
3 tasks done
philfontaine opened this issue Mar 23, 2020 · 8 comments

Comments

@philfontaine
Copy link

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Win
  • Vetur version: 0.24.0
  • VS Code version:

Problem

The parser option babylon has been removed in Prettier 2.0

Error message:

Prettier format failed
[Error - 10:52:04 p.m.] Couldn't resolve parser "babylon"

The fix: https://github.com/vuejs/vetur/blob/master/server/src/modes/script/javascript.ts#L484
Replace babylon with babel

Reproducible Case

Format a Vue File using prettier 2.0

@Janther
Copy link

Janther commented Apr 6, 2020

I'm also using prettier 2.0 and am having troubles when this plugin undoes the formatting in the git repo.
At the moment I just told vscode to give preference to the prettier-vscode plugin when formatting.

@rnenjoy
Copy link

rnenjoy commented Apr 13, 2020

Anyone news?

@Janther
Copy link

Janther commented Apr 13, 2020

@rnenjoy
This is the setting I have in my .vscode/settings.json

{
  "[vue]": {
    // Vetur uses an old version of prettier
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

This is specific enough that it doesn't mess with my other formatting options and fixes the problem with vue files.

@dubonzi
Copy link

dubonzi commented Apr 16, 2020

@rnenjoy
This is the setting I have in my .vscode/settings.json

{
  "[vue]": {
    // Vetur uses an old version of prettier
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

This is specific enough that it doesn't mess with my other formatting options and fixes the problem with vue files.

Not an option for me since that affects the whole .vue file and I don't use prettier to format my template, only the script tag.

@rnenjoy
Copy link

rnenjoy commented Apr 16, 2020

For now i went into the extension code, and changed babylon to babel manually. Tell me if you guys need help which file to edit.

@Mirakurun
Copy link

@rnenjoy how do you do that?

@rnenjoy
Copy link

rnenjoy commented May 12, 2020

@rnenjoy how do you do that?

Sorry for the delay:
Goto %USERPROFILE%.vscode\extensions\octref.vetur-0.24.0\server\dist\modes\script\javascript.js

Change 398
const parser = scriptDoc.languageId === 'javascript' ? 'babylon' : 'typescript';
to
const parser = scriptDoc.languageId === 'javascript' ? 'babel' : 'typescript';

@Makapashev
Copy link

@rnenjoy just add this line to your .vscode/settings.json file "vetur.format.defaultFormatter.html": "none" it should help you.

@octref octref added the bug label Jun 24, 2020
@octref octref closed this as completed in 0bf749a Jul 5, 2020
octref added a commit that referenced this issue Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants