From e6a43fe26035a8a402f822b861f88f3529131db0 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 24 Aug 2021 14:40:57 +0200 Subject: [PATCH 1/4] AC-939: Create unit test for Magento2\Less\AvoidIdSniff check --- Magento2/Sniffs/Less/AvoidIdSniff.php | 1 + Magento2/Tests/Less/AvoidIdUnitTest.inc | 39 ++++++++++++++++++++ Magento2/Tests/Less/AvoidIdUnitTest.php | 48 +++++++++++++++++++++++++ Magento2/ruleset.xml | 6 ++-- 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 Magento2/Tests/Less/AvoidIdUnitTest.inc create mode 100644 Magento2/Tests/Less/AvoidIdUnitTest.php diff --git a/Magento2/Sniffs/Less/AvoidIdSniff.php b/Magento2/Sniffs/Less/AvoidIdSniff.php index d4e1b213..387b5ed8 100644 --- a/Magento2/Sniffs/Less/AvoidIdSniff.php +++ b/Magento2/Sniffs/Less/AvoidIdSniff.php @@ -51,6 +51,7 @@ class AvoidIdSniff implements Sniff T_PLUS, T_NS_SEPARATOR, T_LNUMBER, + T_BITWISE_NOT ]; /** diff --git a/Magento2/Tests/Less/AvoidIdUnitTest.inc b/Magento2/Tests/Less/AvoidIdUnitTest.inc new file mode 100644 index 00000000..070c2eec --- /dev/null +++ b/Magento2/Tests/Less/AvoidIdUnitTest.inc @@ -0,0 +1,39 @@ +// /** +// * Copyright © Magento, Inc. All rights reserved. +// * See COPYING.txt for license details. +// */ + +#foo[bar], +#foo[bar=bash], +#foo[bar~=bash], +#foo[bar$=bash], +#foo[bar*=bash], +#foo[bar|=bash], +#foo[bar='bash'], +#foo:hover, +#foo:nth-last-of-type(n), +#foo::before, +#foo + div, +#foo > div, +#foo ~ div, +#foo\3Abar ~ div, +#foo\:bar ~ div, +#foo.bar .baz, +div#foo { +blah: 'abc'; +} + +.my #foo, +#foo .blah, +.my #foo .blah { +some: 'stuff'; +} +.blah { +#bar .baz(); +.foo #bar .baz(); +#bar .baz(); + +#bar .baz; +.foo #bar .baz; +#bar .baz; +} diff --git a/Magento2/Tests/Less/AvoidIdUnitTest.php b/Magento2/Tests/Less/AvoidIdUnitTest.php new file mode 100644 index 00000000..962af35f --- /dev/null +++ b/Magento2/Tests/Less/AvoidIdUnitTest.php @@ -0,0 +1,48 @@ + 1, + 7 => 1, + 8 => 1, + 9 => 1, + 10 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + 15 => 1, + 16 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + 20 => 1, + 21 => 3, + 22 => 1, + 26 => 1, + 27 => 1, + 28 => 1 + ]; + } + + /** + * @inheritdoc + */ + public function getWarningList() + { + return []; + } +} diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 3ea0c969..daf54da8 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -3,7 +3,7 @@ Magento Coding Standard - + @@ -590,7 +590,9 @@ *Test.php - + + *\.less$ + 0 From a9ef69fb91391df629b460adcd106dff70c511e6 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 24 Aug 2021 14:45:19 +0200 Subject: [PATCH 2/4] AC-939: Create unit test for Magento2\Less\AvoidIdSniff check --- Magento2/Tests/Less/{AvoidIdUnitTest.inc => AvoidIdUnitTest.less} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Magento2/Tests/Less/{AvoidIdUnitTest.inc => AvoidIdUnitTest.less} (100%) diff --git a/Magento2/Tests/Less/AvoidIdUnitTest.inc b/Magento2/Tests/Less/AvoidIdUnitTest.less similarity index 100% rename from Magento2/Tests/Less/AvoidIdUnitTest.inc rename to Magento2/Tests/Less/AvoidIdUnitTest.less From e538e6f9fac9eaabba920c70c1ed4bfdbeadbbb4 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Wed, 25 Aug 2021 12:39:03 +0200 Subject: [PATCH 3/4] AC-939: Create unit test for Magento2\Less\AvoidIdSniff check --- .../Less/AbstractLessSniffUnitTestCase.php | 33 +++++++++++++++++++ Magento2/Tests/Less/AvoidIdUnitTest.php | 6 ++-- Magento2/ruleset.xml | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 Magento2/Tests/Less/AbstractLessSniffUnitTestCase.php diff --git a/Magento2/Tests/Less/AbstractLessSniffUnitTestCase.php b/Magento2/Tests/Less/AbstractLessSniffUnitTestCase.php new file mode 100644 index 00000000..71edcbee --- /dev/null +++ b/Magento2/Tests/Less/AbstractLessSniffUnitTestCase.php @@ -0,0 +1,33 @@ +extensions = array_merge( + $config->extensions, + [ + 'less' => 'CSS' + ] + ); + + $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; + } +} diff --git a/Magento2/Tests/Less/AvoidIdUnitTest.php b/Magento2/Tests/Less/AvoidIdUnitTest.php index 962af35f..33012879 100644 --- a/Magento2/Tests/Less/AvoidIdUnitTest.php +++ b/Magento2/Tests/Less/AvoidIdUnitTest.php @@ -5,9 +5,7 @@ */ namespace Magento2\Tests\Less; -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -class AvoidIdUnitTest extends AbstractSniffUnitTest +class AvoidIdUnitTest extends AbstractLessSniffUnitTestCase { /** * @inheritdoc @@ -30,7 +28,7 @@ public function getErrorList() 18 => 1, 19 => 1, 20 => 1, - 21 => 3, + 21 => 1, 22 => 1, 26 => 1, 27 => 1, diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index daf54da8..204946d0 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -3,7 +3,7 @@ Magento Coding Standard - + From b1c005c3f5ed687f149c9b0f285818c2123dd6de Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko Date: Wed, 25 Aug 2021 11:47:31 +0100 Subject: [PATCH 4/4] Version 8 --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index cc1950eb..f30fd7fd 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "AFL-3.0" ], "type": "phpcodesniffer-standard", - "version": "7", + "version": "8", "require": { "php": ">=7.3", "squizlabs/php_codesniffer": "^3.6", diff --git a/composer.lock b/composer.lock index 72a2ad6a..c26f9e74 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1ed3638000f0e172d4e01c45333fcfb6", + "content-hash": "93bec1b3a36cf67f2511aec0219bcc06", "packages": [ { "name": "squizlabs/php_codesniffer",