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

# first

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


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

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/first': 'error',
    },
  },
]);
```

## Rule Details

Ensures all import statements appear before other statements in a module. Since imports are hoisted, interleaving them with other code can be confusing.

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

```javascript
import { x } from './foo';
export { x };
import { y } from './bar';
```

```javascript
var a = 1;
import { y } from './bar';
```

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

```javascript
import { x } from './foo';
import { y } from './bar';
export { x, y };
```

## Options

### `absolute-first`

When set to `"absolute-first"`, this rule enforces that absolute (package) imports appear before relative imports.

Examples of **incorrect** code with `"absolute-first"`:

```javascript
import { x } from './foo';
import { y } from 'bar';
```

Examples of **correct** code with `"absolute-first"`:

```javascript
import { y } from 'bar';
import { x } from './foo';
```

## Original Documentation

- [eslint-plugin-import: first](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/first.md)
- [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/first.js)
