Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two lines after last import #241

Open
1 task
clintonb opened this issue Jul 13, 2023 · 3 comments
Open
1 task

Two lines after last import #241

clintonb opened this issue Jul 13, 2023 · 3 comments

Comments

@clintonb
Copy link

Your Environment

  • Prettier version: 2.8.8
  • node version: 16.20.0
  • package manager: yarn 1.22.19
  • IDE: WebStorm 2023.1.3 (Build #WS-231.9161.29, built on June 15, 2023)

Describe the bug
This plugin is placing two line breaks after the last import:

import foo;
// These two lines...
// ...come from this plugin, and result in my CI complaining!
const a = 1;

Here is what things look like when this plugin is disabled:

import foo;
// Just one line, which is what is expected/preferred.
const a = 1;

To Reproduce

Expected behavior

The last import

Screenshots, code sample, etc

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

Error log

Contribute to @trivago/prettier-plugin-sort-imports

  • I'm willing to fix this bug 🥇
@roanrobersson
Copy link

For me this problem happens when I use the shortcut CTRL + SHIFT + F to format the code and then immediately save the file with CTRL + S. I ended up discovering that I can solve it by changing the automatic saving configuration of VS Code in the settings.json file:

"editor.formatOnSaveMode": "modificationsIfAvailable"
or
"editor.formatOnSaveMode": "modifications"

To this:

"editor.formatOnSaveMode": "file"

@cat-street
Copy link

For me, this (or similar issue) started happening a few weeks ago, after one of the PHPStorm updates. Moreover, the formatter also removes the empty line at the end of file, which also causes linter errors.
But it happens only if 'Optimize imports' option is checked when I'm trying to reformat file by Ctrl-Alt-Shift-L

@clintonb
Copy link
Author

For me, this (or similar issue) started happening a few weeks ago, after one of the PHPStorm updates. Moreover, the formatter also removes the empty line at the end of file, which also causes linter errors. But it happens only if 'Optimize imports' option is checked when I'm trying to reformat file by Ctrl-Alt-Shift-L

I disabled the "Reformat code" option for "Actions on save", and fixed the issue in Webstorm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants