eslint-stylistic / eslint-stylistic

Monorepo for ESLint Stylistic plugins and configs
https://eslint.style
MIT License
1.31k stars 88 forks source link

`imports-first`: force imports statements to be at the beginning #463

Closed Ericlm closed 9 hours ago

Ericlm commented 1 month ago

Clear and concise description of the problem

I want to have all my imports at the same place (top of the script), without having the possibility to declare imports anywhere else in the script.

Suggested solution

In imports-first or import-top, we could detect each import statement and force it to be at the top of the file. That would also allow rules like sort imports to work better with a single imports "block".

Alternative

Additional context

Validations

Contributes

9romise commented 1 month ago

Maybe you can use eslint-plugin-import-x. https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/first.md https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/exports-last.md

Ericlm commented 1 month ago

Thank you for your suggestions, it looks promising! I'll still leave this issue open I think, like it's more a "stylistic" preference 🤔