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

.vue files cannot be formatted #2729

Open
DimplesY opened this issue Sep 27, 2022 · 8 comments
Open

.vue files cannot be formatted #2729

DimplesY opened this issue Sep 27, 2022 · 8 comments

Comments

@DimplesY
Copy link

Summary

Version 9.9.0, vue files cannot be formatted when a configuration file exists in the project directory

  1. Prettier - Code formatter 9.9.0
  2. Vue Language Features (Volar) 0.40.13

Actual result

image

image

@BabyLy233
Copy link

I have the same problem and it doesn't work on .scss file too

@andr35
Copy link

andr35 commented Oct 1, 2022

I experienced the same problem also with .html files.

It happens with version v9.9.0. I installed the previous version (v9.8.0) and the issue disappeared.

@holazz
Copy link

holazz commented Oct 3, 2022

Same issue.

@github-actions
Copy link

github-actions bot commented Oct 3, 2022

This bug is missing information needed to diagnose the problem. Please see our guide on how to open a good issue and provide the missing information. Most configuration-related issues can only be resolved by providing a full repro. If you don't provide a sample to reproduce your issue, your bug will most likely be closed.

@ghsgz
Copy link

ghsgz commented Mar 25, 2023

Volar will find all corresponding formatting tools according to configurations.

By default, these formaters are:

More information, here.

Seems like, we can not change the behaviour of Volar by setting "editor.defaultFormatter": "esbenp.prettier-vscode" in settings.json. Currently, I do not know why, too.

Back to this issue, if you want to use prettier to format .vue files, here is a workaround.

Make sure:

  • installed prettier and eslint, npm packages as project dependencies and VSCode plugins
  • .eslintrc.cjs in your project root, and make sure '@vue/eslint-config-prettier' is on the last line of prop extends
  • some additional configurations in settings.json, like this:
"editor.codeActionsOnSave": {
    "source.fixAll": false,
    "source.fixAll.eslint": true,
    "source.organizeImports": false
}

Then, ESLint will format your .vue files automatically by calling prettier, every time you save files.

Edit: sorry, seems like the paragraph above I wrote makes nonsense totally.

To mount Volar extension, and format .vue files with a set of rules as well,

That is my poor insights. Hope this helps.

@Igonato
Copy link

Igonato commented Jun 15, 2023

Facing this after a recent VS Code update. Had to downgrade the extension to version 8.2.0 (9.8.0 wasn't enough for me) until it started to work. I'm on Windows 11 and WSL2 Ubuntu 22.04. Willing to help with debugging.

@quroom
Copy link

quroom commented Apr 11, 2024

I faced same problem, But when I reboot my pc. All problem was fixed.

@esorribas
Copy link

Same error for me, if downgrade to Prettier version 9.14.0 works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment