---
url: /docs/guide/usage/linter/rules/import/newline-after-import.md
---

### What it does

Enforces having one or more empty lines after the last top-level import statement or require call.

### Why is this bad?

Without a blank line, import/require declarations blend into the following logic,
which hurts readability and makes changes harder to scan. A blank line clearly
separates dependencies from implementation.

### Examples

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

```js
import * as foo from "foo";
const FOO = "BAR";
```

```js
import * as foo from "foo";
const FOO = "BAR";

import { bar } from "bar-lib";
```

```js
const FOO = require("./foo");
const BAZ = 1;
const BAR = require("./bar");
```

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

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

```js
import defaultExport from "./foo";
import { bar } from "bar-lib";

const FOO = "BAR";
```

```js
const FOO = require("./foo");
const BAR = require("./bar");

const BAZ = 1;
```

With count set to 2 this will be considered valid:

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

With count set to 2 these will be considered invalid:

```js
import defaultExport from "./foo";
const FOO = "BAR";
```

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

With count set to 2 and exactCount set to true this will be considered valid:

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

With count set to 2 and exactCount set to true these will be considered invalid:

```js
import defaultExport from "./foo";
const FOO = "BAR";
```

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

```js
import defaultExport from "./foo";

const FOO = "BAR";
```

With considerComments set to false this will be considered valid:

```js
import defaultExport from "./foo";
// some comment here.
const FOO = "BAR";
```

With considerComments set to true this will be considered valid:

```js
import defaultExport from "./foo";

// some comment here.
const FOO = "BAR";
```

With considerComments set to true this will be considered invalid:

```js
import defaultExport from "./foo";
// some comment here.
const FOO = "BAR";
```

### Example options usage

```json
{
  "rules": {
    "import/newline-after-import": ["error", { "count": 1 }]
  }
}
```

## Configuration

This rule accepts a configuration object with the following properties:

### considerComments

type: `boolean`

default: `false`

### count

type: `integer`

default: `1`

### exactCount

type: `boolean`

default: `false`

## How to use

## Version

This rule was added in v1.66.0.

## References
