import-js / import-js/eslint-plugin-import
Add newline before `exports-last`
- 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
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