javascriptprettierprettier-vscodeprettier-standard

disable multiline ternary in prettier


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,
};

Solution

  • I also found a conflict between standard and prettier. Putting at the top of the file the following works for me

    /* eslint-disable multiline-ternary */ 
    

    See https://eslint.org/docs/latest/rules/multiline-ternary