Skip to content

Commit

Permalink
Merge pull request #117 from swlodarski-sumoheavy/10.1.x-eslint
Browse files Browse the repository at this point in the history
SP-1082: Magento 2 ESLint
  • Loading branch information
p-maguire authored Jan 17, 2025
2 parents e8b91fe + f2081dc commit 467af6c
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 349 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test

on: [push, pull_request]

env:
NODE_VERSION: 18

jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Run linter
run: |
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require magento/magento-coding-standard --dev
cd vendor/magento/magento-coding-standard
npm install
npm run eslint -- ../../../view
2 changes: 1 addition & 1 deletion view/adminhtml/layout/sales_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="Bitpay_BPCheckout::js/send_ipn_request.js"/>
<link src="Bitpay_BPCheckout::js/bootstrap/sales-order-view.js"/>
</head>
<body>
<referenceBlock name="order_tab_info">
Expand Down
3 changes: 3 additions & 0 deletions view/adminhtml/web/js/bootstrap/sales-order-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require([
'Bitpay_BPCheckout/js/send_ipn_request'
]);
31 changes: 17 additions & 14 deletions view/adminhtml/web/js/send_ipn_request.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
function sendIpnRequest(url, orderId) {
define([], function () {
'use strict';

jQuery.ajax({
url: url,
method: 'POST',
data: {
form_key: window.FORM_KEY,
order_id: orderId
},
dataType: 'json',
complete: function(response) {
window.location.reload();
},
});
}
window.sendIpnRequest = function (url, orderId) {
jQuery.ajax({
url: url,
method: 'POST',
data: {
form_key: window.FORM_KEY,
order_id: orderId
},
dataType: 'json',
complete: function () {
window.location.reload();
}
});
};
});
7 changes: 0 additions & 7 deletions view/frontend/layout/default.xml

This file was deleted.

2 changes: 1 addition & 1 deletion view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var config = {
map: {
'*': {
bitpay: 'https://bitpay.com/bitpay.min.js',
bitpay: 'https://bitpay.com/bitpay.min.js'
}
}
};
59 changes: 0 additions & 59 deletions view/frontend/web/js/bitpay/checkout/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions view/frontend/web/js/bitpay/config.js

This file was deleted.

22 changes: 16 additions & 6 deletions view/frontend/web/js/checkout.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
require(['mage/storage', 'Magento_Checkout/js/checkout-data', 'uiRegistry'], function (storage, checkoutData, registry) {
require([
'mage/storage',
'Magento_Checkout/js/checkout-data',
'uiRegistry'
],
function (storage, checkoutData, registry) {
'use strict';

storage.get('/bitpay-invoice/customer/data').done(function (data) {
var addressFormData = {};

if (!data) {
return;
}
var addressFormData = {
addressFormData = {
'firstname': data.billingAddress.firstname,
'lastname': data.billingAddress.lastname,
'street': {'0': data.billingAddress.street},
Expand All @@ -13,12 +22,13 @@ require(['mage/storage', 'Magento_Checkout/js/checkout-data', 'uiRegistry'], fun
'region_id': data.billingAddress.region_id
};

registry.async('checkoutProvider')(function (checkoutProvider) {
registry.async('checkoutProvider')(function () {
var shippingAddressData = checkoutData.getShippingAddressFromData();

if (!shippingAddressData && window.isCustomerLoggedIn === false) {
checkoutData.setShippingAddressFromData(addressFormData)
checkoutData.setShippingAddressFromData(addressFormData);
}
checkoutData.setInputFieldEmailValue(data.email)
})
checkoutData.setInputFieldEmailValue(data.email);
});
});
});
13 changes: 8 additions & 5 deletions view/frontend/web/js/checkout/cart.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require(['Magento_Customer/js/customer-data', 'mage/url'], function (customerData, url) {
var queryString = window.location.search;
var urlParams = new URLSearchParams(queryString);
var reload = urlParams.get('reload')
'use strict';

var queryString = window.location.search,
urlParams = new URLSearchParams(queryString),
reload = urlParams.get('reload');

if (reload) {
customerData.initStorage()
customerData.initStorage();
customerData.invalidate(['cart']);
window.history.pushState(null, null, url.build('checkout/cart'))
window.history.pushState(null, null, url.build('checkout/cart'));
}
});
8 changes: 5 additions & 3 deletions view/frontend/web/js/sales/guest/form.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require(['mage/storage'], function (storage) {
'use strict';

// autofill form guest form
setTimeout(function () {
storage.get('/bitpay-invoice/customer/data').done(function (data) {
if (!data) {
return;
}
document.getElementById("oar-order-id").value = data.incrementId;
document.getElementById("oar-billing-lastname").value = data.billingAddress.lastname;
document.getElementById("oar_email").value = data.email;
document.getElementById('oar-order-id').value = data.incrementId;
document.getElementById('oar-billing-lastname').value = data.billingAddress.lastname;
document.getElementById('oar_email').value = data.email;
});
},
1000);
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/view/payment/bpcheckout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* See COPYING.txt for license details.
*/
/*browser:true*/
/*global define*/
define(
[
'uiComponent',
Expand All @@ -18,6 +17,7 @@ define(
type: 'bpcheckout',
component: 'Bitpay_BPCheckout/js/view/payment/method-renderer/bpcheckout-method'
});

/** Add view logic here if needed */
return Component.extend({});
}
Expand Down
Loading

0 comments on commit 467af6c

Please sign in to comment.