Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-states-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@paypal/react-paypal-js": patch
---

Fix lint warnings.
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ describe("<PayPalButtons />", () => {
.spyOn(console, "error")
.mockImplementation();
window.paypal = {
// @ts-expect-error mocking partial ButtonComponent
Buttons() {
return {
close: jest.fn().mockResolvedValue({}),
Expand Down Expand Up @@ -424,6 +425,7 @@ describe("<PayPalButtons />", () => {
.fn()
.mockRejectedValue(new Error("Unknown error"));
window.paypal = {
// @ts-expect-error mocking partial ButtonComponent
Buttons() {
return {
close: jest.fn().mockResolvedValue({}),
Expand Down Expand Up @@ -467,7 +469,7 @@ describe("<PayPalButtons />", () => {
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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<PayPalButtons />` component supports rendering [buttons](https://developer.paypal.com/docs/business/javascript-sdk/javascript-sdk-reference/#buttons) for PayPal, Venmo, and alternative payment methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))}`;
Expand Down
5 changes: 3 additions & 2 deletions packages/react-paypal-js/src/hooks/useProxyProps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
OnClickActions,
} from "@paypal/paypal-js";
import { renderHook } from "@testing-library/react-hooks";

import { useProxyProps } from "./useProxyProps";

describe("useProxyProps", () => {
Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion packages/react-paypal-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading