Skip to content

Commit 1ba4b15

Browse files
authored
Node 20 upgrade lint fixes (#4606)
* Node 20 upgrade lint fixes * Prettier RC * Revert some of the lint fixes * Changelog and readme entries * Import resolver package update * Revert unnecessary changes
1 parent 1300e12 commit 1ba4b15

File tree

104 files changed

+1177
-1057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1177
-1057
lines changed

.prettierrc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
// Import the default config file and expose it in the project root.
22
// Useful for editor integrations.
3-
module.exports = require( '@wordpress/prettier-config' );
3+
module.exports = {
4+
...require( '@wordpress/prettier-config' ),
5+
overrides: [
6+
{
7+
files: [ 'changelog.txt' ],
8+
options: { parser: 'markdown' },
9+
},
10+
],
11+
};

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.9.0 - xxxx-xx-xx =
4+
* Dev - Multiple lint fixes in preparation for the Node 20 upgrade
45
* Dev - Introduces a new helper method to identify Stripe orders
56
* Add - Setting to allow merchants to control the layout of the Optimized Checkout payment element on the checkout page
67
* Fix - Removes the credit card payment method requirement for the Optimized Checkout feature

client/api/blocks.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
99
* Construct WC AJAX endpoint URL.
1010
*
1111
* @param {string} endpoint Request endpoint URL.
12-
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
12+
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
1313
* @return {string} URL with interpolated endpoint.
1414
*/
1515
const getAjaxUrl = ( endpoint, prefix = 'wc_stripe_' ) => {
@@ -33,7 +33,7 @@ export const getCartDetails = () => {
3333
/**
3434
* Update shipping options.
3535
*
36-
* @param {Object} address Customer address.
36+
* @param {Object} address Customer address.
3737
* @param {string} paymentRequestType Either 'apple_pay' or 'payment_request_api' depending on the type of request.
3838
*/
3939
export const updateShippingOptions = ( address, paymentRequestType ) => {
@@ -65,18 +65,6 @@ export const updateShippingDetails = ( shippingOption ) => {
6565
} );
6666
};
6767

68-
export const createOrder = ( sourceEvent, paymentRequestType ) => {
69-
let data = normalizeOrderData( sourceEvent, paymentRequestType );
70-
data = getRequiredFieldDataFromCheckoutForm( data );
71-
72-
return $.ajax( {
73-
type: 'POST',
74-
data,
75-
dataType: 'json',
76-
url: getAjaxUrl( 'create_order' ),
77-
} );
78-
};
79-
8068
const getRequiredFieldDataFromCheckoutForm = ( data ) => {
8169
const checkoutForm = document.querySelector( '.wc-block-checkout' );
8270
// Return if cart page.
@@ -109,3 +97,15 @@ const getRequiredFieldDataFromCheckoutForm = ( data ) => {
10997

11098
return data;
11199
};
100+
101+
export const createOrder = ( sourceEvent, paymentRequestType ) => {
102+
let data = normalizeOrderData( sourceEvent, paymentRequestType );
103+
data = getRequiredFieldDataFromCheckoutForm( data );
104+
105+
return $.ajax( {
106+
type: 'POST',
107+
data,
108+
dataType: 'json',
109+
url: getAjaxUrl( 'create_order' ),
110+
} );
111+
};

client/api/index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class WCStripeAPI {
3333
* Construct WC AJAX endpoint URL.
3434
*
3535
* @param {string} endpoint Request endpoint URL.
36-
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
36+
* @param {string} prefix Endpoint URI prefix (default: 'wc_stripe_').
3737
* @return {string} URL with interpolated endpoint.
3838
*/
3939
getAjaxUrl( endpoint, prefix = 'wc_stripe_' ) {
@@ -140,7 +140,7 @@ export default class WCStripeAPI {
140140
/**
141141
* Creates an intent based on a payment method.
142142
*
143-
* @param {number|null} orderId The id of the order if creating the intent on Order Pay page.
143+
* @param {number|null} orderId The id of the order if creating the intent on Order Pay page.
144144
* @param {string|null} paymentMethodType The type of payment method.
145145
*
146146
* @return {Promise} The final promise for the request to the server.
@@ -172,7 +172,7 @@ export default class WCStripeAPI {
172172
/**
173173
* Creates and confirms a setup intent.
174174
*
175-
* @param {Object} paymentMethod Payment method data.
175+
* @param {Object} paymentMethod Payment method data.
176176
* @param {Object} additionalData Additional data to send with the request.
177177
*
178178
* @return {Promise} Promise containing the setup intent.
@@ -251,12 +251,12 @@ export default class WCStripeAPI {
251251
/**
252252
* Updates a payment intent with data from order: customer, level3 data and and maybe sets the payment for future use.
253253
*
254-
* @param {string} intentId The id of the payment intent.
255-
* @param {number} orderId The id of the order.
256-
* @param {string} savePaymentMethod 'yes' if saving.
254+
* @param {string} intentId The id of the payment intent.
255+
* @param {number} orderId The id of the order.
256+
* @param {string} savePaymentMethod 'yes' if saving.
257257
* @param {string} selectedUPEPaymentType The name of the selected UPE payment type or empty string.
258258
*
259-
* @return {Promise} The final promise for the request to the server.
259+
* @return {Object|undefined} The response from the server or undefined if the intent is a setup intent.
260260
*/
261261
updateIntent(
262262
intentId,
@@ -298,7 +298,7 @@ export default class WCStripeAPI {
298298
* Extracts the details about a payment intent from the redirect URL,
299299
* and displays the intent confirmation modal (if needed).
300300
*
301-
* @param {string} redirectUrl The redirect URL, returned from the server.
301+
* @param {string} redirectUrl The redirect URL, returned from the server.
302302
* @param {string} paymentMethodToSave The ID of a Payment Method if it should be saved (optional).
303303
* @return {Object|true} An object containing the redirect URL on success and a flag indicating
304304
* if the page is the Pay for order page, or `true` if no confirmation is needed.
@@ -385,7 +385,7 @@ export default class WCStripeAPI {
385385
* Process checkout and update payment intent via AJAX.
386386
*
387387
* @param {string} paymentIntentId ID of payment intent to be updated.
388-
* @param {Object} fields Checkout fields.
388+
* @param {Object} fields Checkout fields.
389389
* @return {Promise} Promise containing redirect URL for UPE element.
390390
*/
391391
processCheckout( paymentIntentId, fields ) {
@@ -415,7 +415,7 @@ export default class WCStripeAPI {
415415
* Updates order status, if there is an error while confirming intent.
416416
*
417417
* @param {string} intentId The id of the Payment/Setup Intent.
418-
* @param {number} orderId The id of the WC_Order.
418+
* @param {number} orderId The id of the WC_Order.
419419
*/
420420
updateFailedOrder( intentId, orderId ) {
421421
this.request( this.getAjaxUrl( 'update_failed_order' ), {
@@ -496,7 +496,7 @@ export default class WCStripeAPI {
496496
/**
497497
* Normalizes address fields in WooCommerce supported format.
498498
*
499-
* @param {Object} billingAddress Billing address.
499+
* @param {Object} billingAddress Billing address.
500500
* @param {Object} shippingAddress Shipping address.
501501
* @return {Promise} Promise for the request to the server.
502502
*/
@@ -604,7 +604,7 @@ export default class WCStripeAPI {
604604
/**
605605
* Empty the cart (legacy version, non-StoreAPI).
606606
*
607-
* @param {Object} params Parameters.
607+
* @param {Object} params Parameters.
608608
* @param {number} params.bookingId Booking ID.
609609
* @return {Promise} Promise for the request to the server.
610610
*/
@@ -640,9 +640,9 @@ export default class WCStripeAPI {
640640
/**
641641
* Pays for an order based on the Express Checkout payment method.
642642
*
643-
* @param {number} order The order ID.
643+
* @param {number} order The order ID.
644644
* @param {Object} orderDetails Order details, including order key and billing email.
645-
* @param {Object} paymentData Order data.
645+
* @param {Object} paymentData Order data.
646646
* @return {Promise} Promise for the request to the server.
647647
*/
648648
expressCheckoutECEPayForOrder( order, orderDetails, paymentData ) {
@@ -657,8 +657,8 @@ export default class WCStripeAPI {
657657
/**
658658
* Posts data to the Blocks API.
659659
*
660-
* @param {string} path The path to post to.
661-
* @param {Object} data The data to post.
660+
* @param {string} path The path to post to.
661+
* @param {Object} data The data to post.
662662
* @param {Object} headers The headers for the request.
663663
* @return {Promise} The promise for the request to the server.
664664
*/

client/blocks/credit-card/elements.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const baseTextInputStyles = 'wc-block-gateway-input';
1515
/**
1616
* InlineCard component
1717
*
18-
* @param {Object} props Incoming props for the component.
18+
* @param {Object} props Incoming props for the component.
1919
* @param {React.ReactElement} props.inputErrorComponent
20-
* @param {function(any):any} props.onChange
20+
* @param {function(any):any} props.onChange
2121
*/
2222
export const InlineCard = ( {
2323
inputErrorComponent: ValidationInputError,
@@ -63,8 +63,8 @@ export const InlineCard = ( {
6363
/**
6464
* CardElements component.
6565
*
66-
* @param {Object} props
67-
* @param {function(any):any} props.onChange
66+
* @param {Object} props
67+
* @param {function(any):any} props.onChange
6868
* @param {React.ReactElement} props.inputErrorComponent
6969
*/
7070
export const CardElements = ( {

client/blocks/credit-card/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { __ } from '@wordpress/i18n';
21
import { useEffect, useState } from '@wordpress/element';
2+
import { __ } from '@wordpress/i18n';
33
import { ThreeDSecurePaymentHandler } from '../three-d-secure';
44
import { StripeCreditCard, getStripeCreditCardIcons } from './payment-method';
55
import { PAYMENT_METHOD_NAME } from './constants';

client/blocks/express-checkout/express-button-previews/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import './style.scss';
99
* Base PaymentButtonPreview Component
1010
*
1111
* @param {Object} props
12-
* @param {string} props.icon - The icon to display.
12+
* @param {string} props.icon - The icon to display.
1313
* @param {string} [props.className] - Optional additional class names.
1414
* @return {JSX.Element} The rendered component.
1515
*/

client/blocks/express-checkout/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const getEditorElement = ( expressPaymentMethod ) => {
6767
/**
6868
*
6969
* @param {string} expressPaymentMethod
70-
* @param {Object} api The Stripe API object.
70+
* @param {Object} api The Stripe API object.
7171
* @return {Object} The express payment method configuration.
7272
*/
7373
const expressCheckoutElement = ( expressPaymentMethod, api ) => {

client/blocks/payment-request/event-handlers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ const getRedirectUrlPartials = ( url ) => {
7676
* Helper function. Requests that the provided intent (identified by the secret) is be
7777
* handled by Stripe. Returns a promise from Stripe.
7878
*
79-
* @param {Object} stripe - The stripe object.
80-
* @param {string} intentType - The type of intent. Either `pi` or `si`.
79+
* @param {Object} stripe - The stripe object.
80+
* @param {string} intentType - The type of intent. Either `pi` or `si`.
8181
* @param {string} clientSecret - Client secret returned from Stripe.
8282
*
8383
* @return {Promise} A promise from Stripe with the confirmed intent or an error.
@@ -94,7 +94,7 @@ const requestIntentConfirmation = ( stripe, intentType, clientSecret ) => {
9494
/**
9595
* Helper function. Returns the payment or setup intent from a given confirmed intent.
9696
*
97-
* @param {Object} intent - The confirmed intent.
97+
* @param {Object} intent - The confirmed intent.
9898
* @param {string} intentType - The payment intent's type. Either `pi` or `si`.
9999
*
100100
* @return {Object} The Stripe payment or setup intent.
@@ -122,7 +122,7 @@ const didIntentSucceed = ( intent ) => {
122122
* payment method of the intent was confirmed successfully.
123123
*
124124
* @param {string} redirectUrl - The URL to redirect to after a successful payment.
125-
* @param {string} intentType - The type of the payment intent. Either `pi` or `si`.
125+
* @param {string} intentType - The type of the payment intent. Either `pi` or `si`.
126126
*/
127127
const handleIntentConfirmation = ( redirectUrl, intentType ) => (
128128
confirmation
@@ -144,8 +144,8 @@ const handleIntentConfirmation = ( redirectUrl, intentType ) => (
144144
* our AJAX API, proceeds with payment if possible, otherwise attempts to confirm the
145145
* payment (i.e. 3DS verification) through Stripe.
146146
*
147-
* @param {Object} stripe - The Stripe JS object.
148-
* @param {Object} evt - The `source` event from the Stripe payment request button.
147+
* @param {Object} stripe - The Stripe JS object.
148+
* @param {Object} evt - The `source` event from the Stripe payment request button.
149149
* @param {Function} setExpressPaymentError - Used to show error messages to the customer.
150150
*/
151151
const performPayment = ( stripe, evt, setExpressPaymentError ) => (

client/blocks/payment-request/hooks.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import { getCartDetails } from 'wcstripe/api/blocks';
1616
* This hook takes care of creating a payment request and making sure
1717
* you can pay through said payment request.
1818
*
19-
* @param {Object} stripe The stripe object used to create the payment request.
19+
* @param {Object} stripe The stripe object used to create the payment request.
2020
* @param {boolean} needsShipping A value from the Block checkout that indicates whether shipping
2121
* is required or not.
22-
* @param {Object} billing - The billing data from the checkout or cart block.
22+
* @param {Object} billing - The billing data from the checkout or cart block.
2323
*
2424
* @return {Array} An array; first element is the payment request; second element is the payment
2525
* requests type.
@@ -87,9 +87,9 @@ export const usePaymentRequest = ( stripe, needsShipping, billing ) => {
8787
* Returns an onClick handler for payment request buttons. Checks if login is required, resets
8888
* the error state, syncs the payment request with the block, and calls the provided click handler.
8989
*
90-
* @param {string} paymentRequestType - The payment request type.
90+
* @param {string} paymentRequestType - The payment request type.
9191
* @param {Function} setExpressPaymentError - Used to set the error state.
92-
* @param {Function} onClick - The onClick function that should be called on click.
92+
* @param {Function} onClick - The onClick function that should be called on click.
9393
*
9494
* @return {Function} An onClick handler for the payment request buttons.
9595
*/
@@ -126,7 +126,7 @@ export const useOnClickHandler = (
126126
* Adds a shipping address change event handler to the provided payment request. Updates the
127127
* order's shipping address when necessary.
128128
*
129-
* @param {Object} paymentRequest - The payment request object.
129+
* @param {Object} paymentRequest - The payment request object.
130130
* @param {string} paymentRequestType - The payment request type.
131131
*/
132132
export const useShippingAddressUpdateHandler = (
@@ -149,7 +149,7 @@ export const useShippingAddressUpdateHandler = (
149149
/**
150150
* Adds a shipping option change event handler to the provided payment request.
151151
*
152-
* @param {Object} paymentRequest - The payment request object.
152+
* @param {Object} paymentRequest - The payment request object.
153153
* @param {string} paymentRequestType - The payment request type.
154154
*/
155155
export const useShippingOptionChangeHandler = (
@@ -172,11 +172,11 @@ export const useShippingOptionChangeHandler = (
172172
/**
173173
* Adds a payment event handler to the provided payment request.
174174
*
175-
* @param {Object} stripe - The stripe object used to confirm and create a payment intent.
176-
* @param {Object} paymentRequest - The payment request object.
177-
* @param {string} paymentRequestType - The payment request type.
175+
* @param {Object} stripe - The stripe object used to confirm and create a payment intent.
176+
* @param {Object} paymentRequest - The payment request object.
177+
* @param {string} paymentRequestType - The payment request type.
178178
* @param {Function} setExpressPaymentError - A function used to expose an error message to show
179-
* the customer.
179+
* the customer.
180180
*/
181181
export const useProcessPaymentHandler = (
182182
stripe,
@@ -204,8 +204,8 @@ export const useProcessPaymentHandler = (
204204
/**
205205
* Adds a cancellation handler to the provided payment request.
206206
*
207-
* @param {Object} paymentRequest - The payment request object.
208-
* @param {Function} onClose - A function from the Blocks API.
207+
* @param {Object} paymentRequest - The payment request object.
208+
* @param {Function} onClose - A function from the Blocks API.
209209
*/
210210
export const useCancelHandler = ( paymentRequest, onClose ) => {
211211
useEffect( () => {

0 commit comments

Comments
 (0)