Skip to content

Range formatting broken since v6 #394

Description

@uncaught

Your Environment

  • Prettier version: 3.8.1
  • node version: [24.x.x]
  • package manager: [npm@11, pnpm@10]
  • IDE: [Webstorm, PhpStorm, CLI]

Describe the bug

Formatting with a range adds extra empty lines after the import statements. Jetbrains IDEs use this heavily, which breaks the developer experience.

To Reproduce

I have created a reproducer:

git clone git@github.com:uncaught/trivago-prettier-plugin-sort-imports.git
cd trivago-prettier-plugin-sort-imports
npm i
npm run prettier -- --range-start=0 --range-end=53 hello.js

Expected behavior

There should only be one empty line between the import and the following code.

Actual behavior

There are four empty lines between import and following code.

Screenshots, code sample, etc

See https://github.com/uncaught/trivago-prettier-plugin-sort-imports

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

export default {
  plugins: ["@trivago/prettier-plugin-sort-imports"],
};

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

  • I'm willing to fix this bug 🥇

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions