Eslint-plugin-import: `imports-first` rule enforces import order, `import/order` is expected to do that

Created on 24 Aug 2016  路  8Comments  路  Source: benmosher/eslint-plugin-import

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.

invalid

Most helpful comment

All 8 comments

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" ],

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.

Similar to #512

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 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.

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. 馃槃

@benmosher Okay.

Was this page helpful?
0 / 5 - 0 ratings