At the moment, if you have no imports, you cannot comment the top most function of your file. That comment will be pulled to the top of the file.
Example:
module Bla exposing (..)
-- I want to add a comment here
type alias Bla =
{ }
but elm format will make this
module Bla exposing (..)
-- I want to add a comment here
type alias Bla =
{ }
If it's a doc-comment, {-| -}, it makes sense to pull it to the top because it only makes sense to have doc comments above functions if you have a doc-comment in the module as well. But it doesn't make sense to be pulling -- and {- -} to the top of the file. We should be able to comment the top most function of our files even if we have no imports.
To elaborate, there seems to be a few more issues with the top comment. For example if I do have imports, then my first comment can be a doc-comment, but it can only be a doc-comment.
module Bla exposing (..)
import X
{-| Allowed
-}
type alias Bla =
{ }
But both of these will be reformatted:
module Bla exposing (..)
import X
-- This comment will be pushed up upon formatting
type alias Bla =
{ }
module Bla exposing (..)
import X
{- This comment will be pushed up upon formatting -}
type alias Bla =
{ }
This is a case where elm-format is making the behavior of elm-make/elm-compiler more clear: If a module has no imports, you cannot have a doc comment on the first definition unless you also have a doc comment for the module before it--this is due to the behavior of elm-make and how it parses documentation. elm-format adjusts the spacing to make it more obvious how elm-make will interpret your doc comments.
Most helpful comment
This is a case where elm-format is making the behavior of elm-make/elm-compiler more clear: If a module has no imports, you cannot have a doc comment on the first definition unless you also have a doc comment for the module before it--this is due to the behavior of elm-make and how it parses documentation. elm-format adjusts the spacing to make it more obvious how elm-make will interpret your doc comments.