Skip to content

Commit 756ca2d

Browse files
authored
Merge pull request magento#188 from magento-commerce/imported-svera-magento-coding-standard-405
[Imported] AC-3520: Avoid processing less and CSS pseudo-classes
2 parents f5b3d0e + 31335a0 commit 756ca2d

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

Magento2/Sniffs/Less/ColonSpacingSniff.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ private function needValidateSpaces(File $phpcsFile, $stackPtr, $tokens)
6060
return false;
6161
}
6262

63-
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
64-
if ($tokens[$prev]['code'] !== T_STYLE) {
65-
// The colon is not part of a style definition.
63+
// Avoid false positives when parsing pseudo-classes
64+
$next = $phpcsFile->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $stackPtr + 1);
65+
if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) {
6666
return false;
6767
}
6868

69+
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
6970
if ($tokens[$prev]['content'] === 'progid') {
7071
// Special case for IE filters.
7172
return false;

Magento2/Tests/Less/ColonSpacingUnitTest.less

+29-5
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,46 @@
55

66

77
div#foo {
8-
blah:'abc';
8+
blah:'abc';
99
}
1010

1111
.my #foo .blah {
12-
some: 'stuff';
12+
some: 'stuff';
1313
}
1414

1515
.blah {
16-
foo :'jkl';
16+
foo :'jkl';
1717
}
1818

1919
.foo {
20-
bar:
20+
bar:
2121
'xyz';
2222
}
2323

2424
.right {
25-
way: 'good'
25+
way: 'good';
26+
}
27+
28+
a:active {
29+
color: #000;
30+
}
31+
32+
@abs-action-button-as-link: {
33+
&:not(:focus) {
34+
box-shadow: none;
35+
}
36+
}
37+
38+
.actions-toolbar {
39+
&:not(:first-child) {
40+
&:extend(.abs-add-clearfix all);
41+
> .secondary {
42+
.action {
43+
&.add {
44+
margin-top: @indent__l;
45+
}
46+
}
47+
float: left;
48+
}
49+
}
2650
}

0 commit comments

Comments
 (0)