Skip to content

Commit 8bf94b6

Browse files
committed
AC-391: Static test to cover "deprecated" jQuery methods
- Fixed naming and comment issues
1 parent e4c8f20 commit 8bf94b6

11 files changed

+26
-19
lines changed

Magento2/Tests/Eslint/MiscDeprecatedExprTest.php renamed to Magento2/Tests/Eslint/DeprecatedExprTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
namespace Magento2\Tests\Eslint;
99

1010
/**
11-
* Class EventShorthandTest
11+
* Class DeprecatedExprTest
1212
*
13-
* Test Eslint Rule: jquery-no-event-shorthand.js
13+
* Test Eslint Rule: jquery-no-deprecated-expr.js
1414
*/
15-
class MiscDeprecatedExprTest extends AbstractEslintTestCase
15+
class DeprecatedExprTest extends AbstractEslintTestCase
1616
{
1717
public function testExecute(): void
1818
{
1919
$this->assertFileContainsError(
20-
'MiscDeprecatedExprTest.js',
20+
'DeprecatedExprTest.js',
2121
[
2222
'jQuery.expr[":"] is deprecated; Use jQuery.expr.pseudos instead',
2323
'jQuery.expr.filters is deprecated; Use jQuery.expr.pseudos instead'

Magento2/Tests/Eslint/ClickEventShorthandTest.php renamed to Magento2/Tests/Eslint/InputEventShorthandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
namespace Magento2\Tests\Eslint;
99

1010
/**
11-
* Class ClickEventShorthandTest
11+
* Class InputEventShorthandTest
1212
*
13-
* Test Eslint Rule: jquery-no-click-event-shorthand.js
13+
* Test Eslint Rule: jquery-no-input-event-shorthand.js
1414
*/
15-
class ClickEventShorthandTest extends AbstractEslintTestCase
15+
class InputEventShorthandTest extends AbstractEslintTestCase
1616
{
1717
public function testExecute(): void
1818
{
1919
$this->assertFileContainsError(
20-
'ClickEventShorthandTest.js',
20+
'InputEventShorthandTest.js',
2121
[
2222
'Instead of .blur(fn) use .on("blur", fn). Instead of .blur() use .trigger("blur")',
2323
'Instead of .focus(fn) use .on("focus", fn). Instead of .focus() use .trigger("focus")',

Magento2/Tests/Eslint/MiscDeprecatedFunctionsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
namespace Magento2\Tests\Eslint;
99

1010
/**
11-
* Class EventShorthandTest
11+
* Class MiscDeprecatedFunctionsTest
1212
*
13-
* Test Eslint Rule: jquery-no-event-shorthand.js
13+
* Test Eslint Rule: jquery-no-misc-deprecated-functions.js
1414
*/
1515
class MiscDeprecatedFunctionsTest extends AbstractEslintTestCase
1616
{

eslint/.eslintrc-jquery

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2+
"ignorePatterns": ["**/vendor/**/*.js", "**/node_modules/**/*.js"],
23
"rules": {
34
"jquery-no-andSelf": 2,
45
"jquery-no-bind-unbind": 2,
5-
"jquery-no-click-event-shorthand": 2,
6+
"jquery-no-input-event-shorthand": 2,
67
"jquery-no-delegate-undelegate": 2,
78
"jquery-no-event-shorthand": 2,
89
"jquery-no-size": 2,

eslint/rules/jquery-no-deprecated-expr.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
meta: {
33
type: 'suggestion',
44
docs: {
5-
description: 'Disallow the use of shorthand event methods',
5+
description: 'Disallow the use of deprecated way to add to custom selectors',
66
category: 'jQuery deprecated functions',
77
recommended: true,
88
url: 'https://api.jquery.com/load/'
@@ -23,7 +23,7 @@ module.exports = {
2323

2424
return {
2525
/**
26-
* Checks if shorthand methods are used and reports it.
26+
* Checks for jQuery.expr[':']
2727
*
2828
* @param {Object} node - The node to check.
2929
*/
@@ -35,6 +35,12 @@ module.exports = {
3535
});
3636
}
3737
},
38+
39+
/**
40+
* Checks for jQuery.expr.filters
41+
*
42+
* @param {Object} node - The node to check.
43+
*/
3844
'MemberExpression[property.name="filters"] MemberExpression[property.name="expr"]': function (node) {
3945
if (utils.isjQuery(node)) {
4046
context.report({

eslint/rules/jquery-no-event-shorthand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = {
4444
if (utils.isjQuery(node)) {
4545
context.report({
4646
node: node,
47-
message: namesToMsg[name]
47+
message: message
4848
});
4949
}
5050
}

eslint/rules/jquery-no-click-event-shorthand.js renamed to eslint/rules/jquery-no-input-event-shorthand.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
meta: {
33
type: 'suggestion',
44
docs: {
5-
description: 'Disallow the use of shortcuts to trigger events',
5+
description: 'Disallow the use of shortcuts to input events via keyboard/mouse trigger events',
66
category: 'jQuery deprecated functions',
77
recommended: true,
88
url: 'https://api.jquery.com/bind/'

eslint/rules/jquery-no-misc-deprecated-functions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
meta: {
33
type: 'suggestion',
44
docs: {
5-
description: 'Disallow the use of shorthand event methods',
5+
description: 'Disallow the use of various deprecated methods methods',
66
category: 'jQuery deprecated functions',
77
recommended: true,
88
url: 'https://api.jquery.com/load/'
@@ -11,7 +11,7 @@ module.exports = {
1111
},
1212

1313
/**
14-
* Executes the function to check if shorthand methods are used.
14+
* Executes the function to check if deprecated methods methods are used
1515
*
1616
* @param {Object} context
1717
* @returns {Object}
@@ -23,7 +23,7 @@ module.exports = {
2323

2424
return {
2525
/**
26-
* Checks if shorthand methods are used and reports it.
26+
* Checks if deprecated methods are used and reports it.
2727
*
2828
* @param {Object} node - The node to check.
2929
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "eslint/.eslintrc",
66
"scripts": {
7-
"eslint": "./node_modules/.bin/eslint -c eslint/.eslintrc --rulesdir eslint/rules"
7+
"eslint": "./node_modules/.bin/eslint -c eslint/.eslintrc-jquery --rulesdir eslint/rules"
88
},
99
"author": "",
1010
"license": "ISC",

0 commit comments

Comments
 (0)