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

fix: do not crash with comment before method in store #1629

Merged
merged 6 commits into from
Nov 6, 2024

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Nov 5, 2024

Description

https://builder-io.atlassian.net/browse/ENG-7332

This PR fixes an issue where comments before a method in state would cause Mitosis to crash.

Given:

useStore({
  foo: true, // comment
  bar() {}
})

The comment would get pushed to its own line and become part of the bar node:

// comment
bar() {}

The expression handling fallback would then try to do something like this:

let _ = // comment
bar() {}

which is not a valid expression and would crash.

My PR fixes the issue by ensuring that the only the method code is used and any auxiliary data such as comments are removed from parsing.

Make sure to follow the PR preparation steps in CONTRIBUTING.md before submitting your PR:

  • format the codebase: from the root, run yarn fmt:prettier.
  • update all snapshots (in core & CLI): from the root, run yarn test:update
  • add Changeset entry: from the root, run yarn g:changeset and follow the CLI instructions. Alternatively, use the Changeset Github Bot to create the file.

Copy link

changeset-bot bot commented Nov 5, 2024

🦋 Changeset detected

Latest commit: cf7eadd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@builder.io/mitosis Patch
@builder.io/mitosis-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

nx-cloud bot commented Nov 5, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit cf7eadd. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

@liamdebeasi liamdebeasi changed the title Eng 7332 fix: do not crash with comment before method in store Nov 5, 2024
@liamdebeasi liamdebeasi marked this pull request as ready for review November 5, 2024 16:50
Copy link
Contributor

@samijaber samijaber left a comment

Choose a reason for hiding this comment

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

oh nice, this has been driving many people nuts!

@samijaber samijaber merged commit 697c307 into BuilderIO:main Nov 6, 2024
8 checks passed
@liamdebeasi liamdebeasi deleted the ENG-7332 branch November 6, 2024 17:48
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.

2 participants