question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatting of JavaScript in .vue files is broken after release of Prettier 1.13.0

See original GitHub issue

Info

  • Platform: macOS
  • Vetur version: 0.12.3
  • VS Code version: 1.23

Problem

Formatting of JavaScript in the <script> block is broken with the release of Prettier 1.13.0. Format Document does not make any corrections.

In contrast, the <style> block is being formatted as expected.

Installing Prettier 1.12.1 in the project and reloading VSCode fixes the issue:

npm install -D -E prettier@1.12.1

Reproducible Case

  1. Create a VueJs project by running vue init webpack-simple and accepting the defaults.
  2. Open App.vue and introduce a misalignment or a trailing space inside the <script> block.
  3. Run “Format Document”.
  4. Observe that no corrections are made in the <script> block.
  5. Install Prettier 1.12.1 using the npm command given above and reload the window.
  6. Run “Format Document”.
  7. Observe that the formatting issues added in step 2 are corrected.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
lesonkycommented, Jun 1, 2018

I have the same problem,so I changed the setting

"vetur.format.defaultFormatter.js": "vscode-typescript"

it works well.

3reactions
patrickcatecommented, Jun 6, 2018

@octref I upgraded the Prettier VSCode extension, which now uses prettier@1.13.4, and I’m still running into the same error as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode prettier/vue formatting settings don't work properly
and my formatter is causing the " at the end of the line after "...isInteger(quantity)" to be line-broken which breaks my entire component's ......
Read more >
Prettier | WebStorm Documentation - JetBrains
Prettier is a tool to format .js, .ts, .css, .less, .scss, .vue, and .json code. With WebStorm, you can format selected code fragments...
Read more >
How To Configure ESLint and Prettier for Vue.js - DigitalOcean
First, you'll want to install prettier globally from NPM, if you haven't already. It can be installed on a per-project basis, but that's...
Read more >
prettierx | Yarn - Package Manager
(with some prettierX language-js updates now based on Prettier 2.3.2). with some updates including: switch to pure CSS parser using PostCSS 8 (see...
Read more >
ESLint and Prettier with Vite and Vue.js 3 - Vue School Blog
We just need to install the eslint-config-prettier config. This disables the formatting rules in ESLint that Prettier is going to be responsible ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found