Skip to content

💅 noUnusedVariables misses an arrow function that only references itself #11950

Description

@AlbinoGeek

Environment information

Details
CLI:
  Version:                      2.5.14

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_DISTRIBUTION:           npm
  JS_RUNTIME_NAME:              node

Rule name

correctness/noUnusedVariables

Playground link

https://biomejs.dev/playground/?lintRules=noUnusedVariables#files.noUnusedVariables.js=ZQB4AHAAbwByAHQAIABmAHUAbgBjAHQAaQBvAG4AIABmACgAKQAgAHsACgAgACAAZgB1AG4AYwB0AGkAbwBuACAAZwAoACkAIAB7ACAAcgBlAHQAdQByAG4AIABnACgAKQA7ACAAfQAgAC8ALwAgAHIAZQBwAG8AcgB0AGUAZAAKACAAIABsAGUAdAAgAGgAIAA9ACAAKAApACAAPQA%2BACAAaAAoACkAOwAgAC8ALwAgAG4AbwB0ACAAcgBlAHAAbwByAHQAZQBkAAoAIAAgAGMAbwBuAHMAdAAgAGsAIAA9ACAAZgB1AG4AYwB0AGkAbwBuACAAKAApACAAewAgAHIAZQB0AHUAcgBuACAAawAoACkAOwAgAH0AOwAgAC8ALwAgAHIAZQBwAG8AcgB0AGUAZAAKAH0ACgA%3D

export function f() {
  function g() { return g(); } // reported
  let h = () => h(); // not reported
  const k = function () { return k(); }; // reported
}

A function declaration or function expression that is only referenced from its own body is reported as unused, but the same pattern with an arrow function is not. ESLint's no-unused-vars reports all three.

Reproduced with the 2.5.14 CLI and in the playground (f74eb38).

Expected result

h is reported as unused, like g and k.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Tool Use Disclaimer: Claude Code using Anthropic Opus 5.5 helped build the reproduction.

Activity

  1. AlbinoGeek commented on Sep 25, 2026

    @AlbinoGeek
    ContributorAuthor

    These last 6 came specifically from projects I just updated from typescript-eslint lol.

  2. dyc3 commented on Sep 25, 2026

    @dyc3
    Contributor

    How can k possibly be considered used if its only referenced by itself?

  3. added theissue type on Sep 25, 2026
  4. added
    A-Linter
    L-JavaScript
    S-Needs triage
    on Sep 25, 2026
  5. AlbinoGeek commented on Sep 25, 2026

    @AlbinoGeek
    ContributorAuthor

    How can k possibly be considered used if its only referenced by itself?

    This is yet another example of a pattern used in game modding more than standalone applications. When we inject via Proxy into another class, then replace its functions and __proto__, we end up with ugly code like this, where we've replaced one of its methods (for example, a recursive method); but from the outside, there would be no way to know whether we were or were not referenced.

    This happens in FlowerLoader for example, where we inject over the game's MAIN class via Proxy, then have to override main.g creations via __proto__ and constructor, (g being the game loop in that engine); which then calls itself every update.

    It's... again, I would easily accept this as "not biome's problem, out of scope" if it doesn't have an obvious solution.

  6. dyc3 commented on Sep 25, 2026

    @dyc3
    Contributor

    Oh I misread this. If eslint catches all of these and we don't thats definitely a bug.

  7. added
    S-Bug-confirmed
    and removed
    S-Needs triage
    on Sep 25, 2026
  8. self-assigned this
    on Sep 25, 2026
  9. AlbinoGeek commented on Sep 25, 2026

    @AlbinoGeek
    ContributorAuthor

    Oh I misread this. If eslint catches all of these and we don't thats definitely a bug.

    Yeah, I tried to make sure and test typescript-eslint behaviour for each of the newest issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LinterL-JavaScriptS-Bug-confirmed

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions