Skip to content

Releases: avh4/elm-format

0.5.1-alpha

14 Nov 21:44
0.5.1-alpha
Compare
Choose a tag to compare
0.5.1-alpha Pre-release
Pre-release

Bug fixes:

  • Whne upgrading ranges to List.range, parentheses are correctly added if the range is used as a function call argument
  • Correctly space top-level declarations that use pattern destructuring

0.5.0-alpha

14 Nov 07:36
0.5.0-alpha
Compare
Choose a tag to compare
0.5.0-alpha Pre-release
Pre-release

Support for Elm 0.18:

  • Added the --upgrade option to help migration code from Elm 0.17 to Elm 0.18
    • Infix function calls using backticks become normal functions calls
    • Infix function calls using backticks with andThen and onError become pipelines
    • Ranges become calls to List.range
    • Primes in variable names become underscores
    • References to fst and snd become Tuple.first and Tuple.second

Bug fixes:

  • Type tags starting with True and False are now handled correctly

0.4.0-alpha

03 Jul 20:03
0.4.0-alpha
Compare
Choose a tag to compare
0.4.0-alpha Pre-release
Pre-release

elm-format-0.4.0-alpha was announced on elm-dev.

elm-format-0.4.0-alpha is now available: https://github.com/avh4/elm-format#installation-

There are three significant syntax changes from 0.3.*-alpha:

  • multiline expressions with long infix operators now indent in a more appropriate way
  • The <| operator is now handled specially and is placed at the end of the preceding line
  • line breaks are now allowed before the first arguments to functions

Other changes:

  • #186 console output is less verbose
  • #199 files are not touched if they are already formatted
  • #191 elm-format binaries are smaller
  • #184 qualified type constructors in pattern match arguments are now handled correctly w/r to elm-compiler 0.17

What's next:

  • correctly handle -- comments at the end of lines
  • allow blank lines in lists and records
  • release a beta version and announce to elm-discuss

Thanks this release to a new contributor, @gyzerok, who helped update the CLI, including a feature that makes elm-format usable in JetBrains IDEs (#199).

That's it for the release! I have also started writing some guidelines for "elm-format approved" plugins and IDEs. If you are interested in that, read on:

"elm-format approved" plugins

This is a draft of guidelines for IDEs and IDE plugins that want to officially integrate with elm-format.

Discussion is here: https://github.com/avh4/elm-format/issues/104

The goal of elm-format is to make it as easy as possible to follow a standard, consistent style so that everyone can get the benefit of code that is easier to write, easier to read, and easier to maintain.

An "elm-format approved" plugin does the following:

  • Formatting
    • When formatting a file, if the in-memory version of the file and the on-disk version of the file differ, then the plugin should format the in-memory version of the file. (Saving the file before formatting is also acceptable.)
    • When formatting a file, the cursor position and scroll position should be maintained.
      • Currently recommended: save the cursor index into the buffer before formatting, and set the cursor to the same index after formatting
      • Future: elm-format will provide additional information for translating cursor positions (see #149)
  • Format on save
    • The default behavior should be to format any *.elm files on save when working on an Elm project if elm-format is found.
    • If linting or compilation is also triggered on save, elm-format should be run before linting or compiling.
  • Configuration
    • If the path to elm-format has not be explicitly specified by the user, the plugin should automatically find elm-format if it is located on the $PATH or in /usr/local/bin/.

      Is there an equivalent of /usr/local/bin/ for Windows?

    • If elm-format is not found, a message should be shown including a link to the elm-format installation instructions ( https://github.com/avh4/elm-format#installation- ). The message will be shown on the plugin settings screen if such a screen exists, and any time the user explicitly tries to format a file. The message may also be shown when the plugin is first installed or when saving an elm file.

  • Error handling

An "elm-format approved" IDE comes with an "elm-format approved" plugin installed and enabled, or otherwise provides all the features of an "elm-format approved" plugin.

0.3.1-alpha

20 May 04:16
0.3.1-alpha
Compare
Choose a tag to compare
0.3.1-alpha Pre-release
Pre-release

This is a bug fix release.

Changelog

  • BUG: Fixed formatting of the following code (in 0.3.0-alpha it would format to invalid syntax) #179

    import Dict as D
        exposing
            ( empty
            , fromList
            )
    

0.3.0-alpha

11 May 07:50
0.3.0-alpha
Compare
Choose a tag to compare
0.3.0-alpha Pre-release
Pre-release

elm-format-0.3.0-alpha was announced on elm-dev

There are a lot of details to this release, so I'll start out with thanks to everyone who reported issues; to our new and continuing contributors @ento, @danyx23, @eeue56, and @mgold; and to the plugin maintainers @rundis, @benjick, @ajhager, and @Bogdanp.

And if you're in a hurry, here's the link: elm-format-0.3.0-alpha downloads and installation instructions

Elm 0.17 and 0.16 support

There are now two flavors of elm-format in each release: one for Elm 0.17, and one for Elm 0.16. You should download the one that corresponds to the version of Elm you are using.

But note that these two flavors are the same except that they have different default values for the new --elm-version argument. Downloading the correct flavor will make things easier for you, since your IDE plugins will work properly, but if you pass the --elm-version argument to elm-format, both flavors will behave identically. (This works because elm-format can parse both 0.17 and 0.16 files and can output either format regardless of which format the input was in.)

New features

  • You can migrate your Elm 0.16 code to the 0.17 syntax simply by using the 0.17 flavor of elm-format
  • You can validate the formatting of files with elm-format --validate (useful for CI scripts)

Changes and fixes

  • 4-space indentation (see the next section)
  • The first argument in function application is allowed to stay on the same line even if subsequent arguments break the line
  • Decimal float and hexadecimal int literals are preserved
  • The filename and line number is shown when reporting parse errors
  • Added a workaround for an elm-compiler bug with escaping UTF-8 characters on Windows
  • Newlines in function types are properly handled
  • The commenting "trick" of having {--} and --} scattered around your file is not directly supported
  • Fixes for comments
    • The contents of block comments does not indent itself further every time you format
    • Nested block comments are preserved
    • =-- parses correctly
  • top-level declarations are now spaced properly in (hopefully all) cases
  • All places = and : appear in the syntax are now formatted consistently

more details

4-space indentation

We've had several discussions of indentation width in the past, but the rationale for trying 4-space indentation again is here: https://gist.github.com/avh4/bc092cc2207230d044f73defdd46fd13

elm-format has been in alpha for a long time all ready, so apologies for drawing out this issue and making another significant change. If you have strong opinions in favor of 2-space indentation, I do want to hear them, but I would appreciate if you would first spend a few minutes considering 1) why you have those opinions, and 2) how you would convince someone holding an opposing indentation opinion.

