Fix js lint

some rules suppressed to avoid changing implementation
This commit is contained in:
carmenmaymo 2025-04-14 14:37:16 +02:00
parent f5461a1eb2
commit 800bf1b766
No known key found for this signature in database
GPG key ID: 6023F686B0F3102E
28 changed files with 91 additions and 44 deletions

View file

@ -1,11 +1,13 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"env": {
"browser": true
"browser": true,
"jest": true
},
"globals": {
"wc": true,
"jQuery": "readonly"
"jQuery": "readonly",
"ppcpSwitchSettingsUi": "readonly"
},
"rules": {
"no-console": ["error", { "allow": ["warn", "error"] }]

View file

@ -1,3 +1,4 @@
/* eslint-disable no-undef, jsdoc/no-undefined-types */
import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
import { debounce } from '../../../../../ppcp-blocks/resources/js/Helper/debounce';
@ -7,11 +8,12 @@ import { debounce } from '../../../../../ppcp-blocks/resources/js/Helper/debounc
* A generic wrapper that adds debounced store updates to any controlled component.
*
* @param {Object} props
* @param {React.ComponentType} props.control The controlled component to render
* @param {React.ComponentType} props.control The controlled component to render // eslint-disable-line jsdoc/no-undefined-types
* @param {string|number} props.value The controlled value
* @param {Function} props.onChange Change handler
* @param {number} [props.delay=300] Debounce delay in milliseconds
*/
const DataStoreControl = React.forwardRef(
(
{

View file

@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import React from 'react';
const GenericIcon = ( { imageName, className = '', alt = '' } ) => {

View file

@ -36,6 +36,7 @@ const PricingTitleBadge = ( { item } ) => {
);
const label = sprintf(
// Translators: %1$s is the percentage, %2$s is the fixed amount.
__( 'from %1$s%% + %2$s', 'woocommerce-paypal-payments' ),
percentage,
fixedAmount

View file

@ -97,6 +97,7 @@ const TodoItem = ( {
onDismiss,
} ) => {
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
<div
className={ `ppcp-r-todo-item ${
isCompleted ? 'is-completed' : ''

View file

@ -32,13 +32,15 @@ const StepPaymentMethods = () => {
description: <OptionalMethodDescription />,
},
{
title: ownBrandOnly ? __(
'No thanks, I prefer to use a different provider for local payment methods',
'woocommerce-paypal-payments'
) : __(
'No thanks, I prefer to use a different provider for processing credit cards, digital wallets, and local payment methods',
'woocommerce-paypal-payments'
),
title: ownBrandOnly
? __(
'No thanks, I prefer to use a different provider for local payment methods',
'woocommerce-paypal-payments'
)
: __(
'No thanks, I prefer to use a different provider for processing credit cards, digital wallets, and local payment methods',
'woocommerce-paypal-payments'
),
value: false,
},
];

View file

@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { __, sprintf } from '@wordpress/i18n';
import { useEffect, useState } from '@wordpress/element';
@ -38,7 +39,13 @@ const StepProducts = () => {
};
initChoices();
}, [ canUseSubscriptions, optionState, products, setProducts ] );
}, [
canUseSubscriptions,
optionState,
isCasualSeller,
products,
setProducts,
] );
const handleChange = ( key, checked ) => {
const getNewValue = () => {

View file

@ -57,7 +57,9 @@ const filterSteps = ( steps, conditions ) => {
};
export const getSteps = ( flags ) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { ownBrandOnly } = CommonHooks.useWooSettings();
// eslint-disable-next-line react-hooks/rules-of-hooks
const { isCasualSeller } = OnboardingHooks.useBusiness();
const steps = filterSteps( ALL_STEPS, [

View file

@ -3,8 +3,9 @@ import { __, sprintf } from '@wordpress/i18n';
export const payLaterMessaging = {
US: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. PayPals Pay Later helps boost merchants\' conversion rates and increases cart sizes by 39%%.¹ You get paid in full up front. <a target="_blank" href="%s">More about Pay Later</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. PayPals Pay Later helps boost merchants\' conversion rates and increases cart sizes by 39%%.¹ You get paid in full up front. <a target="_blank" href="%1$s">More about Pay Later</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/us/business/accept-payments/checkout/installments'
@ -15,8 +16,9 @@ export const payLaterMessaging = {
},
GB: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 3 gets a 216%% higher Average Order Value than a standard PayPal transaction.¹ Theres <strong>no extra cost</strong> and you get paid up front. <a target="_blank" href="%s">More about Pay in 3</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 3 gets a 216%% higher Average Order Value than a standard PayPal transaction.¹ Theres <strong>no extra cost</strong> and you get paid up front. <a target="_blank" href="%1$s">More about Pay in 3</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/uk/business/accept-payments/checkout/installments'
@ -30,8 +32,9 @@ export const payLaterMessaging = {
},
FR: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 4x gets a 65%% higher Average Order Value than a standard PayPal transaction.¹ <strong>There\'s no extra cost on top of your PayPal Checkout rate</strong>, and you get paid up front. <a target="_blank" href="%s">More about Pay in 4x</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 4x gets a 65%% higher Average Order Value than a standard PayPal transaction.¹ <strong>There\'s no extra cost on top of your PayPal Checkout rate</strong>, and you get paid up front. <a target="_blank" href="%1$s">More about Pay in 4x</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/fr/business/accept-payments/checkout/installments'
@ -45,8 +48,9 @@ export const payLaterMessaging = {
},
AU: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 4 gets more than a 100%% higher Average Order Value than a standard PayPal transaction.¹ Theres <strong>no extra cost</strong> and you get paid up front. <a target="_blank" href="%s">More about Pay in 4</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 4 gets more than a 100%% higher Average Order Value than a standard PayPal transaction.¹ Theres <strong>no extra cost</strong> and you get paid up front. <a target="_blank" href="%1$s">More about Pay in 4</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/au/business/accept-payments/checkout/installments'
@ -60,8 +64,9 @@ export const payLaterMessaging = {
},
IT: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 3 installments gets about a 275%% higher Average Order Value than a standard PayPal transaction.¹ <strong>There\'s no extra cost on top of your PayPal Checkout rate</strong>, and you get paid up front. <a target="_blank" href="%s">More about Pay in 3 installments</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 3 installments gets about a 275%% higher Average Order Value than a standard PayPal transaction.¹ <strong>There\'s no extra cost on top of your PayPal Checkout rate</strong>, and you get paid up front. <a target="_blank" href="%1$s">More about Pay in 3 installments</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/it/business/accept-payments/checkout/installments'
@ -75,8 +80,9 @@ export const payLaterMessaging = {
},
ES: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 3 installments gets about a 275%% higher Average Order Value than a standard PayPal transaction.¹ <strong>There\'s no extra cost on top of your PayPal Checkout rate</strong>, and you get paid up front. <a target="_blank" href="%s">More about Pay in 3 installments</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. Pay in 3 installments gets about a 275%% higher Average Order Value than a standard PayPal transaction.¹ <strong>There\'s no extra cost on top of your PayPal Checkout rate</strong>, and you get paid up front. <a target="_blank" href="%1$s">More about Pay in 3 installments</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/es/business/accept-payments/checkout/installments'
@ -90,8 +96,9 @@ export const payLaterMessaging = {
},
DE: {
description: sprintf(
// Translators: %1$s: URL for more information.
__(
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. When you offer your customers Pay Later options, 57%% will be more likely to buy from you again.¹ <strong>There\'s no extra cost</strong> and you get paid up front. <a target="_blank" href="%s">More about Pay Later</a>',
'Your customers can already buy now and pay later with PayPal — add messaging to your site to let them know. When you offer your customers Pay Later options, 57%% will be more likely to buy from you again.¹ <strong>There\'s no extra cost</strong> and you get paid up front. <a target="_blank" href="%1$s">More about Pay Later</a>',
'woocommerce-paypal-payments'
),
'https://www.paypal.com/de/business/accept-payments/checkout/installments'

View file

@ -22,6 +22,7 @@ const PaymentDependencyMessage = ( { parentId, parentName } ) => {
{
methodLink: (
<strong>
{ /* eslint-disable-next-line jsx-a11y/anchor-is-valid */ }
<a
href="#"
onClick={ ( e ) => {

View file

@ -36,6 +36,7 @@ const transformSectionId = ( sectionId ) => {
*/
const SettingLink = ( { settingName, sectionId } ) => (
<strong>
{ /* eslint-disable-next-line jsx-a11y/anchor-is-valid */ }
<a
href="#"
onClick={ ( e ) => {

View file

@ -73,6 +73,7 @@ const generateOptions = ( config, settings, updateFormValue ) => [
value: 'manual_connect',
label: __( 'Manual Connect', 'woocommerce-paypal-payments' ),
description: sprintf(
// translators: %s: Link to PayPal REST application documentation.
__(
'For advanced users: Connect a custom PayPal REST app for full control over your integration. For more information on creating a PayPal REST application, <a target="_blank" href="%s">click here</a>.',
'woocommerce-paypal-payments'
@ -128,9 +129,10 @@ const generateOptions = ( config, settings, updateFormValue ) => [
const generateModeData = ( config, settings, updateFormValue ) => ( {
title: config.title,
description: config.description,
connectTitle: __(
`Connect ${ config.label } Account`, // TODO: Avoid variables inside __() translation literal.
'woocommerce-paypal-payments'
connectTitle: sprintf(
/* translators: %s: Account type (e.g., Sandbox, Live) */
__( 'Connect %s Account', 'woocommerce-paypal-payments' ),
config.label
),
connectDescription: config.connectDescription,
options: generateOptions( config, settings, updateFormValue ),

View file

@ -1,4 +1,5 @@
import { __ } from '@wordpress/i18n';
// eslint-disable-next-line import/no-extraneous-dependencies
import { useEffect } from 'react';
import { ControlToggleButton } from '../../../../../ReusableComponents/Controls';
@ -17,7 +18,11 @@ const OrderIntent = () => {
if ( ! authorizeOnly && captureVirtualOnlyOrders ) {
setCaptureVirtualOnlyOrders( false );
}
}, [ authorizeOnly ] );
}, [
authorizeOnly,
captureVirtualOnlyOrders,
setCaptureVirtualOnlyOrders,
] );
return (
<SettingsBlock

View file

@ -36,6 +36,7 @@ const Troubleshooting = () => {
<SettingsBlock
title={ __( 'Webhooks', 'woocommerce-paypal-payments' ) }
description={ sprintf(
// Translators: %s is the URL to the Webhook Status documentation.
__(
'The following PayPal webhooks are subscribed. More information about the webhooks is available in the <a href="%s">Webhook Status documentation</a>.',
'woocommerce-paypal-payments'

View file

@ -24,7 +24,7 @@ const DisconnectButton = () => {
const handleConfirm = useCallback( async () => {
await disconnectMerchant( resetFlag );
goToPluginSettings();
}, [ disconnectMerchant, resetFlag ] );
}, [ disconnectMerchant, goToPluginSettings, resetFlag ] );
const confirmationTitle = __(
'Disconnect from PayPal?',

View file

@ -9,7 +9,7 @@ const TabPayLaterMessaging = () => {
setProduct,
setShop,
setHome,
setCustom_placement,
setCustomPlacement,
} = PayLaterMessagingHooks.usePayLaterMessaging();
const PcpPayLaterConfigurator =
window.ppcpSettings?.PcpPayLaterConfigurator;
@ -41,11 +41,20 @@ const TabPayLaterMessaging = () => {
setProduct( data.config.product );
setShop( data.config.shop );
setHome( data.config.home );
setCustom_placement( data.config.custom_placement );
setCustomPlacement( data.config.custom_placement );
},
} );
}
}, [ PcpPayLaterConfigurator, config ] );
}, [
PcpPayLaterConfigurator,
config,
setCart,
setCheckout,
setCustomPlacement,
setHome,
setProduct,
setShop,
] );
return (
<div

View file

@ -45,7 +45,7 @@ export function refresh() {
*
* @param {string[]} [products=[]] Which products/features to display in the ISU popup.
* @param {Object} [options={}] Options to customize the onboarding workflow.
* @param isSandbox True if is sandbox, otherwise false.
* @param {boolean} isSandbox True if is sandbox, otherwise false.
* @return {Function} The thunk function.
*/
export function onboardingUrl(

View file

@ -8,7 +8,6 @@
* @file
*/
import { __ } from '@wordpress/i18n';
import apiFetch from '@wordpress/api-fetch';
import { REST_PATH } from './constants';

View file

@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import '@testing-library/jest-dom';
import { PRODUCT_TYPES } from './configuration';

View file

@ -28,7 +28,7 @@ const useHooks = () => {
const [ product, setProduct ] = usePersistent( 'product' );
const [ shop, setShop ] = usePersistent( 'shop' );
const [ home, setHome ] = usePersistent( 'home' );
const [ custom_placement, setCustom_placement ] =
const [ customPlacement, setCustomPlacement ] =
usePersistent( 'custom_placement' );
return {
@ -44,8 +44,8 @@ const useHooks = () => {
setShop,
home,
setHome,
custom_placement,
setCustom_placement,
customPlacement,
setCustomPlacement,
};
};
@ -66,8 +66,8 @@ export const usePayLaterMessaging = () => {
setShop,
home,
setHome,
custom_placement,
setCustom_placement,
customPlacement,
setCustomPlacement,
} = useHooks();
return {
@ -77,13 +77,13 @@ export const usePayLaterMessaging = () => {
product,
shop,
home,
custom_placement,
customPlacement,
},
setCart,
setCheckout,
setProduct,
setShop,
setHome,
setCustom_placement,
setCustomPlacement,
};
};

View file

@ -24,7 +24,7 @@ const defaultPersistent = Object.freeze( {
product: {},
shop: {},
home: {},
custom_placement: [],
customPlacement: [],
} );
// Reducer logic.

View file

@ -20,7 +20,6 @@ import {
STYLING_PAYMENT_METHODS,
STYLING_SHAPES,
} from './configuration';
import { persistentData } from './selectors';
/**
* Single source of truth for access Redux details.

View file

@ -29,8 +29,10 @@ const ACTIVITIES = {
export const useHandleOnboardingButton = ( isSandbox ) => {
const { onboardingUrl } = isSandbox
? CommonHooks.useSandbox()
: CommonHooks.useProduction();
? // eslint-disable-next-line react-hooks/rules-of-hooks
CommonHooks.useSandbox()
: // eslint-disable-next-line react-hooks/rules-of-hooks
CommonHooks.useProduction();
const { ownBrandOnly } = CommonHooks.useWooSettings();
const { products, options } =
OnboardingHooks.useDetermineProducts( ownBrandOnly );

View file

@ -70,7 +70,7 @@ export const usePaymentGatewayRefresh = () => {
}
// Update Redux state to mark gateways as refreshed.
const result = await refreshGateways();
await refreshGateways();
setRefreshCompleted( true );
return { success: true };

View file

@ -19,8 +19,8 @@ export const usePaymentGatewaySync = () => {
const { isReady: merchantIsReady } = CommonHooks.useStore();
const [ isSyncing, setIsSyncing ] = useState( false );
const [ syncCompleted, setSyncCompleted ] = useState( false );
const [ syncError, setSyncError ] = useState( null );
const [ , setSyncCompleted ] = useState( false );
const [ , setSyncError ] = useState( null );
// Use a ref to track if we've initiated a sync during this session.
const syncAttemptedRef = useRef( false );

View file

@ -32,7 +32,7 @@ const useSettingDependencyState = ( methods ) => {
if ( method.depends_on_settings.settings ) {
const settingsObj = method.depends_on_settings.settings;
for ( const [ settingId, settingData ] of Object.entries(
for ( const [ , settingData ] of Object.entries(
settingsObj
) ) {
const requiredId = settingData.id;

View file

@ -1,4 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { createRoot } from 'react-dom/client';
import App from './Components/App';

View file

@ -24,7 +24,7 @@ document.addEventListener( 'DOMContentLoaded', () => {
}
return response.json();
} )
.then( ( data ) => {
.then( () => {
window.location.reload();
} )
.catch( ( error ) => {