#11945·biome

`noInvalidUseBeforeDeclaration` misses class declaration heritage, static members and computed keys

Author: AlbinoGeekCreated Sep 24, 2026Updated Sep 30, 2026
LabelsA-LinterL-JavaScriptS-Bug-confirmed

Environment information

bash
CLI:
  Version:                      2.5.14

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_DISTRIBUTION:           npm
  JS_RUNTIME_NAME:              node

Rule name

correctness/noInvalidUseBeforeDeclaration

Playground link

https://biomejs.dev/playground/?lintRules=noInvalidUseBeforeDeclaration#files.noInvalidUseBeforeDeclaration.js=ZQB4AHAAbwByAHQAIABmAHUAbgBjAHQAaQBvAG4AIAByAHUAbgAoACkAIAB7AAoAIAAgAGMAbABhAHMAcwAgAEEAIABlAHgAdABlAG4AZABzACAAQgAgAHsAfQAgAC8ALwAgAFIAZQBmAGUAcgBlAG4AYwBlAEUAcgByAG8AcgAgAGEAdAAgAHIAdQBuAHQAaQBtAGUALAAgAG4AbwB0ACAAcgBlAHAAbwByAHQAZQBkAAoAIAAgAGMAbABhAHMAcwAgAEMAIAB7ACAAcwB0AGEAdABpAGMAIABwACAAPQAgAEIAOwAgAH0AIAAvAC8AIABuAG8AdAAgAHIAZQBwAG8AcgB0AGUAZAAKACAAIABjAGwAYQBzAHMAIABEACAAewAgAFsAQgAuAG4AYQBtAGUAXQAoACkAIAB7AH0AIAB9ACAALwAvACAAbgBvAHQAIAByAGUAcABvAHIAdABlAGQACgAgACAAYwBsAGEAcwBzACAARQAgAHsAIABzAHQAYQB0AGkAYwAgAHsAIABCADsAIAB9ACAAfQAgAC8ALwAgAG4AbwB0ACAAcgBlAHAAbwByAHQAZQBkAAoAIAAgAGMAbwBuAHMAdAAgAGUAIAA9ACAAbgBlAHcAIABCACgAKQA7ACAALwAvACAAcgBlAHAAbwByAHQAZQBkAAoAIAAgAGMAbABhAHMAcwAgAEIAIAB7AH0ACgAgACAAcgBlAHQAdQByAG4AIABbAEEALAAgAEMALAAgAEQALAAgAEUALAAgAGUAXQA7AAoAfQAKAA%3D%3D

javascript
export function run() {
  class A extends B {} // ReferenceError at runtime, not reported
  class C { static p = B; } // not reported
  class D { [B.name]() {} } // not reported
  class E { static { B; } } // not reported
  const e = new B(); // reported
  class B {}
  return [A, C, D, E, e];
}

Only new B() is reported. The other four references are evaluated when the class declaration runs, before B is initialized, and each throws ReferenceError: Cannot access 'B' before initialization in Node. ESLint's no-use-before-define reports class A extends B {}.

The same references in a class expression (const A = class extends B {}) are reported, so this is specific to declarations. It looks like it came from #8157 (the fix for #8148). That PR treats the whole JsClassDeclaration and JsStaticInitializationBlockClassMember as running later, which is only true for method, accessor and constructor bodies and for instance field initializers.

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

Expected result

References in extends, computed member names, static field initializers, static blocks and decorators of a class declaration are reported like any other eager use. Instance fields and member bodies stay exempt, as fixed in #8148.

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.