Search code examples
firebaseeslintfirebase-cliprettier

Possible to make Prettier allow chaining functions on new lines?


I'm writing some Firebase functions. Out of the box, it comes with EsLint with eslint-plugin-promise (which is great). It seems that eslint-plugin-promise is bringing in prettier as well. I'm not used to prettier, but I've configured a few things to my liking in a .prettierrc file, but I can't figure out this Promise chaining problem.

I'm chaining Promise calls on new lines, but prettier is forcing me to put them onto one line.

My code:

module.exports = functions.firestore
    .document('thing/{thingId}')
    .onCreate((snap, context) => {
        // stuff
    });

What Prettier is reformatting to:

module.exports = functions.firestore.document('thing/{thingId}').onCreate((snap, context) => {
    // stuff
}

Prettier's version is worse in my opinion. It's harder to read and harder to diff.

Any idea how I can turn this off? I've just disabled Prettier for now, which I don't like since I like most of what Prettier does.


Solution

  • This is behavior is changed in Prettier 2.