Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Proposal: exports-last #620

Closed
k15a opened this issue Oct 11, 2016 · 8 comments
Closed

Rule Proposal: exports-last #620

k15a opened this issue Oct 11, 2016 · 8 comments

Comments

@k15a
Copy link
Contributor

k15a commented Oct 11, 2016

I would like to propose a new rule which enforces that all export statements are at the end of the file.

Why?

I really like to keep all my exports at the end of the file so I can quickly scan what a file exports.

@jfmengels
Copy link
Collaborator

jfmengels commented Oct 11, 2016

Sounds good to me.
With commonjs, I have the same preference. I don't necessarily have it for ES6 modules at the moment, but this makes sense to me to have this rule.

@k15a Would you be interested in working on this if it gets accepted? :)

@k15a
Copy link
Contributor Author

k15a commented Oct 12, 2016

I am interested but I tried working on another issue 2 times and failed hard so it's not a guarantee for success 😆

@benmosher
Copy link
Member

Sounds like a reasonable style guide rule to me. 👍

@sevor005
Copy link

sevor005 commented Apr 6, 2021

Good afternoon! The question is: can I cancel the rule (put it in ignor) for classes that are exported at the beginning of the file export default class SomeClass, followed by defaultProps and PropTypes?

@ljharb
Copy link
Member

ljharb commented Apr 6, 2021

no. Class fields exists, define them inside the class body.

@RodrigoNovais
Copy link

Good afternoon! The question is: can I cancel the rule (put it in ignor) for classes that are exported at the beginning of the file export default class SomeClass, followed by defaultProps and PropTypes?

This would be reasonable for storybook csf files, since templating would require exports to be mixed within the file
It's not a big deal to disable the rule on every stories file but would be nice to be able to handle it in the eslint config

@ljharb
Copy link
Member

ljharb commented Dec 10, 2022

@RodrigoNovais you can use overrides to disable them on every story file at once, in the config.

@RodrigoNovais
Copy link

Didn't know that's possible, thank you @ljharb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants