# 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.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

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

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

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
let status;

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

Not reported:

{/* good */}
```js
let status;

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

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

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

{/* good */}
```ts
declare let version: string;

console.log(version);
```
