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

chore(remix-react): make inline scripts more robust #1331

Merged
merged 3 commits into from Feb 15, 2022

Conversation

valin4tor
Copy link
Contributor

@valin4tor valin4tor commented Jan 3, 2022

For inline scripts, instead of directly injecting JavaScript using a template literal:

  • Write a function with the desired code, using params for external values
  • Convert this function to a string using Function.prototype.toString()
  • Inject the resulting string, and call the function with the required values

This provides the following benefits for inline scripts:

  • Problem checking with ESLint
  • Type checking with TypeScript
  • Consistent formatting with Prettier
  • Consistent baseline indentation

I haven't added or changed any tests since this isn't strictly a bug fix or new feature.

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 3, 2022

Hi @valerie-makes,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 3, 2022

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@valin4tor valin4tor changed the title Refactor: Make inline scripts more robust chore(remix-react): make inline scripts more robust Jan 16, 2022
@ryanflorence
Copy link
Member

Love it, sorry for taking so long to get to this PR. Do you mind rebasing with dev and doing it again? Both inline scripts have changed since 😭

@valin4tor
Copy link
Contributor Author

@ryanflorence I've rebased with the new script changes 🙂

@ryanflorence
Copy link
Member

Heh, our tests here are a little funny, I'll fix them.

@ryanflorence ryanflorence merged commit 7860169 into remix-run:dev Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants