Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ’… False positive for useConstΒ #7174

@WandererXII

Description

@WandererXII

Environment information

CLI:
  Version:                      2.1.4
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Rule name

lint/style/useConst

Playground link

https://biomejs.dev/playground/?code=bABlAHQAIABpAG4AdABlAHIAdgBhAGwAOgAgAG4AdQBtAGIAZQByACAAfAAgAHUAbgBkAGUAZgBpAG4AZQBkADsACgAKAGMAbwBuAHMAdAAgAHIAZQBkAHIAYQB3ACAAPQAgACgAKQAgAD0APgAgAHsACgAgACAAYwBsAGUAYQByAEkAbgB0AGUAcgB2AGEAbAAoAGkAbgB0AGUAcgB2AGEAbAApADsACgAgACAAYwBvAG4AcwBvAGwAZQAuAGwAbwBnACgAIgByAGUAZAByAGEAdwAiACkAOwAKAH0AOwAKAHIAZQBkAHIAYQB3ACgAKQA7AAoACgBpAG4AdABlAHIAdgBhAGwAIAA9ACAAcwBlAHQASQBuAHQAZQByAHYAYQBsACgAcgBlAGQAcgBhAHcALAAgADEAMAAwADAAKQA7AA%3D%3D&language=ts

Expected result

let interval: number | undefined;

const redraw = () => {
  clearInterval(interval);
  console.log("redraw");
};
redraw();

interval = setInterval(redraw, 1000);

Minimal example, interval is read before assignment inside a function, yet still marked as warning.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-LinterArea: linterL-JavaScriptLanguage: JavaScript and super languagesS-EnhancementStatus: Improve an existing feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions