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

imports-first rule enforces import order, import/order is expected to do that #520

Closed
sompylasar opened this issue Aug 24, 2016 · 8 comments
Labels

Comments

@sompylasar
Copy link
Contributor

I get a warning from import/imports-first rule:

import/imports-first Absolute imports should come before relative imports. at line 14 col 8

According to ESLint's single responsibility principle, this should be enforced by a separate rule, which is import/order.

@sompylasar
Copy link
Contributor Author

From the docs, there is an option absolute-first, but there is no documentation how to disable it.

From the code that checks the rule options, I found a way I'd like to share if someone is confused by the same warning:

"import/imports-first": [ "warn", "DISABLE-absolute-first" ],

@benmosher benmosher added this to the 2.0.0 milestone Aug 24, 2016
@benmosher
Copy link
Member

IIRC I already removed/disabled it in v2 branch, but I can't find the issue.

If I didn't, I think I will. or at least make absolute-first default to disabled.

@HenriBeck
Copy link

Similar to #512

@benmosher
Copy link
Member

Ah, so, discovery: https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js#L97

It's not on by default, but the (ever increasingly ubiquitous) AirBnB config turns it on.

I'm closing, as this is technically already true and is a consequence of that config (I'm assuming).

@benmosher benmosher removed this from the 2.0.0 milestone Sep 1, 2016
@sompylasar
Copy link
Contributor Author

@benmosher The issue is that the import/imports-first enforces an order within the import statements, though there is a different rule for that specific purpose, so I suppose import/imports-first should not do more than it should: verify that all the import statements are at the top, regardless of the order relative to one another.

@benmosher
Copy link
Member

I'm not disagreeing with you, though I think I will keep the functionality for backwards compatibility. It predates import/order by quite a bit, and I have no way of knowing what kind of usage it has.

If I were to write the rule today, I wouldn't include it, but such is life. 😄

@sompylasar
Copy link
Contributor Author

@benmosher Okay.

@xyzdata
Copy link

xyzdata commented Jun 22, 2017

import first always!

http://eslint.org/docs/rules/sort-imports

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

No branches or pull requests

4 participants