import-js / import-js/eslint-plugin-import

Add newline before `exports-last`

Open
#2,880 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Hello, I will be glad if you consider adding a new feature to [import/exports-last](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/exports-last.md):

### Add option to [import/exports-last](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/exports-last.md), to enforce a specific number of newlines **before the first** `export` keyword.

Similarly to an option implemented in [import/newline-after-import](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/newline-after-import.md), I wish to have 2 blank lines before the **first** `export` section.

---

For example, when `count` is `2`:

#### Valid:
```js
import { groups } from '../../db';
import { errors } from '../../errors';

const getGroupById = (id)=> {
if (!Object.keys(groups).includes(id)) {
throw new errors.NotExistsError({
message: `The group id '${id}' not found`
});
}
return groups[id];
};

export { getGroupById };

```

#### Invalid:
```js
import { groups } from '../../db';
import { errors } from '../../errors';

const getGroupById = (id)=> {
if (!Object.keys(groups).includes(id)) {
throw new errors.NotExistsError({
message: `The group id '${id}' not found`
});
}
return groups[id];
};

export { getGroupById };

```
```js
import { groups } from '../../db';
import { errors } from '../../errors';

const getGroupById = (id)=> {
if (!Object.keys(groups).includes(id)) {
throw new errors.NotExistsError({
message: `The group id '${id}' not found`
});
}
return groups[id];
};

export { getGroupById };

```

Thank you!

Contributor guide

Open the contributing guide

Research direction

Start with docs/rules/exports-last.md and compare its option documentation with docs/rules/newline-after-import.md. Then locate the exports-last rule entry point and its tests, and verify that a configurable count enforces the requested blank lines before the first export without affecting other exports.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.