question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

space-after-declaration vs comments

See original GitHub issue

@mishanga @kizu, I can really use your advice here.

Take this code as an example:

a {
  color: tomato;      /* comment */
  position: fixed;
  /* comment */
  top: 0;
  left: 0;

  &:hover {
    color: black;     // comment
    top: 100%;
  }
}

What should be the result after processing this code with settings:

  1. 'space-after-declaration': ' ' and
  2. 'space-after-declaration': '\n'?

Related issue: #232

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kizucommented, Jul 8, 2014

I’d say that when the comment is on a line with another declaration, then, from a user’s standpoint, it is a part of a declaration as it is related to it.

The comments themselves, I’d say, should have their own space-before and space-after, so when there is a block-level comment, it should be still on its own line.

The preprocessor-style inline comment is tricky, I’d say that it should prevent the lines to join in all cases. Maybe we could add a preprocessor-specific option for converting such inline comments when there is something that should go after them.

So, as a user, I would expect:

  1. 'space-after-declaration': ' ':

    a {
      color: tomato;      /* comment */ position: fixed;
      /* comment */
      top: 0; left: 0;
    
      &:hover {
        color: black;     // comment
        top: 100%;
      }
    }
    
  2. 'space-after-declaration': '\n': just the initial result, as I would expect the inline comments to be treated as the part of declaration.

Also, I would expect the following options: space-[before|after]-[block|inline]-comment, where the inline comment is the comment placed on the same line as a declaration (or any other entity), while block comment is a comment that do not have any non-whitespace symbols on the line it starts from.

0reactions
tonyganchcommented, Jul 14, 2014

@kizu @mishanga, thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

declaration-colon-space-after - Stylelint
There must always be a single space after the colon if the declaration's value is single-line. The following patterns are considered problems: a...
Read more >
Formatting - Coding Style - Read the Docs
Comment lines can be longer than 80 characters if it is not feasible to split them ... Do not add spaces after the...
Read more >
PEP 8 – Style Guide for Python Code
Block comments generally apply to some (or all) code that follows them, and are indented to the same level as that code. Each...
Read more >
VS Code - space before function parentheses - Stack Overflow
In VS Code open File -> Preferences -> Settings; Add to your JSON config: "javascript.format.insertSpaceBeforeFunctionParenthesis": true.
Read more >
False positive of declaration-colon-space-after for single line ...
There must always be a single space after the colon if the declaration's value is single-line. Yes. But I'm in clamp currently: I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found