Next up

If you have trouble installing elm-format to work with your editor, please file an issue or make a pull request to the elm-format README.

I'm hoping the next elm-format release will be beta-quality and ready to announce on elm-discuss. Thanks for all the feedback!

development snapshot for Elm-0.17 release candidate

09 May 00:44
Compare
Choose a tag to compare

You only want this if you are trying out the Elm-Platform-0.17 release candidate. If you are using Elm-0.16, you want elm-format-0.2.0-alpha instead.

0.3.0-alpha-elm017rc1-rc1 was a pre-0.3.0-alpha release that works with Elm-0.17-rc1 and was announced on the elm-dev mailing list

Regarding the new syntax for the module statement, this version of elm-format will automatically migrate 0.16 files to the 0.17 format.

Please report any 0.17-specific elm-format issues here to elm-dev, and not to the github issue tracker.

In addition, expect the next elm-format alpha release shortly after the public Elm 0.17 release.

0.2.0-alpha

30 Jan 06:17
Compare
Choose a tag to compare
0.2.0-alpha Pre-release
Pre-release

0.2.0-alpha was announced on the elm-dev mailing list

After the tedious work of making the AST retain comments, elm-format-0.2-alpha is ready! Most notable is the switch to 2-space indentation, as previously discussed on elm-dev. There are also now plugins for LightTable, Emacs, and Vim thanks to @rundis, @Bogdanp, and @ajhager!

You can find the downloads and editor integration instructions here:

Here's a brief list of changes:

  • changed to 2-space indentation
  • comments are handled everywhere they can appear
  • fixed a unicode problem with console output on Windows
  • parentheses in pattern matches are handled correctly, including a workaround for elm/compiler#951
  • triple double quotes in multiline strings are handled correctly
  • more than one file or directory can be given on the command line
  • added the --stdin command line option to support IDE plugins

Thanks to everyone who helped improve the documentation and to the following for contributing code to this release:

0.1-alpha2

08 Dec 08:10
Compare
Choose a tag to compare
0.1-alpha2 Pre-release
Pre-release

0.1-alpha2 was announced on the elm-dev mailing list

Hello all! Prompted by Richard and Evan a couple months ago, I (with help from Martin and Noah) have been working on elm-format, a source code formatter for Elm inspired by gofmt. There are still a few unhandled cases in the far reaches of the syntax space, but elm-format is now ready for use and feedback.

The goal for elm-format is to make it easy to follow a standard style for Elm code. The standard style is based on the Elm Style Guide, which aims to be easy to read, produce clean diffs, and encourage well-factored code.

You can find the downloads and editor integration instructions here (this is the first time I've packaged binaries for multiple platforms, so if you have any problems running it, please let me know):

If you are excited about this kind of tool, please try it out and let me know if anything goes amiss! I have a few more bugs to fix before announcing it more publicly on elm-discuss, and I wanted to give you all a chance to look it over before then.