Prettier-vscode: Range formater and eslint formats the whole document

Created on 24 Jun 2017  路  14Comments  路  Source: prettier/prettier-vscode

By using eslintIntegration and the range formater, the whole document gets formatted.

Due to prettier-eslint not supporting this feature (yet?)

Alternative: Disable eslint with the range formater.

bug locked

Most helpful comment

I've to do work-around by: Format whole document (Shift + Alt + F) -> copy the formarted block code -> Ctrl + Z -> Paste 馃槅馃槅

All 14 comments

There are multiple problems with format selection:

  1. Because it gets re-printed and you select nested code, it will move everything to the left
  2. if forgot to select a { meaning you have "invalid" code selected because it can not be printed in 1 go, it will fail. (this happens quite a lot in my case).
  3. Why do we need this feature actually? If you work with an html file with script tags in it. Aren't there ways to only format that script block because that's the only part that can be formatted? Just thinking out loud.

Have you tried the range formater recently ? @josephfrazier improved it a lot :-)
1 and 2 are past issues to me.

  1. Prettier aims to support HTML in the future if I remember correctly. Sorry I've no source right now.

Oh, I haven't used range formatting in a while now, ignore my comments :D

I've some ideas:

  • Remove eslint support :confused:
  • Use only prettier on range formatting :expressionless:
  • As is, ie format document :disappointed_relieved:
  • prettier-eslint supports range. :laughing:

Seeing this issue in latest vscode (1.19 release) on Fedora 27 linux x64. Reporting since this has been open since quite some time. I've to manually copy the seletion to a new js file, run prettier on it and then copy it back again at the moment :sweat_smile:

I've to do work-around by: Format whole document (Shift + Alt + F) -> copy the formarted block code -> Ctrl + Z -> Paste 馃槅馃槅

I think this feature(selection format) is very necessary. Because in the multi project collaboration development of old projects, conflicts can be reduced. 馃槃 馃槃

I've turned off "prettier.eslintIntegration": false but nevertheless format selection formats all document (

Format selection formats the first common parent node which can act as a valid Program. This may be your entire file.

I've turned off "prettier.eslintIntegration": false but nevertheless format selection formats all document (

This was the only thing that worked for me. Unfortunate, but Format Selection is extremely useful for me.

Still have this problem

Is there any solution for this problem?

No, the issue is with prettier-eslint not supporting range formatting. The fix from our side would be to disable range formatting when eslint integration is enabled, but that's probably not something I am going to prioritize any time soon. Happy to accept a PR though.

It also seems like prettier-eslint is mostly a dead project so it is unlikely this will get fixed. I would suggest switching to the recommended approach of integrating ESLint and Prettier

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

finalclass picture finalclass  路  4Comments

screendriver picture screendriver  路  4Comments

bluemoehre picture bluemoehre  路  3Comments

FlorianWendelborn picture FlorianWendelborn  路  3Comments

Glinkis picture Glinkis  路  4Comments