From 2787b5ef35054830b2789a8cc8766987d92ad83a Mon Sep 17 00:00:00 2001
From: Dan Wallis <dan@wallis.nz>
Date: Wed, 20 Sep 2023 16:52:05 +0100
Subject: [PATCH 1/4] Update ESLint configuration

---
 eslint/.eslintrc-magento | 92 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 83 insertions(+), 9 deletions(-)

diff --git a/eslint/.eslintrc-magento b/eslint/.eslintrc-magento
index 69b47e83..6ed8a5bf 100644
--- a/eslint/.eslintrc-magento
+++ b/eslint/.eslintrc-magento
@@ -3,23 +3,32 @@
         "amd": true,
         "browser": true,
         "es6": true,
-        "es2017": true,
-        "es2020": true,
-        "es2021": true,
         "jasmine": true,
         "jquery": true,
         "prototypejs": true,
         "node": true
     },
     "rules": {
-        "comma-dangle": [2, "never"],
+        "array-bracket-spacing": [2, "never"],
+        "arrow-spacing": [2, {"after": true, "before": true}],
+        "block-spacing": [2, "always"],
+        "brace-style": [2, "1tbs", {"allowSingleLine": true}],
+        "comma-dangle": [ 2, "always-multiline" ],
+        "comma-spacing": [2, {"after": true, "before": false}],
         "comma-style": [2, "last"],
+        "constructor-super": 2,
         "curly": [2, "all"],
+        "dot-location": [2, "property"],
+        "dot-notation": [2, {"allowKeywords": true}],
         "eol-last": 2,
         "eqeqeq": [2, "smart"],
+        "func-call-spacing": [2, "never"],
+        "generator-star-spacing": [2, {"after": true, "before": true}],
         "guard-for-in": 2,
         "indent": [2, 4],
+        "key-spacing": [2, {"afterColon": true, "beforeColon": false}],
         "keyword-spacing": [2, {"after": true, "before": true}],
+        "linebreak-style": [2, "unix"],
         "lines-around-comment": [
             2,
             {
@@ -28,18 +37,35 @@
                 "allowObjectStart": true
             }
         ],
+        "lines-between-class-members": [2, "always", {"exceptAfterSingleLine": true}],
         "max-depth": [2, 2],
         "max-len": [2, 120, 4],
         "max-nested-callbacks": [2, 3],
+        "multiline-ternary": [2, "always-multiline"],
+        "new-cap": [2, {"capIsNew": false, "newIsCap": true, "properties": true}],
+        "new-parens": 2,
         "newline-after-var": 2,
         "no-alert": 2,
         "no-array-constructor": 2,
         "no-caller": 2,
+        "no-case-declarations": 2,
         "no-catch-shadow": 2,
+        "no-class-assign": 2,
+        "no-compare-neg-zero": 2,
         "no-cond-assign": 2,
+        "no-console": 2,
+        "no-const-assign": 2,
         "no-constant-condition": 2,
+        "no-control-regex": 2,
         "no-debugger": 2,
+        "no-delete-var": 2,
+        "no-dupe-args": 2,
+        "no-dupe-class-members": 2,
+        "no-dupe-keys": 2,
+        "no-duplicate-case": 2,
         "no-else-return": 2,
+        "no-empty-character-class": 2,
+        "no-empty-pattern": 2,
         "no-empty": [2, {"allowEmptyCatch": true}],
         "no-eval": 2,
         "no-ex-assign": 2,
@@ -55,25 +81,53 @@
         "no-implied-eval": 2,
         "no-inner-declarations": 2,
         "no-invalid-regexp": 2,
+        "no-irregular-whitespace": 2,
+        "no-iterator": 2,
+        "no-labels": [2, {"allowLoop": false, "allowSwitch": false}],
         "no-lone-blocks": 2,
         "no-lonely-if": 2,
         "no-loop-func": 2,
+        "no-mixed-operators": [2, {"allowSamePrecedence": true, "groups": [["==", "!=", "===", "!==", ">", ">=", "<", "<="], ["&&", "||"], ["in", "instanceof"]]}],
         "no-mixed-spaces-and-tabs": 2,
+        "no-multi-spaces": 2,
         "no-multi-str": 2,
-        "no-multiple-empty-lines": 2,
+        "no-multiple-empty-lines": [2, {"max": 1, "maxEOF": 0}],
         "no-native-reassign": 2,
         "no-negated-in-lhs": 2,
+        "no-new-func": 2,
         "no-new-object": 2,
+        "no-new-symbol": 2,
+        "no-new-wrappers": 2,
+        "no-new": 2,
+        "no-obj-calls": 2,
+        "no-octal-escape": 2,
+        "no-octal": 2,
         "no-proto": 2,
+        "no-prototype-builtins": 2,
         "no-redeclare": 2,
         "no-regex-spaces": 2,
         "no-return-assign": 2,
+        "no-self-assign": [2, {"props": true}],
         "no-self-compare": 2,
+        "no-sequences": 2,
         "no-shadow": 2,
+        "no-shadow-restricted-names": 2,
+        "no-sparse-arrays": 2,
+        "no-tabs": 2,
+        "no-template-curly-in-string": 2,
+        "no-this-before-super": 2,
+        "no-throw-literal": 2,
         "no-trailing-spaces": 2,
         "no-undef": 2,
         "no-undef-init": 2,
+        "no-unexpected-multiline": 2,
+        "no-unmodified-loop-condition": 2,
+        "no-unneeded-ternary": [2, {"defaultAssignment": false}],
         "no-unreachable": 2,
+        "no-unsafe-finally": 2,
+        "no-unsafe-negation": 2,
+        "no-unused-expressions": [2, {"allowShortCircuit": true, "allowTaggedTemplates": true, "allowTernary": true}],
+        "no-unused-labels": 2,
         "no-unused-vars": [
             2,
             {
@@ -89,22 +143,42 @@
         "no-useless-escape": 2,
         "no-useless-rename": 2,
         "no-useless-return": 2,
+        "no-var": 2,
+        "no-void": 2,
+        "no-whitespace-before-property": 2,
         "no-with": 2,
-        "one-var": [2, "always"],
+        "object-curly-newline": [2, {"consistent": true, "multiline": true}],
+        "object-curly-spacing": [2, "always"],
+        "object-property-newline": [2, {"allowMultiplePropertiesPerLine": true}],
+        "one-var": [2, {"initialized": "never"}],
         "operator-assignment": [2, "always"],
-        "quotes": [2, "single", {"allowTemplateLiterals": true}],
+        "operator-linebreak": [2, "after", {"overrides": {":": "before", "?": "before", "|>": "before"}}],
+        "padded-blocks": [2, {"blocks": "never", "classes": "never", "switches": "never"}],
+        "prefer-const": [2, {"destructuring": "all"}],
+        "prefer-promise-reject-errors": 2,
+        "quote-props": [2, "as-needed"],
+        "quotes": [2, "single", {"allowTemplateLiterals": true, "avoidEscape": true}],
         "radix": 2,
+        "require-yield": 2,
+        "rest-spread-spacing": [2, "never"],
         "semi": [2, "always"],
         "semi-spacing": 2,
         "space-before-blocks": [2, "always"],
-        "space-before-function-paren": [2, {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
+        "space-before-function-paren": [2, "always"],
         "space-in-parens": [2, "never"],
         "space-infix-ops": 2,
-        "space-unary-ops": [2, {"words": false, "nonwords": false}],
+        "space-unary-ops": [2, {"nonwords": false, "words": true}],
+        "spaced-comment": [2, "always", {"block": {"balanced": true, "exceptions": ["*"], "markers": ["*package", "!", ",", ":", "::", "flow-include"]}, "line": {"markers": ["*package", "!", "/", ",", "="]}}],
         "strict": ["error", "function"],
+        "symbol-description": 2,
+        "template-curly-spacing": [2, "never"],
+        "template-tag-spacing": [2, "never"],
+        "unicode-bom": [2, "never"],
         "use-isnan": 2,
         "valid-typeof": 2,
         "vars-on-top": 2,
+        "wrap-iife": [2, "any", {"functionPrototypeMethods": true}],
+        "yield-star-spacing": [2, "both"],
         "yoda": [2, "never"]
     }
 }

From 662113b97425a3a95548cb56ba1c28419feed226 Mon Sep 17 00:00:00 2001
From: Dan Wallis <dan@wallis.nz>
Date: Wed, 20 Sep 2023 16:52:07 +0100
Subject: [PATCH 2/4] Update existing files to match new coding standard

---
 eslint/rules/jquery-no-andSelf.js             | 18 +++----
 eslint/rules/jquery-no-bind-unbind.js         | 18 +++----
 eslint/rules/jquery-no-delegate-undelegate.js | 18 +++----
 eslint/rules/jquery-no-deprecated-expr.js     | 14 +++---
 eslint/rules/jquery-no-event-shorthand.js     | 32 ++++++-------
 .../rules/jquery-no-input-event-shorthand.js  | 25 +++++-----
 .../jquery-no-misc-deprecated-functions.js    | 48 +++++++++----------
 eslint/rules/jquery-no-size.js                | 18 +++----
 eslint/rules/jquery-no-trim.js                | 18 +++----
 eslint/rules/utils.js                         | 45 +++++++++--------
 10 files changed, 130 insertions(+), 124 deletions(-)

diff --git a/eslint/rules/jquery-no-andSelf.js b/eslint/rules/jquery-no-andSelf.js
index ad08cbb1..16684112 100644
--- a/eslint/rules/jquery-no-andSelf.js
+++ b/eslint/rules/jquery-no-andSelf.js
@@ -5,12 +5,12 @@ module.exports = {
             description: 'Disallow the use of the deprecated `andSelf` method',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/andself/'
+            url: 'https://api.jquery.com/andself/',
         },
         schema: [],
         messages: {
-            andSelf: 'jQuery.andSelf() removed, use jQuery.addBack()'
-        }
+            andSelf: 'jQuery.andSelf() removed, use jQuery.addBack()',
+        },
     },
 
     /**
@@ -22,7 +22,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -31,17 +31,17 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                if (node.callee.property.name !== 'andSelf') {return;}
+                if (node.callee.property.name !== 'andSelf') { return; }
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        messageId: 'andSelf'
+                        messageId: 'andSelf',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-bind-unbind.js b/eslint/rules/jquery-no-bind-unbind.js
index 58b4e92c..258f4322 100644
--- a/eslint/rules/jquery-no-bind-unbind.js
+++ b/eslint/rules/jquery-no-bind-unbind.js
@@ -5,12 +5,12 @@ module.exports = {
             description: 'Disallow the use of the deprecated $.bind and $.unbind',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/bind/'
+            url: 'https://api.jquery.com/bind/',
         },
         schema: [],
         messages: {
-            bind: 'jQuery $.bind and $.unbind are deprecated, use $.on and $.off instead'
-        }
+            bind: 'jQuery $.bind and $.unbind are deprecated, use $.on and $.off instead',
+        },
     },
 
     /**
@@ -22,7 +22,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -31,17 +31,17 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                if (!['bind', 'unbind'].includes(node.callee.property.name)) {return;}
+                if (!['bind', 'unbind'].includes(node.callee.property.name)) { return; }
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        messageId: 'bind'
+                        messageId: 'bind',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-delegate-undelegate.js b/eslint/rules/jquery-no-delegate-undelegate.js
index fd96c9f2..536a3f71 100644
--- a/eslint/rules/jquery-no-delegate-undelegate.js
+++ b/eslint/rules/jquery-no-delegate-undelegate.js
@@ -5,12 +5,12 @@ module.exports = {
             description: 'Disallow the use of the deprecated $.delegate and $.undelegate',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/delegate/'
+            url: 'https://api.jquery.com/delegate/',
         },
         schema: [],
         messages: {
-            delegate: 'jQuery $.delegate and $.undelegate are deprecated, use $.on and $.off instead'
-        }
+            delegate: 'jQuery $.delegate and $.undelegate are deprecated, use $.on and $.off instead',
+        },
     },
 
     /**
@@ -22,7 +22,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -31,17 +31,17 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                if (!['delegate', 'undelegate'].includes(node.callee.property.name)) {return;}
+                if (!['delegate', 'undelegate'].includes(node.callee.property.name)) { return; }
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        messageId: 'delegate'
+                        messageId: 'delegate',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-deprecated-expr.js b/eslint/rules/jquery-no-deprecated-expr.js
index 2a9e2377..0cb7cc3e 100644
--- a/eslint/rules/jquery-no-deprecated-expr.js
+++ b/eslint/rules/jquery-no-deprecated-expr.js
@@ -5,9 +5,9 @@ module.exports = {
             description: 'Disallow the use of deprecated way to add to custom selectors',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/load/'
+            url: 'https://api.jquery.com/load/',
         },
-        schema: []
+        schema: [],
     },
 
     /**
@@ -19,7 +19,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -31,7 +31,7 @@ module.exports = {
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        message: 'jQuery.expr[":"] is deprecated; Use jQuery.expr.pseudos instead'
+                        message: 'jQuery.expr[":"] is deprecated; Use jQuery.expr.pseudos instead',
                     });
                 }
             },
@@ -45,10 +45,10 @@ module.exports = {
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        message: 'jQuery.expr.filters is deprecated; Use jQuery.expr.pseudos instead'
+                        message: 'jQuery.expr.filters is deprecated; Use jQuery.expr.pseudos instead',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-event-shorthand.js b/eslint/rules/jquery-no-event-shorthand.js
index 28e66353..330444ac 100644
--- a/eslint/rules/jquery-no-event-shorthand.js
+++ b/eslint/rules/jquery-no-event-shorthand.js
@@ -5,9 +5,9 @@ module.exports = {
             description: 'Disallow the use of shorthand event methods',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/load/'
+            url: 'https://api.jquery.com/load/',
         },
-        schema: []
+        schema: [],
     },
 
     /**
@@ -19,7 +19,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -28,26 +28,26 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                var namesToMsg = {
-                        'unload': 'jQuery.unload() was removed, use .on("unload", fn) instead.',
-                        'ready': 'jQuery.ready(handler) is deprecated and should be replaced with jQuery(handler)'
-                    },
-                    name,
-                    message;
+                const namesToMsg = {
+                    unload: 'jQuery.unload() was removed, use .on("unload", fn) instead.',
+                    ready: 'jQuery.ready(handler) is deprecated and should be replaced with jQuery(handler)',
+                };
 
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                name = node.callee.property.name;
-                if (!namesToMsg.hasOwnProperty(name)) {return;}
-                message = namesToMsg[name];
+                const name = node.callee.property.name;
+
+                if (!Object.prototype.hasOwnProperty.call(namesToMsg, name)) { return; }
+
+                const message = namesToMsg[name];
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        message: message
+                        message: message,
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-input-event-shorthand.js b/eslint/rules/jquery-no-input-event-shorthand.js
index 6983fa5e..c387a8ef 100644
--- a/eslint/rules/jquery-no-input-event-shorthand.js
+++ b/eslint/rules/jquery-no-input-event-shorthand.js
@@ -5,9 +5,9 @@ module.exports = {
             description: 'Disallow the use of shortcuts to input events via keyboard/mouse trigger events',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/bind/'
+            url: 'https://api.jquery.com/bind/',
         },
-        schema: []
+        schema: [],
     },
 
     /**
@@ -19,7 +19,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -28,25 +28,24 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                var names, name;
-
-                names = ['blur', 'focus', 'focusin', 'focusout', 'resize', 'scroll', 'dblclick', 'mousedown',
-                    'mouseup', 'mousemove','mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'change', 'select',
+                const names = ['blur', 'focus', 'focusin', 'focusout', 'resize', 'scroll', 'dblclick', 'mousedown',
+                    'mouseup', 'mousemove', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'change', 'select',
                     'submit', 'keydown', 'keypress', 'keyup', 'contextmenu', 'click'];
 
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                if (!names.includes(node.callee.property.name)) {return;}
+                if (!names.includes(node.callee.property.name)) { return; }
 
                 if (utils.isjQuery(node)) {
-                    name = node.callee.property.name;
+                    const name = node.callee.property.name;
+
                     context.report({
                         node: node,
                         message: 'Instead of .' + name + '(fn) use .on("' + name + '", fn). Instead of .' + name +
-                            '() use .trigger("' + name + '")'
+                            '() use .trigger("' + name + '")',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-misc-deprecated-functions.js b/eslint/rules/jquery-no-misc-deprecated-functions.js
index b4b7b52e..ce759a59 100644
--- a/eslint/rules/jquery-no-misc-deprecated-functions.js
+++ b/eslint/rules/jquery-no-misc-deprecated-functions.js
@@ -5,9 +5,9 @@ module.exports = {
             description: 'Disallow the use of various deprecated methods methods',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/load/'
+            url: 'https://api.jquery.com/load/',
         },
-        schema: []
+        schema: [],
     },
 
     /**
@@ -19,7 +19,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -28,32 +28,32 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                var namesToMsg = {
-                        'isFunction': 'jQuery.isFunction() is deprecated. '
-                            + 'In most cases, it can be replaced by [typeof x === "function"]',
-                        'type': 'jQuery.type() is deprecated. ' +
-                            'Replace with an appropriate type check like [typeof x === "function"]',
-                        'isArray': 'jQuery.isArray() is deprecated. ' +
-                            'Use the native Array.isArray method instead',
-                        'parseJSON' : 'jQuery.parseJSON() is deprecated. ' +
-                            'To parse JSON strings, use the native JSON.parse method instead'
-                    },
-                    name,
-                    message;
-
-                if (node.callee.type !== 'MemberExpression') {return;}
-
-                name = node.callee.property.name;
-                if (!namesToMsg.hasOwnProperty(name)) {return;}
-                message = namesToMsg[name];
+                const namesToMsg = {
+                    isFunction: 'jQuery.isFunction() is deprecated. ' +
+                        'In most cases, it can be replaced by [typeof x === "function"]',
+                    type: 'jQuery.type() is deprecated. ' +
+                        'Replace with an appropriate type check like [typeof x === "function"]',
+                    isArray: 'jQuery.isArray() is deprecated. ' +
+                        'Use the native Array.isArray method instead',
+                    parseJSON: 'jQuery.parseJSON() is deprecated. ' +
+                        'To parse JSON strings, use the native JSON.parse method instead',
+                };
+
+                if (node.callee.type !== 'MemberExpression') { return; }
+
+                const name = node.callee.property.name;
+
+                if (!Object.prototype.hasOwnProperty.call(namesToMsg, name)) { return; }
+
+                const message = namesToMsg[name];
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        message: message
+                        message: message,
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-size.js b/eslint/rules/jquery-no-size.js
index dc8b6477..247c07d2 100644
--- a/eslint/rules/jquery-no-size.js
+++ b/eslint/rules/jquery-no-size.js
@@ -5,12 +5,12 @@ module.exports = {
             description: 'Disallow the use of the deprecated `size` method',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/size/'
+            url: 'https://api.jquery.com/size/',
         },
         schema: [],
         messages: {
-            size: 'jQuery.size() removed, use jQuery.length'
-        }
+            size: 'jQuery.size() removed, use jQuery.length',
+        },
     },
 
     /**
@@ -22,7 +22,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -31,17 +31,17 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                if (node.callee.property.name !== 'size') {return;}
+                if (node.callee.property.name !== 'size') { return; }
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        messageId: 'size'
+                        messageId: 'size',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/jquery-no-trim.js b/eslint/rules/jquery-no-trim.js
index cd122294..299eeaf4 100644
--- a/eslint/rules/jquery-no-trim.js
+++ b/eslint/rules/jquery-no-trim.js
@@ -5,12 +5,12 @@ module.exports = {
             description: 'Disallow the use of the deprecated `trim` function',
             category: 'jQuery deprecated functions',
             recommended: true,
-            url: 'https://api.jquery.com/jQuery.trim/'
+            url: 'https://api.jquery.com/jQuery.trim/',
         },
         schema: [],
         messages: {
-            trim: 'jQuery.trim is deprecated; use String.prototype.trim'
-        }
+            trim: 'jQuery.trim is deprecated; use String.prototype.trim',
+        },
     },
 
     /**
@@ -22,7 +22,7 @@ module.exports = {
     create: function (context) {
         'use strict';
 
-        var utils = require('./utils.js');
+        const utils = require('./utils.js');
 
         return {
             /**
@@ -31,17 +31,17 @@ module.exports = {
              * @param {Object} node - The node to check.
              */
             CallExpression: function (node) {
-                if (node.callee.type !== 'MemberExpression') {return;}
+                if (node.callee.type !== 'MemberExpression') { return; }
 
-                if (node.callee.property.name !== 'trim') {return;}
+                if (node.callee.property.name !== 'trim') { return; }
 
                 if (utils.isjQuery(node)) {
                     context.report({
                         node: node,
-                        messageId: 'trim'
+                        messageId: 'trim',
                     });
                 }
-            }
+            },
         };
