biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
14.96k stars 465 forks source link

🐛 Astro dynamic redirects fail `biome(parse)` #2232

Closed AdoryVo closed 6 months ago

AdoryVo commented 6 months ago

Environment information

CLI:
  Version:                      1.6.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v20.10.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/8.15.5"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

  1. Add an Astro dynamic redirect to a .astro file. This involves adding return Astro.redirect('/url') to your Astro component script.
  2. Observe "Illegal return statement outside of a function" from biome(parse) in syntax highlighting as well as biome check output. See Biome playground snippet and picture.

image

Expected result

The return statement is legal in Astro files, as shown in the Astro docs, so an error should not be thrown.

Code of Conduct

erguotou520 commented 6 months ago

How to disable this rule?

Sec-ant commented 6 months ago

How to disable this rule?

This is a parser error so it cannot be disabled. This issue should be fixed in #2273.