Skip to content

Don’t multi-line imports (let them take less space) / Conflict with VSCode’s organizeImports #5995

@dimikot

Description

@dimikot

Hi.

There is a bug somewhere when builtin VSCode's source.organizeImports feature is used together with Prettier.

People sometimes prefer to use VSCode's built-in source.organizeImports feature ON SAVE which, among other things, places all imports on the same line. And this conflicts with Prettier when it formats imports at multiple lines: if there is an error in the code, the underlining of this error shifts towards beginning of the file.

I recorded a video which shows the effect, pretty easy to reproduce:
https://www.dropbox.com/s/apj5znzlqy8pub6/vscode-prettier.mp4?dl=0

There are two possible ways I imagine:

  1. Fix the bug somehow (I tried to find the root case, but failed unfortunately), so organizeImports + Prettier could work together.
  2. Introduce an option which allows to turn off imports indentation in Prettier (a quick PR: Add option neverIndentImports to skip import statements formatting #5991) - it's a work-around in some sense, but at the same time, having all imports on the same line is VSCode's default they evangelize, and Prettier in some sense goes against this default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSstatus:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions