Skip to content

Commit

Permalink
Squiz/SemicolonSpacing: bug fix
Browse files Browse the repository at this point in the history
Allow for the IE < 7 star-prefix hack before style property names.

Fixes 2453
  • Loading branch information
jrfnl committed Mar 21, 2019
1 parent e46e46c commit 8fda399
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$endOfThisStatement = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextStatement - 1), null, true);
$ignore = Tokens::$emptyTokens;
if ($tokens[$nextStatement]['code'] === T_STYLE) {
// Allow for star-prefix hack.
$ignore[] = T_MULTIPLY;
}

$endOfThisStatement = $phpcsFile->findPrevious($ignore, ($nextStatement - 1), null, true);
if ($tokens[$endOfThisStatement]['code'] !== T_SEMICOLON) {
$error = 'Style definitions must end with a semicolon';
$phpcsFile->addError($error, $endOfThisStatement, 'NotAtEnd');
Expand Down
5 changes: 5 additions & 0 deletions src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
;
}

.allow-for-star-hack {
cursor: pointer;
*cursor: hand;
}

/* Live coding. Has to be the last test in the file. */
.intentional-parse-error {
float: left
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
0px; /* right + left */
}

.allow-for-star-hack {
cursor: pointer;
*cursor: hand;
}

/* Live coding. Has to be the last test in the file. */
.intentional-parse-error {
float: left

0 comments on commit 8fda399

Please sign in to comment.