diff --git a/Magento2/Sniffs/Less/ColourDefinitionSniff.php b/Magento2/Sniffs/Less/ColourDefinitionSniff.php index 82568824..945abffd 100644 --- a/Magento2/Sniffs/Less/ColourDefinitionSniff.php +++ b/Magento2/Sniffs/Less/ColourDefinitionSniff.php @@ -42,7 +42,7 @@ public function process(File $phpcsFile, $stackPtr) $variablePtr = $phpcsFile->findPrevious(T_ASPERAND, $stackPtr); if ((false === $variablePtr) || ($tokens[$stackPtr]['line'] !== $tokens[$variablePtr]['line'])) { - $phpcsFile->addError('Hexadecimal value should be used for variable', $stackPtr, 'NotInVariable'); + $phpcsFile->addError('A variable should be used for a CSS colour', $stackPtr, 'NotInVariable'); } $expected = strtolower($colour); diff --git a/Magento2/Tests/Less/ColourDefinitionUnitTest.less b/Magento2/Tests/Less/ColourDefinitionUnitTest.less new file mode 100644 index 00000000..49af23a9 --- /dev/null +++ b/Magento2/Tests/Less/ColourDefinitionUnitTest.less @@ -0,0 +1,25 @@ +// /** +// * Copyright © Magento, Inc. All rights reserved. +// * See COPYING.txt for license details. +// */ + +@red: #aaaaaa; +@blue: #00F; +@green: #0f0; +@purple: #abcdef; + +.my{ + color: @red; +} + +.foo { + color: #aaa; +} + +.baz { + color: @blue; +} + +.bar { + color: @green; +} diff --git a/Magento2/Tests/Less/ColourDefinitionUnitTest.php b/Magento2/Tests/Less/ColourDefinitionUnitTest.php new file mode 100644 index 00000000..890a39ca --- /dev/null +++ b/Magento2/Tests/Less/ColourDefinitionUnitTest.php @@ -0,0 +1,29 @@ + 1, + 7 => 1, + 16 => 1, + ]; + } + + /** + * @inheritdoc + */ + public function getWarningList() + { + return []; + } +}