magento-coding-standard icon indicating copy to clipboard operation
magento-coding-standard copied to clipboard

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

Open Sental opened this issue 2 years ago • 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

Sental avatar May 25 '22 05:05 Sental

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


m2-assistant[bot] avatar May 25 '22 05:05 m2-assistant[bot]

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

mrtuvn avatar Jun 06 '22 00:06 mrtuvn

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?

hostep avatar Jun 06 '22 09:06 hostep

@sivaschenko, could you take a look? We have an example where this issue reproducing on a PR - https://github.com/magento/magento2/pull/35101#issuecomment-1146916983

ihor-sviziev avatar Jun 09 '22 12:06 ihor-sviziev

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

sivaschenko avatar Jun 13 '22 12:06 sivaschenko

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

svera avatar Jun 21 '22 13:06 svera

I guess the changes are the following: https://github.com/magento/magento-coding-standard/pull/405

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

ihor-sviziev avatar Jun 21 '22 13:06 ihor-sviziev

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

mrtuvn avatar Apr 11 '23 14:04 mrtuvn