> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# vars-on-top

[Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'vars-on-top': 'error',
    },
  },
]);
```

The `vars-on-top` rule requires `var` declarations to appear before executable
statements in the program or in a function body. Directive strings and imports
may appear before the declarations. Declarations inside nested blocks and loop
headers are reported; declarations at the start of a class static block are
also allowed.

## Rule Details

Examples of **incorrect** code:

```js
function example() {
  doSomething();
  var value = 1;
}
```

Examples of **correct** code:

```js
function example() {
  "use strict";
  var value = 1;
  doSomething(value);
}
```

## Differences from ESLint

rslint applies the same rule behavior to JavaScript and TypeScript syntax. As
with ESLint, the rule has no options and reports the complete declaration.
