Skip to content

Commit 638e8e6

Browse files
hnguyen510Hai-Yen Nguyenwsbrunson
authored
Fix formatting (#552)
* remove prettier for packages/paypal-js * uninstall prettier for packages/react-paypal-js * update prettier version to 3.1.1 in root level * remove format and format:check * remove format:check from validate * change format, update node version to v18, fixed build errors * run changeset add --empty * update prettier version from 3.1.1 to 3.3.3 * remove .nvmrc and lint-staged.config.js in react-paypal-js * fix package-lock registry value for prettier * fix changesets + prettier --------- Co-authored-by: Hai-Yen Nguyen <[email protected]> Co-authored-by: Shane Brunson <[email protected]>
1 parent f96c7f6 commit 638e8e6

File tree

90 files changed

+608
-1468
lines changed

Some content is hidden

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

90 files changed

+608
-1468
lines changed

.changeset/silver-trees-give.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@paypal/react-paypal-js": patch
3+
"@paypal/paypal-js": patch
4+
---
5+
6+
remove .nvmrc and lint-staged.config.js in react-paypal-js

.changeset/slow-plums-refuse.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@paypal/react-paypal-js": patch
3+
"@paypal/paypal-js": patch
4+
---
5+
6+
remove the prettier dependency from each packages, update the prettier root version, fixed build error, update note version to 18

package-lock.json

Lines changed: 177 additions & 1037 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
]
3030
},
3131
"devDependencies": {
32-
"@changesets/cli": "^2.25.2",
32+
"@changesets/cli": "^2.27.7",
3333
"husky": "^8.0.1",
3434
"lint-staged": "^13.0.3",
35-
"prettier": "^2.7.1"
35+
"prettier": "^3.3.3"
3636
}
3737
}

