-
Notifications
You must be signed in to change notification settings - Fork 31
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 BUG: Parsing error: 'return' outside of function. #326
Comments
Hello, this error is coming from ESLint, not Prettier. The Prettier plugin is able to format this snippet with no errors. I suspect that this is a similar issue to #315, where the ESLint plugin does not pass the correct information to the Prettier plugin, or something similar. Please create an issue on the ESLint plugin: https://github.com/ota-meshi/eslint-plugin-astro |
Hmm, weird, this successfully format for me 馃 I'll investigate more! |
Tried a bunch of things, including your link and I cannot reproduce, sorry |
Gosh.. Maybe it's just my problem. I feel guilty for wasting your time 馃槗 I'll close this issue. Contact you again after I find a solution. Thanks a lot! |
No worries, I'm paid by the hour 馃槃 |
Sorry to re-open this but I was having the same issue. I've narrowed it down to an interaction between Astro and @trivago/prettier-plugin-sort-imports. It seems like there was an issue filed with prettier-plugin-sort-imports but no progress has been made trivago/prettier-plugin-sort-imports#210 I don't know enough about Prettier to understand if this is an issue entirely in prettier-plugin-sort-imports or in an interaction with it and prettier-plugin-astro. |
mind creating an https://astro.new reproduction? |
https://stackblitz.com/edit/github-pjbsr1?file=src/pages/index.astro This is based on the "Just the basics" template. All I've done is run If you run |
Awesome! Thx a lot! |
Thanks for the reproduction, I'll re-open this issue as I can reproduce the bug myself with the stackblitz link 馃憤 |
I am not too sure what the solution can be.. Parsing a top level return always results in an error, it's a design flaw of Astro to have one at the top level (there's a reason other frameworks "throw" their returns, as weird as it looks). We could fix this in our parser, maybe, but then other plugins would need to be after our parser but before our printer which is wonky in Prettier |
If Astro wants to deprecate Otherwise it seems like |
Describe the Bug
when I write this in astro
Prettier give me an error that I cannot format (eslint just for showing prettier's error):
Steps to Reproduce
https://github.com/jsun969/jsundotlol/blob/c901168568b93fd5e7038e1699948bb288869287/src/pages/blog/%5Bslug%5D.astro#L10-L13
The text was updated successfully, but these errors were encountered: