Skip to content

Idea: max-expression length #1099

@vjeux

Description

@vjeux

When people try setting the line width to more than 80 columns, it ends up being a bad experience because prettier tries to push too much content into a single line. I've also observed multiple times and had many people complaining that prettier didn't break expressions when it "should" have when code was on a single level of indentation, but worked better when code was in a deeply nested context.

I've talked about this problem with many people at Facebook and had a realization. I don't think that trying to push as much content as possible within 80 columns is the best heuristic to model how people are writing code. A potentially better one would be to have a maximum expression length.

If we have a max-expression length of 70, this means that an expression would break the same way for up to 5 levels of indentation given a tab width of 2 and 80 columns limit.

I think that it's going to be a subtle, but positive, change for 80 columns and would have a big impact if you increase that column count. I want to implement it and see how it feels but figured that I would post it first to get feedback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions