Skip to content

Config for CSS selectors to multi-line #5937

Closed

Description

@syntag

Prettier 1.16.4
Playground link

Currently, Prettier forces all CSS Selectors to be on their own line. This is a nice feature but takes too much vertical height for selectors with an initial short horizontal width. This creates unnecessarily long files for a selector that was simple to begin with.

I propose that we add a simple config that I believe will cover every CSS developer's use case, such as: { styleSelectorWidth : 40} (default: 0 = All CSS selectors on a new line). This would behave similarly to eslint's' max-len rule and Prettier's rationale behind --print-width.

Related: #5086, #3464

Input:

h1, h2, h3, h4, h5, h6 {
  margin: 0;
}

.container, .button, .heading, .description {
  display: flex;  
}

Output:

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
}

.container,
.button,
.heading,
.description {
  display: flex;
}

Expected behavior:

h1, h2, h3, h4, h5, h6 {
  margin: 0;
}

.container,
.button,
.heading,
.description {
  display: flex; 
}

Activity

  1. j-f1 commented on Mar 5, 2019

    @j-f1
    Member

    Instead of an option, we should have a heuristic for this. Please follow along in #5086.

  2. added
    lang:css/scss/less
    type:duplicate
    on Mar 5, 2019
  3. added
    locked-due-to-inactivity
    on Jun 3, 2019
  4. locked as resolved and limited conversation to collaborators on Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:css/scss/lesslocked-due-to-inactivitytype:duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions