diff --git a/.changeset/tame-states-return.md b/.changeset/tame-states-return.md new file mode 100644 index 00000000..f7f958c6 --- /dev/null +++ b/.changeset/tame-states-return.md @@ -0,0 +1,5 @@ +--- +"@paypal/react-paypal-js": patch +--- + +Fix lint warnings. diff --git a/packages/react-paypal-js/src/components/PayPalButtons.test.tsx b/packages/react-paypal-js/src/components/PayPalButtons.test.tsx index 66a03542..59c0c4b7 100644 --- a/packages/react-paypal-js/src/components/PayPalButtons.test.tsx +++ b/packages/react-paypal-js/src/components/PayPalButtons.test.tsx @@ -343,6 +343,7 @@ describe("", () => { .spyOn(console, "error") .mockImplementation(); window.paypal = { + // @ts-expect-error mocking partial ButtonComponent Buttons() { return { close: jest.fn().mockResolvedValue({}), @@ -424,6 +425,7 @@ describe("", () => { .fn() .mockRejectedValue(new Error("Unknown error")); window.paypal = { + // @ts-expect-error mocking partial ButtonComponent Buttons() { return { close: jest.fn().mockResolvedValue({}), @@ -467,7 +469,7 @@ describe("", () => { userEvent.setup(); // @ts-expect-error mocking partial ButtonComponent - window.paypal!.Buttons = ({ onClick }: { onClick: () => void }) => ({ + window.paypal.Buttons = ({ onClick }: { onClick: () => void }) => ({ isEligible: () => true, close: async () => undefined, render: async (ref: HTMLDivElement) => { diff --git a/packages/react-paypal-js/src/components/PayPalButtons.tsx b/packages/react-paypal-js/src/components/PayPalButtons.tsx index 8287a975..627d5f97 100644 --- a/packages/react-paypal-js/src/components/PayPalButtons.tsx +++ b/packages/react-paypal-js/src/components/PayPalButtons.tsx @@ -3,11 +3,11 @@ import React, { useEffect, useRef, useState } from "react"; import { usePayPalScriptReducer } from "../hooks/scriptProviderHooks"; import { getPayPalWindowNamespace, generateErrorMessage } from "../utils"; import { SDK_SETTINGS } from "../constants"; +import { useProxyProps } from "../hooks/useProxyProps"; import type { FunctionComponent } from "react"; import type { PayPalButtonsComponent, OnInitActions } from "@paypal/paypal-js"; import type { PayPalButtonsComponentProps } from "../types"; -import { useProxyProps } from "../hooks/useProxyProps"; /** This `` component supports rendering [buttons](https://developer.paypal.com/docs/business/javascript-sdk/javascript-sdk-reference/#buttons) for PayPal, Venmo, and alternative payment methods. diff --git a/packages/react-paypal-js/src/context/scriptProviderContext.ts b/packages/react-paypal-js/src/context/scriptProviderContext.ts index c5c68066..da46df4c 100644 --- a/packages/react-paypal-js/src/context/scriptProviderContext.ts +++ b/packages/react-paypal-js/src/context/scriptProviderContext.ts @@ -18,6 +18,7 @@ import type { */ export function getScriptID(options: ReactPayPalScriptOptions): string { // exclude the data-react-paypal-script-id value from the options hash + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { [SCRIPT_ID]: _scriptId, ...paypalScriptOptions } = options; return `react-paypal-js-${hashStr(JSON.stringify(paypalScriptOptions))}`; diff --git a/packages/react-paypal-js/src/hooks/useProxyProps.test.ts b/packages/react-paypal-js/src/hooks/useProxyProps.test.ts index 4300994c..530b26df 100644 --- a/packages/react-paypal-js/src/hooks/useProxyProps.test.ts +++ b/packages/react-paypal-js/src/hooks/useProxyProps.test.ts @@ -4,6 +4,7 @@ import { OnClickActions, } from "@paypal/paypal-js"; import { renderHook } from "@testing-library/react-hooks"; + import { useProxyProps } from "./useProxyProps"; describe("useProxyProps", () => { @@ -26,12 +27,12 @@ describe("useProxyProps", () => { expect(current.onClick).not.toBe(props.onClick); expect( - current.createOrder!( + current.createOrder?.( {} as CreateOrderData, {} as CreateOrderActions, ), ).toBe("createOrder"); - expect(current.onClick!({}, {} as OnClickActions)).toBe("onClick"); + expect(current.onClick?.({}, {} as OnClickActions)).toBe("onClick"); expect(props.createOrder).toHaveBeenCalled(); expect(props.onClick).toHaveBeenCalled(); diff --git a/packages/react-paypal-js/src/index.ts b/packages/react-paypal-js/src/index.ts index 4a31e56e..9827c440 100644 --- a/packages/react-paypal-js/src/index.ts +++ b/packages/react-paypal-js/src/index.ts @@ -18,9 +18,10 @@ export * from "./components/cardFields/PayPalCardFieldsForm"; export * from "./components/cardFields/context"; export { usePayPalCardFields } from "./components/cardFields/hooks"; -import type { FUNDING_SOURCE } from "@paypal/paypal-js"; import * as constants from "@paypal/sdk-constants/dist/module"; +import type { FUNDING_SOURCE } from "@paypal/paypal-js"; + // We do not re-export `FUNDING` from the `sdk-constants` module // directly because it has no type definitions. // diff --git a/packages/react-paypal-js/src/stories/components/CopyButton.tsx b/packages/react-paypal-js/src/stories/components/CopyButton.tsx index b78f45e9..98d5c243 100644 --- a/packages/react-paypal-js/src/stories/components/CopyButton.tsx +++ b/packages/react-paypal-js/src/stories/components/CopyButton.tsx @@ -2,7 +2,6 @@ import React, { useState } from "react"; import { useSandpack } from "@codesandbox/sandpack-react"; import type { ReactElement } from "react"; - import type { Properties as CSSProperties } from "csstype"; const COPY_BUTTON: CSSProperties = {