Stylelint: Fix false positives for shared-line comments after multiline values in comment-empty-line-before

Created on 20 Oct 2017  Â·  3Comments  Â·  Source: stylelint/stylelint

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

It would be great to be able to ignore comment-empty-line-before rule when comment are after a specific char or end of the line.

I use CSS Guideline comments technic

Which rule, if any, is this issue related to?

comment-empty-line-before

What CSS is needed to reproduce this issue?

/**
 * This is a comment
 *
 * 1. This is a specific comment
 * 2. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas
 * nesciunt facilis omnis et dignissimos, labore, voluptatum aliquid, est
 * debitis qui expedita dolores reprehenderit laborum temporibus.
 */
h1 {
    font-size: 1rem;

    background-image: linear-gradient(
        -100deg,
        color(rgba(255, 0, 0, 1) alpha(-70%)),
        color(rgba(255, 0, 0, 1) alpha(-30%)) 95%, /* [1] */
        color(rgba(255, 0, 0, 1) alpha(-90%))
    ); /* [1] */

    border-radius:
        1em
        0; /* [2] */
}

What stylelint configuration is needed to reproduce this issue?

{
    "rules": {
        "comment-empty-line-before": [
             "always",
             {
                 "except": ["first-nested"],
                 "ignore": ["stylelint-commands"]
             }
        ],
    }
}

Which version of stylelint are you using?

8.2.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

I use it via CLI $ stylelint "test/*.css" and _gulp-stylelint_

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

nope

What did you expect to happen?

No warnings to be flagged.

What actually happened (e.g. what warnings or errors you are getting)?

"The following warnings were flagged:"

test/test.css
 17:8 ✖ Expected empty line before comment comment-empty-line-before
 21:12 ✖ Expected empty line before comment comment-empty-line-before
bug

All 3 comments

you can use https://github.com/alienlebarge/stylelint-config to reproduce the bug

@alienlebarge Thanks for the report and for using the template.

I can reproduce this with:

a {
  border-radius:
    1em
    0; /* shared-line comment */
}

Gives:

4:8 error Expected empty line before comment (comment-empty-line-before)

This is a bug as comment-empty-line-before should not be applied to shared-line comments.

I believe the isSharedLineComment util will need to be fixed to account for this type of shared-line comment.

@alienlebarge I'm labelling this as "help wanted". Please consider contributing a fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jitendravyas picture jitendravyas  Â·  3Comments

Linxflasher picture Linxflasher  Â·  3Comments

ntwb picture ntwb  Â·  3Comments

jeddy3 picture jeddy3  Â·  3Comments

rosven picture rosven  Â·  3Comments