-
Notifications
You must be signed in to change notification settings - Fork 13
Remove absolute first from import/first #61
Conversation
Removing `absolute-first` field from import/first as the order of the imports does not matter. What matters is avoiding any weird knowledge issues when putting code between the imports since imports are hoisted. This also unlocks a nice organizational feature for React components where you group your imports ``` // Components - External ... // Components - Internal import {Button} from '../button'; // Utiltiies import * as moment from 'moment'; ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, we will discuss within the team.
My thoughts: Even with this rule you still have grouping, just a different kind. You declare all of your node_module imports above, which is a good thing, and typically the first place people look for such imports.
For rules that don't really matter like this one, I would opt to err on the side of consistency.
The grouping has a functional purpose though (putting code between two imports may not get executed in the order you expect). Forcing the absolute imports to be first doesn't actually gain you any benefit. Further if the argument is consistency why not use import/sort instead which is far more consistent and actually would reduce merge conflicts as the order of the imports is always the same. That said, I would sort based on path ordering, not import specifier ordering personally as the line import itself wont jump around as much. |
Agree about import/order. Filed this issue to look into it: #62 |
Seems that whichever way you go, looks like you're up for removing absolute from import/first so mind stamping this? |
We'll discuss this with the team. In the meantime you could use |
We've decided as a team that we want to go with eslint:recommended as well as type checking, only keeping linting rules which help prevent bugs. Because this does not prevent bugs, we'll go ahead and accept this PR. Thanks for your contribution. |
!merge |
Removing
absolute-first
field from import/first as the order of the imports does not matter. What matters is avoiding any weird knowledge issues when putting code between the imports since imports are hoisted.This also unlocks a nice organizational feature for React components where you group your imports