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

The user's code should be transformed alongside the injected code #47646

Open
ojeytonwilliams opened this issue Sep 28, 2022 · 4 comments
Open
Labels
help wanted Open for all. You do not need permission to work on these. platform: learn UI side of the client application that needs familiarity with React, Gatsby etc.

Comments

@ojeytonwilliams
Copy link
Contributor

ojeytonwilliams commented Sep 28, 2022

Since the head, contents and tail are evaluated together, they should be Babelified together.

Mostly this is not a problem, but there are edge cases where it breaks. For example https://github.com/freeCodeCamp/freeCodeCamp/blob/237f11be8b777be582e9cfc8d73a3fef907aefa2/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person.md tries to reassign a const. This should not be allowed, but no errors are thrown because Babel only adds an error when it detects reassignment, but it cannot because Babel evaluates the tail separately from the contents.

@ojeytonwilliams ojeytonwilliams added the platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. label Sep 28, 2022
@scissorsneedfoodtoo scissorsneedfoodtoo added status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. bookmark Start next issue triage meeting here labels Dec 21, 2022
@raisedadead raisedadead added help wanted Open for all. You do not need permission to work on these. and removed bookmark Start next issue triage meeting here status: discussing Under discussion threads. Closed as stale after 60 days of inactivity. labels Jan 4, 2023
@raisedadead
Copy link
Member

Anyone willing to work on this should:

  • look into transpiling the user code alongside the seed and any other setup code we have
  • look into getting the tests to evaluate this final transpiled code

As a helpful note babel is already available in the browser. See us in the contributors' chat if you need more help or guidance.

@raisedadead
Copy link
Member

@ojeytonwilliams could you help us with a sample challenge to help test the solution when its ready?

@shuaib128
Copy link

@raisedadead is the bug still open? Or the bug has been closed?

@ojeytonwilliams
Copy link
Contributor Author

It's still an issue, though it's not a serious one. The problem is that https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person isn't entirely valid JavaScript, when you take into account the code we append to the learner's. It tries to reassign a const, which should fail, but does not.

In this particular challenge, it's fine, it just illustrates that the code is not be evaluated as you would expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Open for all. You do not need permission to work on these. platform: learn UI side of the client application that needs familiarity with React, Gatsby etc.
Projects
None yet
Development

No branches or pull requests

4 participants