Skip to content

Commit c8e0ee9

Browse files
committed
AC-13683::Investigate latest patch version of grunt-eslint
1 parent d7ece6d commit c8e0ee9

14 files changed

+105
-33
lines changed

eslint/eslint.config.mjs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { defineConfig } from "eslint/config";
2+
import magentoCodingStandardEslintPlugin from "magento-coding-standard-eslint-plugin";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import js from "@eslint/js";
6+
import { FlatCompat } from "@eslint/eslintrc";
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all
14+
});
15+
export default defineConfig([{
16+
plugins: {
17+
"magento-coding-standard-eslint-plugin": magentoCodingStandardEslintPlugin, // This is in flat config format (object)
18+
},
19+
rules: {
20+
"magento-coding-standard-eslint-plugin/jquery-no-andSelf": "warn",
21+
"magento-coding-standard-eslint-plugin/jquery-no-bind-unbind": "warn",
22+
"magento-coding-standard-eslint-plugin/jquery-no-delegate-undelegate": "warn",
23+
"magento-coding-standard-eslint-plugin/jquery-no-deprecated-expr": "warn",
24+
"magento-coding-standard-eslint-plugin/jquery-no-event-shorthand": "warn",
25+
"magento-coding-standard-eslint-plugin/jquery-no-input-event-shorthand": "warn",
26+
"magento-coding-standard-eslint-plugin/jquery-no-misc-deprecated-functions": "warn",
27+
"magento-coding-standard-eslint-plugin/jquery-no-size": "warn",
28+
"magento-coding-standard-eslint-plugin/jquery-no-trim": "warn",
29+
},
30+
}]);

eslint/index.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Import individual rule files as modules
2+
import jqueryNoAndSelf from './rules/jquery-no-andSelf.js';
3+
import jqueryNoBindUnbind from './rules/jquery-no-bind-unbind.js';
4+
import jqueryNoDelegateUndelegate from './rules/jquery-no-delegate-undelegate.js';
5+
import jqueryNoDeprecatedExpr from './rules/jquery-no-deprecated-expr.js';
6+
import jqueryNoEventShorthand from './rules/jquery-no-event-shorthand.js';
7+
import jqueryNoInputEventShorthand from './rules/jquery-no-input-event-shorthand.js';
8+
import jqueryNoMiscDeprecatedFunctions from './rules/jquery-no-misc-deprecated-functions.js';
9+
import jqueryNoSize from './rules/jquery-no-size.js';
10+
import jqueryNoTrim from './rules/jquery-no-trim.js';
11+
12+
export default {
13+
rules: {
14+
'jquery-no-andSelf': jqueryNoAndSelf,
15+
'jquery-no-bind-unbind': jqueryNoBindUnbind,
16+
'jquery-no-delegate-undelegate': jqueryNoDelegateUndelegate,
17+
'jquery-no-deprecated-expr': jqueryNoDeprecatedExpr,
18+
'jquery-no-event-shorthand': jqueryNoEventShorthand,
19+
'jquery-no-input-event-shorthand': jqueryNoInputEventShorthand,
20+
'jquery-no-misc-deprecated-functions': jqueryNoMiscDeprecatedFunctions,
21+
'jquery-no-size': jqueryNoSize,
22+
'jquery-no-trim': jqueryNoTrim
23+
}
24+
};

eslint/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "magento-coding-standard-eslint-plugin",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"resolutions": {
6+
"eslint": "~9.22.0"
7+
},
8+
"eslintConfig": {
9+
"plugins": ["magento-coding-standard-eslint-plugin"]
10+
},
11+
"type": "module"
12+
}

eslint/rules/jquery-no-andSelf.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -22,8 +25,6 @@ module.exports = {
2225
create: function (context) {
2326
'use strict';
2427

25-
var utils = require('./utils.js');
26-
2728
return {
2829
/**
2930
* Checks if andSelf is used in the node and reports it.

eslint/rules/jquery-no-bind-unbind.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -22,8 +25,6 @@ module.exports = {
2225
create: function (context) {
2326
'use strict';
2427

25-
var utils = require('./utils.js');
26-
2728
return {
2829
/**
2930
* Checks if bind and unbind are used in the node and reports it.

eslint/rules/jquery-no-delegate-undelegate.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -22,8 +25,6 @@ module.exports = {
2225
create: function (context) {
2326
'use strict';
2427

25-
var utils = require('./utils.js');
26-
2728
return {
2829
/**
2930
* Checks if delegate and undelegate are used in the node and reports it.

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -19,8 +22,6 @@ module.exports = {
1922
create: function (context) {
2023
'use strict';
2124

22-
var utils = require('./utils.js');
23-
2425
return {
2526
/**
2627
* Checks for jQuery.expr[':']

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -19,8 +22,6 @@ module.exports = {
1922
create: function (context) {
2023
'use strict';
2124

22-
var utils = require('./utils.js');
23-
2425
return {
2526
/**
2627
* Checks if shorthand event methods are used.

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -19,8 +22,6 @@ module.exports = {
1922
create: function (context) {
2023
'use strict';
2124

22-
var utils = require('./utils.js');
23-
2425
return {
2526
/**
2627
* Checks if shortcuts are used to trigger events and reports it.

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -19,8 +22,6 @@ module.exports = {
1922
create: function (context) {
2023
'use strict';
2124

22-
var utils = require('./utils.js');
23-
2425
return {
2526
/**
2627
* Checks if deprecated methods are used and reports it.

eslint/rules/jquery-no-size.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -22,8 +25,6 @@ module.exports = {
2225
create: function (context) {
2326
'use strict';
2427

25-
var utils = require('./utils.js');
26-
2728
return {
2829
/**
2930
* Checks if size method is used and reports it.

eslint/rules/jquery-no-trim.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module.exports = {
1+
// Import utils using ES module syntax
2+
import utils from './utils.js';
3+
4+
export default {
25
meta: {
36
type: 'suggestion',
47
docs: {
@@ -22,8 +25,6 @@ module.exports = {
2225
create: function (context) {
2326
'use strict';
2427

25-
var utils = require('./utils.js');
26-
2728
return {
2829
/**
2930
* Checks if trim method is used and reports it.

eslint/rules/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function isjQuery(node) {
116116
return id && jQueryId && id.name === jQueryId.name;
117117
}
118118

119-
module.exports = {
119+
export default {
120120
traverse: getExpressionId,
121121
isjQuery: isjQuery
122122
};

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
"name": "js",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "eslint/.eslintrc",
6-
"scripts": {
7-
"eslint": "./node_modules/.bin/eslint -c eslint/.eslintrc --rulesdir eslint/rules"
8-
},
5+
"main": "eslint/eslint.config.mjs",
96
"author": "",
107
"license": "ISC",
118
"devDependencies": {
12-
"eslint": "^8.8.0"
9+
"eslint": "~9.22.0"
1310
}
1411
}

0 commit comments

Comments
 (0)