packages/paypal-js/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ We also provide a legacy build that includes the [promise-polyfill](https://gith
229229
The paypal-js script is also available on the [unpkg CDN](https://unpkg.com/). The iife/paypal-js.js build assigns the `loadScript` function to the window object as `window.paypalLoadScript`. Here's an example:
230230

231231
```html
232-
<!DOCTYPE html>
232+
<!doctype html>
233233
<html lang="en">
234234
<head>
235235
<script src="https://unpkg.com/@paypal/[email protected]/dist/iife/paypal-js.min.js"></script>

packages/paypal-js/bundle-tests/bundle-size.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("bundle size", () => {
1515

1616
test(`paypal-js.legacy.min.js should be less than ${maxLegacyBundleSizeInKiloBytes} KB`, () => {
1717
const { size: sizeInBytes } = fs.statSync(
18-
"dist/iife/paypal-js.legacy.min.js"
18+
"dist/iife/paypal-js.legacy.min.js",
1919
);
2020
const [sizeInKiloBytes] = filesize(sizeInBytes, { output: "array" });
2121

packages/paypal-js/e2e-tests/browser-global.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="UTF-8" />

packages/paypal-js/e2e-tests/browser-global.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ test("Browser global window.paypalLoadScript", async ({ page }) => {
66
route.fulfill({
77
status: 200,
88
body: successfulSDKResponseMock(),
9-
})
9+
}),
1010
);
1111

1212
await page.goto("/e2e-tests/browser-global.html");
1313

1414
await expect(page).toHaveTitle(
15-
"Demo with window.paypalLoadScript | PayPal JS"
15+
"Demo with window.paypalLoadScript | PayPal JS",
1616
);
1717

1818
const scriptElement = await page.locator(
19-
'script[src^="https://www.paypal.com/sdk/js"]'
19+
'script[src^="https://www.paypal.com/sdk/js"]',
2020
);
2121
const uidFromDOM = await scriptElement.getAttribute("data-uid-auto");
2222

packages/paypal-js/e2e-tests/http-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ http.createServer(function (request, response) {
4848
response.end(
4949
"Sorry, check with the site admin for error: " +
5050
error.code +
51-
" ..\n"
51+
" ..\n",
5252
);
5353
}
5454
} else {

packages/paypal-js/e2e-tests/load-cached-script.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="UTF-8" />

packages/paypal-js/e2e-tests/load-cached-script.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test("Load cached script", async ({ page }) => {
66
route.fulfill({
77
status: 200,
88
body: successfulSDKResponseMock(),
9-
})
9+
}),
1010
);
1111

1212
let sdkRequestCounter = 0;

packages/paypal-js/e2e-tests/reload-script.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="UTF-8" />

packages/paypal-js/e2e-tests/validation-errors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="UTF-8" />

packages/paypal-js/e2e-tests/validation-errors.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ test("Validation errors", async ({ page }) => {
66
route.fulfill({
77
status: 400,
88
body: validationErrorSDKResponseMock(),
9-
})
9+
}),
1010
);
1111

1212
await page.goto("/e2e-tests/validation-errors.html");
1313
await expect(page).toHaveTitle("Validation Errors | PayPal JS");
1414
await page.locator("#btn-load-no-client-id").click();
1515

1616
await page.waitForResponse((response) =>
17-
response.url().startsWith("https://www.paypal.com/sdk/js")
17+
response.url().startsWith("https://www.paypal.com/sdk/js"),
1818
);
1919

2020
await page.waitForFunction(
21-
'document.querySelector("#error-message").innerText.length'
21+
'document.querySelector("#error-message").innerText.length',
2222
);
2323

2424
const errorMessage = await page.locator("#error-message").innerText();
2525
expect(errorMessage).toEqual(
26-
'Error: The script "https://www.paypal.com/sdk/js?" failed to load. Check the HTTP status code and response body in DevTools to learn more.'
26+
'Error: The script "https://www.paypal.com/sdk/js?" failed to load. Check the HTTP status code and response body in DevTools to learn more.',
2727
);
2828
});

packages/paypal-js/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"test:e2e": "playwright test",
2020
"test:e2e:debug": "PWDEBUG=1 playwright test --project=\"chromium\"",
2121
"test:e2e:start": "node e2e-tests/http-server.js",
22-
"typecheck": "tsc --noEmit",
23-
"validate": "npm run check-node-version && npm run format:check && npm run typecheck && npm run build && npm run lint && npm test -- --watch=false --coverage.enabled --coverage.include=src && npm run test:bundle -- --watch=false",
22+
"typecheck": "tsc --noEmit --allowSyntheticDefaultImports",
23+
"validate": "npm run check-node-version && npm run typecheck && npm run build && npm run lint && npm test -- --watch=false --coverage.enabled --coverage.include=src && npm run test:bundle -- --watch=false",
2424
"openapi": "npm run openapi-orders && npm run openapi-subscriptions",
2525
"openapi-orders": "openapi-typescript node_modules/@paypal/paypal-rest-api-specifications/openapi/checkout_orders_v2.json -o types/apis/openapi/checkout_orders_v2.d.ts",
2626
"openapi-subscriptions": "openapi-typescript node_modules/@paypal/paypal-rest-api-specifications/openapi/billing_subscriptions_v1.json -o types/apis/openapi/billing_subscriptions_v1.d.ts"
@@ -66,7 +66,6 @@
6666
"jsdom": "^23.0.1",
6767
"lint-staged": "15.2.0",
6868
"openapi-typescript": "^6.7.3",
69-
"prettier": "3.1.1",
7069
"rollup": "4.9.1",
7170
"semver": "7.5.4",
7271
"standard-version": "9.5.0",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Promise from "promise-polyfill";
1+
import * as Promise from "promise-polyfill";
22
import {
33
loadScript as originalLoadScript,
44
loadCustomScript as originalLoadCustomScript,
@@ -7,7 +7,7 @@ import type { PayPalScriptOptions } from "../../types/script-options";
77
import type { PayPalNamespace } from "../../types/index";
88

99
export function loadScript(
10-
options: PayPalScriptOptions
10+
options: PayPalScriptOptions,
1111
): Promise<PayPalNamespace | null> {
1212
return originalLoadScript(options, Promise);
1313
}

packages/paypal-js/src/load-script.node.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import { loadScript, loadCustomScript } from "./load-script";
77
test("should still resolve when global window object does not exist", async () => {
88
await expect(loadScript({ clientId: "test" })).resolves.toBeNull();
99
await expect(
10-
loadCustomScript({ url: "https://www.example.com/index.js" })
10+
loadCustomScript({ url: "https://www.example.com/index.js" }),
1111
).resolves.toBeUndefined();
1212
});

packages/paypal-js/src/load-script.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ vi.mock("./utils", async () => {
1616
const namespace = attributes["data-namespace"] || "paypal";
1717
vi.stubGlobal(namespace, { version: "5" });
1818
process.nextTick(() => onSuccess());
19-
}
19+
},
2020
),
2121
};
2222
});
@@ -38,7 +38,7 @@ describe("loadScript()", () => {
3838

3939
const response = await loadScript({ clientId: "test" });
4040
expect(mockedInsertScriptElement.mock.calls[0][0].url).toEqual(
41-
"https://www.paypal.com/sdk/js?client-id=test"
41+
"https://www.paypal.com/sdk/js?client-id=test",
4242
);
4343
expect(mockedInsertScriptElement).toHaveBeenCalledTimes(1);
4444
expect(response).toEqual(window.paypal);
@@ -53,7 +53,7 @@ describe("loadScript()", () => {
5353
});
5454
expect(mockedInsertScriptElement).toHaveBeenCalledTimes(1);
5555
expect(mockedInsertScriptElement.mock.calls[0][0].url).toEqual(
56-
"https://www.sandbox.paypal.com/sdk/js?client-id=test"
56+
"https://www.sandbox.paypal.com/sdk/js?client-id=test",
5757
);
5858
expect(response).toEqual(window.paypal);
5959
});
@@ -67,7 +67,7 @@ describe("loadScript()", () => {
6767
});
6868
expect(mockedInsertScriptElement).toHaveBeenCalledTimes(1);
6969
expect(mockedInsertScriptElement.mock.calls[0][0].url).toEqual(
70-
"https://www.paypal.com/sdk/js?client-id=test"
70+
"https://www.paypal.com/sdk/js?client-id=test",
7171
);
7272
expect(response).toEqual(window.paypal);
7373
});
@@ -117,7 +117,7 @@ describe("loadScript()", () => {
117117
const { message: errorMessage } = err as Record<string, string>;
118118

119119
expect(errorMessage).toBe(
120-
"The window.paypal global variable is not available."
120+
"The window.paypal global variable is not available.",
121121
);
122122
}
123123
});
@@ -129,9 +129,9 @@ describe("loadScript()", () => {
129129
clientId: "test",
130130
// @ts-expect-error intentionally sending invalid value
131131
environment: "invalid",
132-
})
132+
}),
133133
).toThrowError(
134-
'The `environment` option must be either "production" or "sandbox"'
134+
'The `environment` option must be either "production" or "sandbox"',
135135
);
136136
});
137137

@@ -140,7 +140,7 @@ describe("loadScript()", () => {
140140
expect(() => loadScript()).toThrow("Expected an options object.");
141141
// @ts-expect-error ignore invalid arguments error
142142
expect(() => loadScript({}, {})).toThrow(
143-
"Expected PromisePonyfill to be a function."
143+
"Expected PromisePonyfill to be a function.",
144144
);
145145
});
146146
});
@@ -163,7 +163,7 @@ describe("loadCustomScript()", () => {
163163

164164
await loadCustomScript(options);
165165
expect(mockedInsertScriptElement).toHaveBeenCalledWith(
166-
expect.objectContaining(options)
166+
expect.objectContaining(options),
167167
);
168168
});
169169

@@ -179,16 +179,16 @@ describe("loadCustomScript()", () => {
179179
url: "https://www.example.com/index.js",
180180
// @ts-expect-error ignore invalid arguments error
181181
attributes: "",
182-
})
182+
}),
183183
).toThrow("Expected attributes to be an object.");
184184
expect(() =>
185185
loadCustomScript(
186186
{
187187
url: "https://www.example.com/index.js",
188188
},
189189
// @ts-expect-error ignore invalid arguments error
190-
{}
191-
)
190+
{},
191+
),
192192
).toThrow("Expected PromisePonyfill to be a function.");
193193
});
194194

@@ -209,7 +209,7 @@ describe("loadCustomScript()", () => {
209209
const { message } = err as Record<string, string>;
210210

211211
expect(message).toBe(
212-
'The script "https://www.example.com/index.js" failed to load. Check the HTTP status code and response body in DevTools to learn more.'
212+
'The script "https://www.example.com/index.js" failed to load. Check the HTTP status code and response body in DevTools to learn more.',
213213
);
214214
}
215215
});
@@ -225,7 +225,7 @@ describe("loadCustomScript()", () => {
225225
url: "https://www.example.com/index.js",
226226
},
227227
// @ts-expect-error ignore mock error
228-
PromisePonyfill
228+
PromisePonyfill,
229229
);
230230
expect(PromisePonyfill).toHaveBeenCalledTimes(1);
231231
});

packages/paypal-js/src/load-script.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { PayPalNamespace } from "../types/index";
1111
*/
1212
export function loadScript(
1313
options: PayPalScriptOptions,
14-
PromisePonyfill: PromiseConstructor = Promise
14+
PromisePonyfill: PromiseConstructor = Promise,
1515
): Promise<PayPalNamespace | null> {
1616
validateArguments(options, PromisePonyfill);
1717

@@ -36,7 +36,7 @@ export function loadScript(
3636
url,
3737
attributes: attributes,
3838
},
39-
PromisePonyfill
39+
PromisePonyfill,
4040
).then(() => {
4141
const newWindowNamespace = getPayPalWindowNamespace(namespace);
4242

@@ -45,7 +45,7 @@ export function loadScript(
4545
}
4646

4747
throw new Error(
48-
`The window.${namespace} global variable is not available.`
48+
`The window.${namespace} global variable is not available.`,
4949
);
5050
});
5151
}
@@ -62,7 +62,7 @@ export function loadCustomScript(
6262
url: string;
6363
attributes?: Record<string, string>;
6464
},
65-
PromisePonyfill: PromiseConstructor = Promise
65+
PromisePonyfill: PromiseConstructor = Promise,
6666
): Promise<void> {
6767
validateArguments(options, PromisePonyfill);
6868

@@ -86,7 +86,7 @@ export function loadCustomScript(
8686
onSuccess: () => resolve(),
8787
onError: () => {
8888
const defaultError = new Error(
89-
`The script "${url}" failed to load. Check the HTTP status code and response body in DevTools to learn more.`
89+
`The script "${url}" failed to load. Check the HTTP status code and response body in DevTools to learn more.`,
9090
);
9191

9292
return reject(defaultError);
@@ -112,7 +112,7 @@ function validateArguments(options: unknown, PromisePonyfill?: unknown) {
112112
environment !== "sandbox"
113113
) {
114114
throw new Error(
115-
'The `environment` option must be either "production" or "sandbox".'
115+
'The `environment` option must be either "production" or "sandbox".',
116116
);
117117
}
118118

0 commit comments

Comments
 (0)