Skip to content

Commit e6a43fe

Browse files
committed
AC-939: Create unit test for Magento2\Less\AvoidIdSniff check
1 parent a636ed7 commit e6a43fe

File tree

4 files changed

+92
-2
lines changed

4 files changed

+92
-2
lines changed

Magento2/Sniffs/Less/AvoidIdSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class AvoidIdSniff implements Sniff
5151
T_PLUS,
5252
T_NS_SEPARATOR,
5353
T_LNUMBER,
54+
T_BITWISE_NOT
5455
];
5556

5657
/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// /**
2+
// * Copyright © Magento, Inc. All rights reserved.
3+
// * See COPYING.txt for license details.
4+
// */
5+
6+
#foo[bar],
7+
#foo[bar=bash],
8+
#foo[bar~=bash],
9+
#foo[bar$=bash],
10+
#foo[bar*=bash],
11+
#foo[bar|=bash],
12+
#foo[bar='bash'],
13+
#foo:hover,
14+
#foo:nth-last-of-type(n),
15+
#foo::before,
16+
#foo + div,
17+
#foo > div,
18+
#foo ~ div,
19+
#foo\3Abar ~ div,
20+
#foo\:bar ~ div,
21+
#foo.bar .baz,
22+
div#foo {
23+
blah: 'abc';
24+
}
25+
26+
.my #foo,
27+
#foo .blah,
28+
.my #foo .blah {
29+
some: 'stuff';
30+
}
31+
.blah {
32+
#bar .baz();
33+
.foo #bar .baz();
34+
#bar .baz();
35+
36+
#bar .baz;
37+
.foo #bar .baz;
38+
#bar .baz;
39+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Tests\Less;
7+
8+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
9+
10+
class AvoidIdUnitTest extends AbstractSniffUnitTest
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public function getErrorList()
16+
{
17+
return [
18+
6 => 1,
19+
7 => 1,
20+
8 => 1,
21+
9 => 1,
22+
10 => 1,
23+
11 => 1,
24+
12 => 1,
25+
13 => 1,
26+
14 => 1,
27+
15 => 1,
28+
16 => 1,
29+
17 => 1,
30+
18 => 1,
31+
19 => 1,
32+
20 => 1,
33+
21 => 3,
34+
22 => 1,
35+
26 => 1,
36+
27 => 1,
37+
28 => 1
38+
];
39+
}
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
public function getWarningList()
45+
{
46+
return [];
47+
}
48+
}

Magento2/ruleset.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<description>Magento Coding Standard</description>
44

55
<!-- File extensions to be checked. -->
6-
<arg name="extensions" value="php,phtml,graphqls/GraphQL"/>
6+
<arg name="extensions" value="php,phtml,graphqls/GraphQL,less"/>
77

88
<!-- Severity 10 errors: Critical code issues. -->
99
<rule ref="Generic.Functions.CallTimePassByReference">
@@ -590,7 +590,9 @@
590590
<exclude-pattern>*Test.php</exclude-pattern>
591591
</rule>
592592
<rule ref="Magento2.Html"/>
593-
<rule ref="Magento2.Less"/>
593+
<rule ref="Magento2.Less">
594+
<include-pattern>*\.less$</include-pattern>
595+
</rule>
594596
<rule ref="Internal.NoCodeFound">
595597
<severity>0</severity>
596598
</rule>

0 commit comments

Comments
 (0)