Skip to content

Parsing error: 'return' outside of function #459

@robertsosinski

Description

@robertsosinski

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.16.0

What version of eslint-plugin-astro are you using?

1.3.1

What did you do?

Reopening issue #389 as I am seeing this again.

When using return in an .astro file, I am getting the error:

Parsing error: 'return' outside of function eslint

eslint.config.js

import pluginAstro from 'eslint-plugin-astro';

export default [
  ...pluginAstro.configs.recommended,
];
---
return Astro.redirect('/path/here');
---

<h1>My Page</h1>

See screen snip below:

Screenshot 2024-12-05 140144

What did you expect to happen?

Not to show this as an error, as I need to return in the astro frontmatter to do things such as Astro.redirect.

What actually happened?

See above, eslint is showing a appropriate return as an error.

Link to Minimal Reproducible Example

See above.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions