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

Support TypeScript 5.0 and update dependencies

Open odiak opened this issue 2 years ago • 2 comments

  • Update some dependencies and support TypeScript 5.0
  • Fix code to work with latest @babel/generator (describing below)
    • @babel/generator changed way how to print comments
    • But some cases weren't fixed

Fixed cases

Sometimes new lines after comment (before first import) were broken.

unformatted:

// comment
import   y     from 'y'
import   x from 'x'

formatted (before fix):

// comment

import x from 'x'
import y from 'y'

formatted (after fix):

// comment
import x from 'x'
import y from 'y'

Unfixed cases

With new @babel/generator, new lines between comments are maintained. Because I think this behavior is natural, I didn't fix and updated test snapshots.

unformatted:

// comment1
/**
 * hello
 */

// comment2
import x        from 'x'

formatted (previously expected):

// comment1
/**
 * hello
 */
// comment2
import x from 'x'

formatted (newly expected):

// comment1
/**
 * hello
 */

// comment2
import x from 'x'

odiak avatar May 19 '23 01:05 odiak

Oops, CI on Node.js 12 failed because latest Jest only supports Node 14+.

odiak avatar May 19 '23 01:05 odiak

I also published forked version of the package. It contains changes of this pull request. Feel free to use it. https://www.npmjs.com/package/@odiak/prettier-plugin-sort-imports

odiak avatar May 19 '23 01:05 odiak