Skip to content

Destroys comments at end of line #368

@KieranP

Description

@KieranP

Your Environment

  • Plugin version: 5.2.2
  • Prettier version: 3.6.2
  • node version: 22.15.1
  • package manager: yarn@4

Describe the bug

Comments at end of imports being bumped to next line

import 'core-js/stable/url-search-params' // 2018+
import 'core-js/stable/array/flat-map' // 2019+
import 'core-js/stable/global-this' // 2019+
import 'core-js/stable/object/from-entries' // 2019+
import 'core-js/stable/string/replace-all' // 2020+
import 'core-js/stable/structured-clone' // 2022+

is being converted to:

import 'core-js/stable/url-search-params'
// 2018+
import 'core-js/stable/array/flat-map'
// 2019+
import 'core-js/stable/global-this'
// 2019+
import 'core-js/stable/object/from-entries'
// 2019+
import 'core-js/stable/string/replace-all' 
// 2020+
import 'core-js/stable/structured-clone'
// 2022+

All imports have this issue, but for side effects in particular, this happens even though I have "importOrderSideEffects": false,, so side effects should be unaffected.

To Reproduce

See above

Expected behavior

Comments should remain at the end of the lines

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

  "importOrderCaseInsensitive": true,
  "importOrderGroupNamespaceSpecifiers": true,
  "importOrderSeparation": true,
  "importOrderSideEffects": false,
  "importOrderSortSpecifiers": true,

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