avh4 / elm-format

elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide
BSD 3-Clause "New" or "Revised" License
1.31k stars 145 forks source link

elm-format reorganises imports across comment boundaries #594

Open jmbromley opened 5 years ago

jmbromley commented 5 years ago

I like to be able to split my imports into core libraries, external dependencies (i.e. from elm packages), and internal (i.e. unpublished) dependencies. For example:

module MyModule exposing (MyStuff, view)

import Array exposing (Array)
import Browser.Dom
import Json.Decode
import Task

-- EXTERNAL DEPS

import Element exposing (Element)

-- LOCAL DEPS

import MyThing exposing (Thing(..))
import MyOtherModule

-- MODEL

...

However with the latest changes to elm-format (specifically the ordering of imports and removal of duplicates) this is no longer possible, as elm-format reorders all my import alphabetically and places them before the dividing comment lines, leaving the comments 'dangling' at the end.

Would it be possible to not reorder imports across comment lines, to enable people to group their imports into meaningful sections? Or would this break something?

Drenmi commented 5 years ago

I was quite surprised to see that elm-format mixed my own imports in together with those from the standard library. It seems like what @jmbromley is suggesting would give some power back to the user. (Although I recognize that's not always desirable.)