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!
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.
Please try adding .prettierrc file to your code and adding a line in the object of the file.
"printWidth": 100
Reference screenshot:
Did not find a configuration. As a hack you might want to include a comment on the first line to break:
return ternaryExpression //
? trueResult
: falseResult;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With