Skip to content

CSS comment partially eaten #2468

Closed
Closed

Description

@beauroberts

Apologies if this is the same issue as #2127 - I noticed that in that case the entire comment is eaten, whereas here it's just a substring within the comment.

Input

.first-selector, // some|comment
.second-selector {
    color: white;
}

Expected

.first-selector,
// some|comment
.second-selector {
    color: white;
}

Output

Notice that the part of the comment up to and including the vertical bar is discarded

.first-selector,
// comment
.second-selector {
    color: white;
}

Repro

https://prettier.io/playground/#%7B%22content%22%3A%22.first-selector%2C%5Cn%2F%2F%20some%7Ccomment%5Cn.second-selector%20%7B%5Cn%20%20%20%20color%3A%20white%3B%5Cn%7D%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3A%22none%22%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22parser%22%3A%22postcss%22%2C%22semi%22%3Atrue%2C%22useTabs%22%3Afalse%2C%22doc%22%3Afalse%2C%22ast%22%3Afalse%7D%7D

Thanks for an amazing tool! We have an enormous codebase and it's been nearly flawless.

Activity

  1. added
    area:comments
    scope:dependency
    on Jul 13, 2017
  2. azz commented on Jul 13, 2017

    @azz
    Member

    Thanks for the bug report.

    This is a bug (or potentially unsupported feature) of one in our dependencies. I've raised it at postcss/postcss-selector-parser#112.

  3. added
    lang:css/scss/less
    on Oct 1, 2017
  4. suchipi commented on Dec 9, 2017

    @suchipi
    Member

    As a workaround, you can use inline comments (normal CSS syntax), but it's still not very pretty:

    Prettier 1.9.1
    Playground link

    --parser less

    Input:

    .first-selector, /* some|comment */
    .second-selector {
        color: white;
    }

    Output:

    .first-selector,
    /* some|comment */ .second-selector {
      color: white;
    }
    
  5. azz commented on Jan 5, 2018

    @azz
    Member

    Fixed in #3649

  6. added
    locked-due-to-inactivity
    on Jul 6, 2018
  7. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  8. 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

    area:commentslang:css/scss/lesslocked-due-to-inactivityscope:dependency

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions