6

Is there way to config prettier to prevent not multi line the ternary operation?

wanted this:

const route = routeModule.config ? routeModule.config(router) : routeModule(router);

not this:

  const route = routeModule.config
        ? routeModule.config(router)
        : routeModule(router);

My prettier.config.js :

module.exports = {
    trailingComma: 'es5',
    tabWidth: 4,
    semi: true,
    singleQuote: true,
    printwidth: 200,
    bracketspacings: true,
};
Mohsen
  • 1,295
  • 1
  • 15
  • 45
  • 3
    I don't know if it's configurable, but honestly the way it formatted it is more readable than having it on one line. – Brandon Dyer Sep 19 '21 at 21:01
  • 4
    I don't mind the multi-line, but I wish it would put the ? on the same line as the condition. It reads much better that way IMO. – PsiKai Apr 07 '22 at 04:19
  • similar question https://stackoverflow.com/questions/65030709/vscode-formatting-ternary-incorrectly-within-reacts-jsx – Michael Freidgeim Feb 22 '23 at 22:03

0 Answers0