---
url: /docs/guide/usage/linter/rules/eslint/no-unassigned-vars.md
---

### What it does

Disallow let or var variables that are read but never assigned.

#### Ignored Files

This rule ignores `.svelte` and `.vue` files entirely. Oxlint only parses the
`<script>` blocks of these files, so a binding that the template assigns looks
like it is never assigned. In Svelte the template writes through
`bind:this={el}` and `bind:value={x}`; in Vue a `<script setup>` `let` is a
`setup-let` binding that `v-model="x"` and inline handlers such as
`@click="x = 1"` assign to directly.

### Why is this bad?

This rule flags let or var declarations that are never assigned a value but are still read or used in the code.
Since these variables will always be `undefined`, their usage is likely a programming mistake.

### Examples

Examples of **incorrect** code for this rule:

```js
let status;
if (status === "ready") {
  console.log("Ready!");
}
```

Examples of **correct** code for this rule:

```js
let message = "hello";
console.log(message);

let user;
user = getUser();
console.log(user.name);
```

## How to use

## Version

This rule was added in v1.10.0.

## References
