Skip to content

Fix #22747 - JavaScript modules contain unnecessary define checks #24833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
* See COPYING.txt for license details.
*/

(function (factory) {
if (typeof define === 'function' && define.amd) {
define([
'jquery',
'mage/backend/validation',
'prototype'
], factory);
} else {
factory(jQuery);
}
}(function (jQuery) {

define([
'jquery',
'mage/backend/validation',
'prototype'
], function (jQuery) {
window.directPost = Class.create();
directPost.prototype = {
initialize: function (methodCode, iframeId, controller, orderSaveUrl, cgiUrl, nativeAction) {
Expand Down Expand Up @@ -349,4 +342,4 @@
}
}
};
}));
});
16 changes: 5 additions & 11 deletions app/code/Magento/Backend/view/adminhtml/web/js/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
*/

/* eslint-disable strict */
(function (factory) {
if (typeof define === 'function' && define.amd) {
define([
'jquery',
'mage/mage'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'mage/mage'
], function ($) {
$.extend(true, $, {
mage: {
translate: (function () {
Expand Down Expand Up @@ -51,4 +45,4 @@
$.mage.__ = $.proxy($.mage.translate.translate, $.mage.translate);

return $.mage.__;
}));
});
18 changes: 5 additions & 13 deletions app/code/Magento/Catalog/view/frontend/web/js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
* See COPYING.txt for license details.
*/

(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery-ui-modules/widget'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'jquery-ui-modules/widget'
], function ($) {
'use strict';

$.widget('mage.gallery', {
Expand Down Expand Up @@ -49,4 +41,4 @@
});

return $.mage.gallery;
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@
* See COPYING.txt for license details.
*/

(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery-ui-modules/widget',
'mage/validation/validation'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'jquery-ui-modules/widget',
'mage/validation/validation'
], function ($) {
'use strict';

$.widget('mage.validation', $.mage.validation, {
Expand Down Expand Up @@ -97,4 +89,4 @@
});

return $.mage.validation;
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
*/

/* @api */
(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'Magento_Payment/js/model/credit-card-validation/cvv-validator',
'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator',
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator',
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator',
'Magento_Payment/js/model/credit-card-validation/credit-card-data',
'mage/translate'
], factory);
} else {
factory(jQuery);
}
}(function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
define([
'jquery',
'Magento_Payment/js/model/credit-card-validation/cvv-validator',
'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator',
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator',
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator',
'Magento_Payment/js/model/credit-card-validation/credit-card-data',
'mage/translate'
], function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
'use strict';

$('.payment-method-content input[type="number"]').on('keyup', function () {
Expand Down Expand Up @@ -111,4 +103,4 @@
rule.unshift(i);
$.validator.addMethod.apply($.validator, rule);
});
}));
});
18 changes: 5 additions & 13 deletions lib/web/mage/backend/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
* See COPYING.txt for license details.
*/

(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery/ui'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'jquery/ui'
], function ($) {
'use strict';

$.widget('ui.button', $.ui.button, {
Expand Down Expand Up @@ -58,4 +50,4 @@
});

return $.ui.button;
}));
});
18 changes: 5 additions & 13 deletions lib/web/mage/backend/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery/ui'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'jquery/ui'
], function ($) {
'use strict';

$.widget('mage.form', {
Expand Down Expand Up @@ -209,4 +201,4 @@
});

return $.mage.form;
}));
});
18 changes: 5 additions & 13 deletions lib/web/mage/backend/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
* See COPYING.txt for license details.
*/

(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery/ui'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'jquery/ui'
], function ($) {
'use strict';

$.widget('mage.menu', {
Expand Down Expand Up @@ -784,4 +776,4 @@
});

return $.mage.menu;
}));
});
26 changes: 9 additions & 17 deletions lib/web/mage/backend/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@
* See COPYING.txt for license details.
*/

(function (root, factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'mage/template',
'mage/mage',
'jquery/ui',
'mage/backend/menu',
'mage/translate'
], factory);
} else {
factory(root.jQuery, root.mageTemplate);
}
}(this, function ($, mageTemplate) {
define([
'jquery',
'mage/template',
'mage/mage',
'jquery/ui',
'mage/backend/menu',
'mage/translate'
], function ($, mageTemplate) {
'use strict';

/**
Expand Down Expand Up @@ -1196,4 +1188,4 @@
});

return $.mage.suggest;
}));
});
18 changes: 5 additions & 13 deletions lib/web/mage/backend/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@
*/

/* global FORM_KEY */
(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery/ui'
], factory);
} else {
factory(jQuery);
}
}(function ($) {
define([
'jquery',
'jquery/ui'
], function ($) {
'use strict';

var rhash, isLocal;
Expand Down Expand Up @@ -423,4 +415,4 @@
});

return $.mage.tabs;
}));
});
22 changes: 7 additions & 15 deletions lib/web/mage/backend/tree-suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
* See COPYING.txt for license details.
*/

(function (root, factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'jquery/ui',
'jquery/jstree/jquery.jstree',
'mage/backend/suggest'
], factory);
} else {
factory(root.jQuery);
}
}(this, function ($) {
define([
'jquery',
'jquery/ui',
'jquery/jstree/jquery.jstree',
'mage/backend/suggest'
], function ($) {
'use strict';

/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
Expand Down Expand Up @@ -274,4 +266,4 @@
});

return $.mage.treeSuggest;
}));
});
28 changes: 10 additions & 18 deletions lib/web/mage/backend/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
*/

/* global BASE_URL, alertAlreadyDisplayed */
(function (factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
define([
'jquery',
'underscore',
'Magento_Ui/js/modal/alert',
'jquery/ui',
'jquery/validate',
'mage/translate',
'mage/validation'
], factory);
} else {
factory(jQuery);
}
}(function ($, _, alert) {
define([
'jquery',
'underscore',
'Magento_Ui/js/modal/alert',
'jquery/ui',
'jquery/validate',
'mage/translate',
'mage/validation'
], function ($, _, alert) {
'use strict';

$.extend(true, $.validator.prototype, {
Expand Down Expand Up @@ -307,4 +299,4 @@
});

return $.mage.validation;
}));
});
Loading