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

💅 False negative `noUnusedVariables` in Astro file #2863

Closed 1v3n closed 5 months ago

1v3n commented 5 months ago

Environment information

Hey,

inside an Astro file I get an false noUnusedVariables error.

My biome setup for that:


"rules": {
  "recommended": true,
  "correctness": {
    "noUnusedVariables": "error"
  }
}

index.astro

---
const { title } = Astro.props;
---

<span>{title}</span>

Causes

 ✖ This variable is unused.

  > 2 │ const { title } = Astro.props;
      │         ^^^^^
    3 │ 

  ℹ Unused variables usually are result of incomplete refactoring, typos and other source of bugs.

Rule name

noUnusedVariables

Playground link

https://codesandbox.io/p/devbox/biome-bug-lkjq3m

Expected result

I would not expect an error, as the variable is used In the JSX part of the Astro file.

Code of Conduct

1v3n commented 5 months ago

Biome doesn't fully support Astro files, therefore I needed to set this:

 "globals": ["Astro"]

--> Source

motss commented 1 month ago

@1v3n what do you set this?

 "globals": ["Astro"]
ematipico commented 1 month ago

@1v3n what do you set this?

 "globals": ["Astro"]

javascript.globals: https://biomejs.dev/reference/configuration/#javascriptglobals