Why Prettier does not format code in VSCODE?

后端 未结 18 742
失恋的感觉
失恋的感觉 2020-12-07 18:39

In my Nuxt application where ESlint and Prettier are installed and enabled, I switched to Visual Studio Code editor.

When I open a .vue file and pre

18条回答
  •  一向
    一向 (楼主)
    2020-12-07 19:03

    I am not using Vue, but had the same problem.

    I already had the settings

    • Editor: default formatter to prettier
    • Editor: Format on Save to true
    • I already had .eslintrc.js and .prettierrc files But nothing worked.

    The solution to my problem was that I had all set properly, except I needed to:

    • Command + Shift + p
    • type format document with
    • select Configure Default Formatter...
    • select Prettier as default.

    I don't know why the Editor: Format on Save set to true was not enough. I needed to select default formatter using the above steps so it worked.

提交回复
热议问题