Skip to content

Commit

Permalink
Merge branch 'magento-commerce:develop' into jorsini/MTS-2096
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinijose authored Aug 25, 2021
2 parents bd8c956 + 05c75c0 commit 92e4d48
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 4 deletions.
1 change: 1 addition & 0 deletions Magento2/Sniffs/Less/AvoidIdSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AvoidIdSniff implements Sniff
T_PLUS,
T_NS_SEPARATOR,
T_LNUMBER,
T_BITWISE_NOT
];

/**
Expand Down
33 changes: 33 additions & 0 deletions Magento2/Tests/Less/AbstractLessSniffUnitTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Copyright © Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento2\Tests\Less;

use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;

/**
* Implements an abstract base for unit tests that cover less sniffs.
*/
abstract class AbstractLessSniffUnitTestCase extends AbstractSniffUnitTest
{
/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();

$config = new Config();
$config->extensions = array_merge(
$config->extensions,
[
'less' => 'CSS'
]
);

$GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config;
}
}
39 changes: 39 additions & 0 deletions Magento2/Tests/Less/AvoidIdUnitTest.less
Original file line number Diff line number Diff line change
@@ -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;
}
46 changes: 46 additions & 0 deletions Magento2/Tests/Less/AvoidIdUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento2\Tests\Less;

class AvoidIdUnitTest extends AbstractLessSniffUnitTestCase
{
/**
* @inheritdoc
*/
public function getErrorList()
{
return [
6 => 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 => 1,
22 => 1,
26 => 1,
27 => 1,
28 => 1
];
}

/**
* @inheritdoc
*/
public function getWarningList()
{
return [];
}
}
6 changes: 4 additions & 2 deletions Magento2/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<description>Magento Coding Standard</description>

<!-- File extensions to be checked. -->
<arg name="extensions" value="php,phtml,graphqls/GraphQL"/>
<arg name="extensions" value="php,phtml,graphqls/GraphQL,less/CSS,html/PHP"/>

<!-- Severity 10 errors: Critical code issues. -->
<rule ref="Generic.Functions.CallTimePassByReference">
Expand Down Expand Up @@ -590,7 +590,9 @@
<exclude-pattern>*Test.php</exclude-pattern>
</rule>
<rule ref="Magento2.Html"/>
<rule ref="Magento2.Less"/>
<rule ref="Magento2.Less">
<include-pattern>*\.less$</include-pattern>
</rule>
<rule ref="Internal.NoCodeFound">
<severity>0</severity>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"AFL-3.0"
],
"type": "phpcodesniffer-standard",
"version": "7",
"version": "8",
"require": {
"php": ">=7.3",
"squizlabs/php_codesniffer": "^3.6",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 92e4d48

Please sign in to comment.