prettier / prettier-vscode

Visual Studio Code extension for Prettier

Home Page:https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Range formater and eslint formats the whole document

CiGit opened this issue Β· comments

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.

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.
3. 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 πŸ˜•
  • Use only prettier on range formatting πŸ˜‘
  • As is, ie format document πŸ˜₯
  • prettier-eslint supports range. πŸ˜†

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 πŸ˜…

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.

commented

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.