Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use camelCase instead of kebab-case for params (breaking change!) #375

Merged
merged 1 commit into from Jun 1, 2023

Conversation

gregjopa
Copy link
Contributor

@gregjopa gregjopa commented May 30, 2023

This PR makes a breaking interface change for the types for the loadScript(PayPalScriptOptions) loader function. It changes the PayPalScriptOptions interface to use camelCase instead of kebab-case.

I think this would improve the developer experience since JS devs are familiar to camelCase for all the things. Note that we would still pass query params and data attributes as kebab-case under the hood but would hide this from the public interface.

The TypeScript types have been updated to use camelCase format for PayPalScriptOptions and follow this Google JS Style Guide for naming conventions for acronyms.
https://google.github.io/styleguide/jsguide.html#naming-camel-case-defined

Before

loadScript({ 
  "client-id": "test", 
  "merchant-id": ["123", "456", "789"] 
});

After

loadScript({ 
  clientId: "test", 
  merchantId: ["123", "456", "789"] 
});

src/load-script.test.ts Outdated Show resolved Hide resolved
BREAKING CHANGE: this is a breaking change for the TypeScript types.
@gregjopa gregjopa marked this pull request as ready for review May 31, 2023 21:45
@gregjopa gregjopa requested a review from a team as a code owner May 31, 2023 21:45
@gregjopa gregjopa changed the title featuse camelCase instead of kebab-case for params Use camelCase instead of kebab-case for params (breaking change!) May 31, 2023
@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (ec977f1) 100.00% compared to head (77b4e4c) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #375   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          138       128   -10     
  Branches        39        36    -3     
=========================================
- Hits           138       128   -10     
Impacted Files Coverage Δ
src/utils.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@ravishekhar ravishekhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍


if (key.substring(0, 5) === "data-") {
if (key.substring(0, 4) === "data") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Though I feel its a micro optimization; should we use startsWith() instead of substring()

Perf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good call out. Normally I would prefer startsWith() but I think that feature was added to JS in ES6. Right now, paypal-js transpiles to ES5 and has bundle-size checks to keep the library as small as possible.

@gregjopa gregjopa merged commit f73df41 into main Jun 1, 2023
4 checks passed
@gregjopa gregjopa deleted the camelCaseScriptOptions branch June 1, 2023 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants