magento/magento-coding-standard

Expected 1 space after colon with &:not(:first-child)

Sental opened this issue ยท 8 comments

Preconditions

  1. In a less file if you use &:not(:first-child) it generates spacing warnings.

Steps to reproduce

  1. Use &:not(:first-child) in a less file.
  2. Run the coding standard from command line. vendor/bin/phpcs --standard=Magento2 path/to/module

Expected result

  1. No Warnings are generated.

Actual result

  1. Warnings are generated
    154 | WARNING | Expected 1 space after colon in style definition; newline found
    154 | WARNING | Expected 1 space after colon in style definition; 0 found

Hi @Sental. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


Same issue experiences. Actually all pseudo classes not need require spacing after

The phpcs tools should only scan *.php (and maybe *.phtml) files, why is it being used to scan *.less files as well? That makes little sense?

@sivaschenko, could you take a look?
We have an example where this issue reproducing on a PR - magento/magento2#35101 (comment)

@ihor-sviziev yes, we'll work on it

svera commented

@Sental @mrtuvn just released version 25 which should fix this issue.

I guess the changes are the following: #405

@Sental, could you confirm that issue is solved now?

Also found magento yelling warning non-sense at this code

.box-tocart {
    .paypal:first-of-type {
      margin-top: 13px;
    }
  }

:first-of-type totally valid. It's doesn't require space after that colon

.lib-link(
                @_link-color: @primary__color,
                @_link-text-decoration: none,
                @_link-color-visited: @primary__color,
                @_link-text-decoration-visited: none,
                @_link-color-hover: @primary__color,
                @_link-text-decoration-hover: underline,
                @_link-color-active: @primary__color,
                @_link-text-decoration-active: underline
            );

Also detected new line after colon at mixins less declare => still valid with me in my point of view