Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

no-unassigned-vars

Disallow let and var variables that are read but never assigned

A let or var that's declared without a value and never assigned is undefined everywhere you read it. Usually someone forgot the assignment, or a refactor removed it.

no-unused-vars handles variables that are never read.

This rule is on by default.

Configure

On by default as a warning. To turn it off:

bunfig.toml
[lint.rules]
"no-unassigned-vars" = "off" # or "error"

Examples

Reported:

let status;

if (status === "ready") {
  start();
}

Not reported:

let status;

if (isReady()) {
  status = "ready";
}

if (status === "ready") {
  start();
}

In TypeScript, declare says that the value comes from somewhere else:

declare let version: string;

console.log(version);