Skip to content

CSS selectors with comments are not formatted #15356

Open

Description

@fregante

It seems to me that CSS selectors are not formatted at all. Is this a bug or a feature request?

Prettier 3.0.3
Playground link

--parser css

Input:

.a
                	.diff-text-cell
                	 .diff-text

      /*            Edit page, probably upcoming DOM everywhere 
*/
      ::before {
	        visibility: 
              hidden;
}

Output:

.a
                	.diff-text-cell
                	 .diff-text

      /*            Edit page, probably upcoming DOM everywhere 
*/
      ::before {
  visibility: hidden;
}

Expected behavior:

Something like this:

.a .diff-text-cell .diff-text
/* Edit page, probably upcoming DOM everywhere */
  ::before {
  visibility: hidden;
}

Potentially related:

Activity

  1. fregante commented on Sep 5, 2023

    @fregante
    Author
  2. added
    lang:css/scss/less
    on Sep 5, 2023
  3. fisker commented on Sep 5, 2023

    @fisker
  4. HolgerJeromin commented on Oct 27, 2023

    @HolgerJeromin
    Contributor

    The trigger of this bug is the comment. So we could add the github area:comments tag.
    Same with this:

    .myclass > :is(
        .myotherclass,
        /* comment breaks formatting */
    
    
        .myotherclass1, .myotherclass3, .myotherclass4, .myotherclass3) {
        display: none;
    }
  5. changed the title [-]CSS selectors are completely ignored[/-] [+]CSS selectors with comments are completely ignored[/+] on Oct 27, 2023
  6. changed the title [-]CSS selectors with comments are completely ignored[/-] [+]CSS selectors with comments are not formatted[/+] on Jul 24, 2024
  7. added theissue type on Mar 3, 2025
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/less

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions