Skip to content

Commit 22029d4

Browse files
fix: Lint Warnings (#728)
* fix lint warnings * add changeset
1 parent 45b78ce commit 22029d4

File tree

7 files changed

+15
-6
lines changed

7 files changed

+15
-6
lines changed

.changeset/tame-states-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@paypal/react-paypal-js": patch
3+
---
4+
5+
Fix lint warnings.

packages/react-paypal-js/src/components/PayPalButtons.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ describe("<PayPalButtons />", () => {
343343
.spyOn(console, "error")
344344
.mockImplementation();
345345
window.paypal = {
346+
// @ts-expect-error mocking partial ButtonComponent
346347
Buttons() {
347348
return {
348349
close: jest.fn().mockResolvedValue({}),
@@ -424,6 +425,7 @@ describe("<PayPalButtons />", () => {
424425
.fn()
425426
.mockRejectedValue(new Error("Unknown error"));
426427
window.paypal = {
428+
// @ts-expect-error mocking partial ButtonComponent
427429
Buttons() {
428430
return {
429431
close: jest.fn().mockResolvedValue({}),
@@ -467,7 +469,7 @@ describe("<PayPalButtons />", () => {
467469
userEvent.setup();
468470

469471
// @ts-expect-error mocking partial ButtonComponent
470-
window.paypal!.Buttons = ({ onClick }: { onClick: () => void }) => ({
472+
window.paypal.Buttons = ({ onClick }: { onClick: () => void }) => ({
471473
isEligible: () => true,
472474
close: async () => undefined,
473475
render: async (ref: HTMLDivElement) => {

packages/react-paypal-js/src/components/PayPalButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import React, { useEffect, useRef, useState } from "react";
33
import { usePayPalScriptReducer } from "../hooks/scriptProviderHooks";
44
import { getPayPalWindowNamespace, generateErrorMessage } from "../utils";
55
import { SDK_SETTINGS } from "../constants";
6+
import { useProxyProps } from "../hooks/useProxyProps";
67

78
import type { FunctionComponent } from "react";
89
import type { PayPalButtonsComponent, OnInitActions } from "@paypal/paypal-js";
910
import type { PayPalButtonsComponentProps } from "../types";
10-
import { useProxyProps } from "../hooks/useProxyProps";
1111

1212
/**
1313
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.

packages/react-paypal-js/src/context/scriptProviderContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
*/
1919
export function getScriptID(options: ReactPayPalScriptOptions): string {
2020
// exclude the data-react-paypal-script-id value from the options hash
21+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2122
const { [SCRIPT_ID]: _scriptId, ...paypalScriptOptions } = options;
2223

2324
return `react-paypal-js-${hashStr(JSON.stringify(paypalScriptOptions))}`;

packages/react-paypal-js/src/hooks/useProxyProps.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
OnClickActions,
55
} from "@paypal/paypal-js";
66
import { renderHook } from "@testing-library/react-hooks";
7+
78
import { useProxyProps } from "./useProxyProps";
89

910
describe("useProxyProps", () => {
@@ -26,12 +27,12 @@ describe("useProxyProps", () => {
2627
expect(current.onClick).not.toBe(props.onClick);
2728

2829
expect(
29-
current.createOrder!(
30+
current.createOrder?.(
3031
{} as CreateOrderData,
3132
{} as CreateOrderActions,
3233
),
3334
).toBe("createOrder");
34-
expect(current.onClick!({}, {} as OnClickActions)).toBe("onClick");
35+
expect(current.onClick?.({}, {} as OnClickActions)).toBe("onClick");
3536

3637
expect(props.createOrder).toHaveBeenCalled();
3738
expect(props.onClick).toHaveBeenCalled();

packages/react-paypal-js/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ export * from "./components/cardFields/PayPalCardFieldsForm";
1818
export * from "./components/cardFields/context";
1919
export { usePayPalCardFields } from "./components/cardFields/hooks";
2020

21-
import type { FUNDING_SOURCE } from "@paypal/paypal-js";
2221
import * as constants from "@paypal/sdk-constants/dist/module";
2322

23+
import type { FUNDING_SOURCE } from "@paypal/paypal-js";
24+
2425
// We do not re-export `FUNDING` from the `sdk-constants` module
2526
// directly because it has no type definitions.
2627
//

packages/react-paypal-js/src/stories/components/CopyButton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState } from "react";
22
import { useSandpack } from "@codesandbox/sandpack-react";
33

44
import type { ReactElement } from "react";
5-
65
import type { Properties as CSSProperties } from "csstype";
76

87
const COPY_BUTTON: CSSProperties = {

0 commit comments

Comments
 (0)