-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Side-effecting imports should be treated as a special case #505
Comments
Interesting. I would expect anything for this to end up in the Gut reaction is conflicting; I think it makes sense to separate+group side-effect imports, but it also adds a decent amount of complexity to add it as a dimension to the |
Refs #520 |
Note: not just imports without variable binding like Example 1: export + implicit side-effect
Example 2: chained import + indirect side-effects
|
FWIW, I am assuming you're not suggesting we inspect the module content for side effects. The most I would expect from the |
@benmosher The |
By side-effecting imports, I mean when you import something just for its side effects, without assigning a variable. (Not sure what the correct term is.)
For example:
Side-effecting imports do things like reading config files and setting up the environment (in ways that might impact the way other modules initialise), so it usually makes sense for them to go first, regardless of whether they're absolute/relative. But the
imports-first
rule doesn't consider this, and complains about the above snippet, saying "Absolute imports should come before relative imports."I think it would make sense for the
imports-first
rule to make an exception for side-effecting imports.(Sorry if this already exists as an option and I'm just missing it.)
The text was updated successfully, but these errors were encountered: