facebook / facebook/jscodeshift
templates evaluate at global scope, breaks statement`return;`
Open
discussion
improvement
- Dominant language
- JavaScript
- Stars
- 10k
- Forks
- 498
- PR merge metrics
- No merged PRs in 30d
Description
Return statements can only be added inside a function but templates are evaluated by babel at the global scope so babel throws on
```
statement`return;`
```
Example: http://felix-kling.de/esprima_ast_explorer/#/1lLYuPcGmT
This also happens for `break;` statements as well.
@fkling had an idea of always evaluating templates within a function but that could break things like `import` that can only be added at the global scope. Not sure what the way forward is here but i find the templating extremely valuable so it would be great to find a solution!
Contributor guide
Assessment
This issue has not been assessed yet.