-    }
+    },
 };
diff --git a/eslint/rules/utils.js b/eslint/rules/utils.js
index 398e2b86..47e0380a 100644
--- a/eslint/rules/utils.js
+++ b/eslint/rules/utils.js
@@ -3,11 +3,10 @@
  * @param node
  * @returns object
  */
-function define(node) {
+function define (node) {
     'use strict';
-    var defineStmt, args;
 
-    defineStmt = node.body.find(function (stmt) {
+    const defineStmt = node.body.find(function (stmt) {
         return (
             stmt.type === 'ExpressionStatement' &&
             stmt.expression.type === 'CallExpression' &&
@@ -17,16 +16,22 @@ function define(node) {
             stmt.expression.arguments[0].type === 'ArrayExpression'
         );
     });
+
     if (!defineStmt) {
         return;
     }
 
-    args = defineStmt.expression.arguments;
+    const args = defineStmt.expression.arguments;
+    let moduleNames = [];
+
+    if (args.length > 1) {
+        moduleNames = args[1].params;
+    }
 
     return {
         func: defineStmt.expression,
         modulePaths: args[0].elements,
-        moduleNames: args.length > 1 && args[1].params || []
+        moduleNames: moduleNames,
     };
 }
 
@@ -35,28 +40,28 @@ function define(node) {
  * @param defineObject
  * @returns {null|*}
  */
-function getJqueryName(defineObject) {
+function getJqueryName (defineObject) {
     'use strict';
 
-    var jQueryPathIndex;
-
     if (!defineObject.modulePaths || !defineObject.moduleNames) {
         return null;
     }
-    jQueryPathIndex = defineObject.modulePaths.findIndex(function (paths) {
+
+    const jQueryPathIndex = defineObject.modulePaths.findIndex(function (paths) {
         return paths.value.toLowerCase() === 'jquery';
     });
+
     if (jQueryPathIndex === -1 || jQueryPathIndex >= defineObject.moduleNames.length) {
         return null;
     }
-    return defineObject.moduleNames[jQueryPathIndex];
 
+    return defineObject.moduleNames[jQueryPathIndex];
 }
 
 /**
  * Get Root Program node
  */
-function getProgramNode(node) {
+function getProgramNode (node) {
     'use strict';
     if (!node.parent) {
         return node;
@@ -70,7 +75,7 @@ function getProgramNode(node) {
  * @param {Object} node - The node to check
  * @returns {Object|Null}
  */
-function getExpressionId(node) {
+function getExpressionId (node) {
     'use strict';
 
     while (node) {
@@ -85,6 +90,7 @@ function getExpressionId(node) {
 
         case 'Identifier':
             return node;
+
         default:
             return null;
         }
@@ -101,22 +107,23 @@ function getExpressionId(node) {
  * @returns {Boolean} - true if the function call node is attached to a jQuery element set. false, otherwise.
  */
 
-function isjQuery(node) {
+function isjQuery (node) {
     'use strict';
-    var parentNode, defineNode, jQueryId, id;
 
-    parentNode = getProgramNode(node);
-    defineNode = define(parentNode);
+    const parentNode = getProgramNode(node);
+    const defineNode = define(parentNode);
+
     if (!defineNode) {
         return false;
     }
-    jQueryId = getJqueryName(defineNode);
-    id = getExpressionId(node);
+
+    const jQueryId = getJqueryName(defineNode);
+    const id = getExpressionId(node);
 
     return id && jQueryId && id.name === jQueryId.name;
 }
 
 module.exports = {
     traverse: getExpressionId,
-    isjQuery: isjQuery
+    isjQuery: isjQuery,
 };

From 8c6374acd29d5d5acac9277156c5d9a9c0a4cc2a Mon Sep 17 00:00:00 2001
From: Dan Wallis <dan@wallis.nz>
Date: Wed, 20 Sep 2023 16:52:10 +0100
Subject: [PATCH 3/4] Also allow more modern syntax & objects

---
 eslint/.eslintrc-magento | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/eslint/.eslintrc-magento b/eslint/.eslintrc-magento
index 6ed8a5bf..858b44bc 100644
--- a/eslint/.eslintrc-magento
+++ b/eslint/.eslintrc-magento
@@ -3,6 +3,9 @@
         "amd": true,
         "browser": true,
         "es6": true,
+        "es2017": true,
+        "es2020": true,
+        "es2021": true,
         "jasmine": true,
         "jquery": true,
         "prototypejs": true,

From a1766bfe57ff808870f18e8ca10ae84bba46f140 Mon Sep 17 00:00:00 2001
From: Dan Wallis <dan@wallis.nz>
Date: Wed, 20 Sep 2023 16:52:12 +0100
Subject: [PATCH 4/4] Avoid conflict: mixed-operators / extra-parens

The documentation for 'no-mixed-operators' states:
> This rule may conflict with no-extra-parens rule. If you use both this and
> no-extra-parens rule together, you need to use the nestedBinaryExpressions
> option of no-extra-parens rule.
---
 eslint/.eslintrc-magento | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eslint/.eslintrc-magento b/eslint/.eslintrc-magento
index 858b44bc..9ab8470f 100644
--- a/eslint/.eslintrc-magento
+++ b/eslint/.eslintrc-magento
@@ -75,7 +75,7 @@
         "no-extend-native": 2,
         "no-extra-bind": 2,
         "no-extra-boolean-cast": 2,
-        "no-extra-parens": 2,
+        "no-extra-parens": [2, "all", { "nestedBinaryExpressions": false }],
         "no-extra-semi": 2,
         "no-fallthrough": 2,
         "no-floating-decimal": 2,