millermedeiros / esformatter

ECMAScript code beautifier/formatter
MIT License
970 stars 91 forks source link

Keep linebreaks in import #476

Closed AlexDunmow closed 7 years ago

AlexDunmow commented 7 years ago

Esformatter is turning this:

import {
    ONE_THING,
    TWO_THING,
    THREE_THING
} from 'lib'

into this import { ONE_THING, TWO_THING, THREE_THING } from 'lib'

How do I tell esformatter not to remove line breaks from the import statement? This doesn't work:

    "lineBreak": {
      "after": {
        "ImportSpecifier": 1,
        "ImportSpecifierComma": 1
      }
    },
millermedeiros commented 7 years ago

I think this is handled by ModuleSpecifierComma: https://github.com/millermedeiros/esformatter/blob/master/lib/preset/default-linebreak-after.js#L75

see: https://github.com/millermedeiros/esformatter/blob/master/lib/hooks/ImportSpecifier.js#L22

let me know if that doesn't solve your problem.

millermedeiros commented 7 years ago

@AlexDunmow

see also:

you can set values to -1 to keep existing formatting, so in this case something like lineBreak.after.ModuleSpecifierComma = -1

marking as closed; feel free to reopen if issue persists.