When I format the file, Prettier breaks the line and moves return foo(
to a new line.
Why is that? I’ve set printWidth = 200
, and there’s plenty of space to keep it on one line.
How can I stop Prettier from breaking the line like that?
I’m not looking for a workaround like prettier-ignore
.
Is there a configuration option to control this?
Sure! Here’s a more natural rephrasing:
function foo() { // I don't care whether it works or not — I'm only concerned about the formatting
/*
return foo('test', baz`
some text here
`);
*/
return foo(
'test',
baz`
some text here
`
);
}
.prettierrc:
{
"singleQuote": true,
"arrowParens": "always",
"semi": true,
"trailingComma": "es5",
"bracketSameLine": true,
"printWidth": 200
}
This is what I expect (and it’s fine that the text is on a new line since I pressed Enter there):
return foo('test', baz`
some text here
`);