Skip to content

Commit 2fc6815

Browse files
committed
AC-1100: Catch badly put newlines in LESS files
1 parent 142ef3b commit 2fc6815

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Magento2/Sniffs/Less/ColonSpacingSniff.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ public function register()
3939
public function process(File $phpcsFile, $stackPtr)
4040
{
4141
$tokens = $phpcsFile->getTokens();
42-
43-
$nextSemicolon = $phpcsFile->findNext(T_SEMICOLON, $stackPtr);
44-
if (false !== $nextSemicolon && ($tokens[$nextSemicolon]['line'] !== $tokens[$stackPtr]['line'])) {
45-
$error = 'Expected 1 space after colon in style definition; newline found';
46-
$phpcsFile->addError($error, $stackPtr, 'AfterNewline');
47-
}
4842

4943
if ($this->needValidateSpaces($phpcsFile, $stackPtr, $tokens)) {
5044
$this->validateSpaces($phpcsFile, $stackPtr, $tokens);
@@ -95,6 +89,12 @@ private function validateSpaces(File $phpcsFile, $stackPtr, array $tokens)
9589
$phpcsFile->addError('There must be no space before a colon in a style definition', $stackPtr, 'Before');
9690
}
9791

92+
$nextSemicolon = $phpcsFile->findNext(T_SEMICOLON, $stackPtr);
93+
if (false !== $nextSemicolon && ($tokens[$nextSemicolon]['line'] !== $tokens[$stackPtr]['line'])) {
94+
$error = 'Expected 1 space after colon in style definition; newline found';
95+
$phpcsFile->addError($error, $stackPtr, 'AfterNewline');
96+
}
97+
9898
if (T_WHITESPACE !== $tokens[($stackPtr + 1)]['code']) {
9999
$phpcsFile->addError('Expected 1 space after colon in style definition; 0 found', $stackPtr, 'NoneAfter');
100100
} else {

0 commit comments

Comments
 (0)