Prettier 2.0.2
Playground link
--arrow-parens avoid
--parser babel
--no-semi
--single-quote
--trailing-comma none
You may wonder what would be the use case for this kind of behavior. It happened to me as I wrote a generator cli for a project creating several files based on user input data and automatically applying a prettier format when those are generated. One of the files provides the empty import statement with the comment in the middle of the curly braces to invite the developer to import what he should from a precise package.
I currently use the first version commented with // works in the example to work around the issue.
Input:
// works
import {} from 'something'
// breaks
import { /* comment */ } from 'some-package'
// breaks too
import {
// Comment
} from 'some other package'
Output:
// works
import {} from 'something'
// breaks
import /* comment */ 'some-package'
// breaks too
import // Comment
'some other package'
Expected behavior:
// works
import {} from 'something'
// breaks
import { /* comment */ } from 'some-package'
// breaks too
import {
// Comment
} from 'some other package'
Prettier 2.0.2
Playground link
You may wonder what would be the use case for this kind of behavior. It happened to me as I wrote a generator cli for a project creating several files based on user input data and automatically applying a prettier format when those are generated. One of the files provides the empty import statement with the comment in the middle of the curly braces to invite the developer to import what he should from a precise package.
I currently use the first version commented with
// worksin the example to work around the issue.Input:
Output:
Expected behavior: