Is there a config in prettier to keep line breaks?

juan ocho picture juan ocho · Jul 10, 2019 · Viewed 16.3k times · Source

have a problem with prettier extension in VS Code, When I write this:

const result = await pool
      .request()
      .query('select NumberPlate, ID, TimeStamp from RESULTS order by ID');

and save the file, it turns into a single line like this:

const result = await pool.request().query('select NumberPlate, ID, TimeStamp from RESULTS order by ID');

with the following config in prettier:

{
    "git.confirmSync": false,
    "editor.minimap.enabled": false,
    "window.zoomLevel": 0,
    "liveServer.settings.donotShowInfoMsg": true,
    "workbench.startupEditor": "newUntitledFile",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "editor.formatOnSave": true,
    "prettier.printWidth": 200,
    "prettier.singleQuote": true,
    "prettier.arrowParens": "always",
    "editor.tabSize": 2,
    "editor.tabCompletion": "on"
}

Is there a way to avoid this from happening?

Thanks!

Answer

Antoine Gagnon picture Antoine Gagnon · Jul 10, 2019

According to this Github issue and looking at the doc, it doesn't seem to be possible to configure it to keep line breaks.

You could however set a very short printWidth or put // prettier-ignore comment above your code.