diff --git a/Magento2/Sniffs/Less/ColonSpacingSniff.php b/Magento2/Sniffs/Less/ColonSpacingSniff.php index 505c44fd..6b68ea65 100644 --- a/Magento2/Sniffs/Less/ColonSpacingSniff.php +++ b/Magento2/Sniffs/Less/ColonSpacingSniff.php @@ -60,12 +60,13 @@ private function needValidateSpaces(File $phpcsFile, $stackPtr, $tokens) return false; } - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] !== T_STYLE) { - // The colon is not part of a style definition. + // Avoid false positives when parsing pseudo-classes + $next = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $stackPtr + 1); + if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) { return false; } + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($tokens[$prev]['content'] === 'progid') { // Special case for IE filters. return false; diff --git a/Magento2/Tests/Less/ColonSpacingUnitTest.less b/Magento2/Tests/Less/ColonSpacingUnitTest.less index 37de49e4..cd6a3fd3 100644 --- a/Magento2/Tests/Less/ColonSpacingUnitTest.less +++ b/Magento2/Tests/Less/ColonSpacingUnitTest.less @@ -5,22 +5,46 @@ div#foo { - blah:'abc'; + blah:'abc'; } .my #foo .blah { - some: 'stuff'; + some: 'stuff'; } .blah { - foo :'jkl'; + foo :'jkl'; } .foo { - bar: + bar: 'xyz'; } .right { - way: 'good' + way: 'good'; +} + +a:active { + color: #000; +} + +@abs-action-button-as-link: { + &:not(:focus) { + box-shadow: none; + } +} + +.actions-toolbar { + &:not(:first-child) { + &:extend(.abs-add-clearfix all); + > .secondary { + .action { + &.add { + margin-top: @indent__l; + } + } + float: left; + } + } }