prettier-plugin-sort-imports icon indicating copy to clipboard operation
prettier-plugin-sort-imports copied to clipboard

whitespace on top

Open artola opened this issue 2 years ago • 5 comments

Your Environment

  • plugin version: 3.1.1
  • Prettier version: 2.3.2
  • node version 14

Describe the bug

The plugin removes the whitespace before the imports' block, but it should not be affected at all.

To Reproduce

Input:

/* istanbul ignore file */

import foo from 'foo';

Output:

/* istanbul ignore file */
import foo from 'foo';

Expected behavior

/* istanbul ignore file */

import foo from 'foo';

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

{
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "all",
  "bracketSpacing": false,
  "jsxBracketSameLine": false,
  "arrowParens": "always",
  "importOrder": ["^@(.*)/(.*)$", "^#/(.*)$", "^[./]"],
  "importOrderSeparation": true,
  "importOrderSortSpecifiers": true
}

artola avatar Nov 25 '21 14:11 artola

@byara The "input" example above is properly handled by Prettier (if several lines added between the comment and the first import, then just 1 empty line remains) but once added this plugin, it removes all the whitespace. Same behaviour using single or multi-line comments (// ... or /* ... */).

artola avatar Dec 30 '21 19:12 artola

Looks like this PR wanted to fix this issue: https://github.com/trivago/prettier-plugin-sort-imports/pull/24 @ayusharma @byara Can you provide any info why that PR was closed? Is this planned to be fixed? Thanks!

JuhG avatar Feb 28 '22 14:02 JuhG

Looks like this PR wanted to fix this issue: #24 @ayusharma @byara Can you provide any info why that PR was closed? Is this planned to be fixed? Thanks!

Same. Hope this feature can be considered. In the projects I work on, we put the Apache License at the top. So we want to have a blank line between it and the actual code.

Thank you for creating this project. ❤️ It's very useful.

g1eny0ung avatar Apr 28 '22 07:04 g1eny0ung

I'm seeing the same issues with copyright blocks on top of our files. It's removing the blank separator line.

michaelfaith avatar May 20 '22 19:05 michaelfaith

Same problem with copyright blocks in our project.

skalinkin avatar Nov 01 '23 13:11 skalinkin