Skip to content

Commit 7f2cf64

Browse files
committed
fix: standardize payment method labels and configure ESLint
- Remove extra div wrapper from Bizum, PayPal, MBWay, Multibanco labels - All payment methods now use monei-label-container consistently - Configure ESLint to only ban console.log (allow console.warn/error) - Add proper parser options for ES6 modules and JSX
1 parent 435162b commit 7f2cf64

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
lines changed

.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
},
6+
parserOptions: {
7+
ecmaVersion: 2020,
8+
sourceType: 'module',
9+
ecmaFeatures: {
10+
jsx: true,
11+
},
12+
},
13+
rules: {
14+
// Critical rules - only ban console.log, allow warn/error
15+
'no-console': [ 'error', { allow: [ 'warn', 'error' ] } ],
16+
},
17+
};

assets/js/components/monei-apple-google-component.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import {
2-
getPlaceOrderButton,
3-
useButtonStateManager,
4-
} from '../helpers/monei-shared-utils';
1+
import { useButtonStateManager } from '../helpers/monei-shared-utils';
52

63
/**
74
* Create Apple/Google Pay label
85
* @param {Object} moneiData - Configuration data
9-
* @return {React.Element}
6+
* @return {*} JSX Element
107
*/
118
export const createAppleGoogleLabel = ( moneiData ) => {
129
const isApple = window.ApplePaySession?.canMakePayments?.();
@@ -36,15 +33,15 @@ export const createAppleGoogleLabel = ( moneiData ) => {
3633
/**
3734
* Shared Apple/Google Pay Content Component
3835
* @param {Object} props - Component props
39-
* @return {React.Element}
36+
* @return {*} JSX Element
4037
*/
4138
export const MoneiAppleGoogleContent = ( props ) => {
4239
const { useEffect, useRef } = wp.element;
43-
const { responseTypes } = props.emitResponse;
4440
const { onPaymentSetup } = props.eventRegistration;
4541
const { activePaymentMethod } = props;
4642
const moneiData =
4743
props.moneiData ||
44+
// eslint-disable-next-line no-undef
4845
wc.wcSettings.getSetting( 'monei_apple_google_data' );
4946

5047
const paymentRequestRef = useRef( null );
@@ -63,6 +60,7 @@ export const MoneiAppleGoogleContent = ( props ) => {
6360
* Initialize MONEI Payment Request
6461
*/
6562
const initPaymentRequest = () => {
63+
// eslint-disable-next-line no-undef
6664
if ( typeof monei === 'undefined' || ! monei.PaymentRequest ) {
6765
console.error( 'MONEI SDK is not available' );
6866
return;
@@ -77,6 +75,7 @@ export const MoneiAppleGoogleContent = ( props ) => {
7775
}
7876
}
7977

78+
// eslint-disable-next-line no-undef
8079
const paymentRequest = monei.PaymentRequest( {
8180
accountId: moneiData.accountId,
8281
sessionId: moneiData.sessionId,
@@ -116,6 +115,7 @@ export const MoneiAppleGoogleContent = ( props ) => {
116115
}
117116
}
118117
};
118+
// eslint-disable-next-line react-hooks/exhaustive-deps
119119
}, [] );
120120

121121
// Setup payment hook
@@ -125,7 +125,8 @@ export const MoneiAppleGoogleContent = ( props ) => {
125125
} );
126126

127127
return () => unsubscribe();
128-
}, [ onPaymentSetup, buttonManager.tokenRef.current ] );
128+
// eslint-disable-next-line react-hooks/exhaustive-deps
129+
}, [ onPaymentSetup ] );
129130

130131
return (
131132
<fieldset className="monei-fieldset monei-payment-request-fieldset">

assets/js/monei-block-checkout-bizum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312

313313
const MoneiBizumPaymentMethod = {
314314
name: 'monei_bizum',
315-
label: <div> { bizumLabel() } </div>,
315+
label: bizumLabel(),
316316
ariaLabel: __( bizumData.title, 'monei' ),
317317
content: <MoneiBizumContent />,
318318
edit: <div> { __( bizumData.title, 'monei' ) }</div>,

assets/js/monei-block-checkout-mbway.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
const MoneiMbwayPaymentMethod = {
2222
name: 'monei_mbway',
23-
label: <div> { mbwayLabel() } </div>,
23+
label: mbwayLabel(),
2424
ariaLabel: __( mbwayData.title, 'monei' ),
2525
content: <div> { __( mbwayData.description, 'monei' ) }</div>,
2626
edit: <div> { __( mbwayData.title, 'monei' ) }</div>,

assets/js/monei-block-checkout-multibanco.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
const MoneiMultibancoPaymentMethod = {
2222
name: 'monei_multibanco',
23-
label: <div> { multibancoLabel() } </div>,
23+
label: multibancoLabel(),
2424
ariaLabel: __( multibancoData.title, 'monei' ),
2525
content: <div> { __( multibancoData.description, 'monei' ) }</div>,
2626
edit: <div> { __( multibancoData.title, 'monei' ) }</div>,

assets/js/monei-block-checkout-paypal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189

190190
const MoneiPayPalPaymentMethod = {
191191
name: 'monei_paypal',
192-
label: <div> { paypalLabel() } </div>,
192+
label: paypalLabel(),
193193
ariaLabel: __( paypalData.title, 'monei' ),
194194
content: <MoneiPayPalContent />,
195195
edit: <div> { __( paypalData.title, 'monei' ) }</div>,

0 commit comments

Comments
 (0)