Code Monkey home page Code Monkey logo

exfmt's Introduction

Circle CI Hex version API Docs Licence

exfmt ๐ŸŒธ

exfmt formats Elixir source code according to a standard set of rules. It is inspired by Aaron VonderHaar's elm-format.

# exfmt takes any Elixir code...

defmodule MyApp, do: (
    use( SomeLib )
    def run( data ), do: {
      :ok,
      data
   }
)

# and rewrites it in a clean and idiomatic style:

defmodule MyApp do
  use SomeLib

  def run(data) do
    {:ok, data}
  end
end

The benefits of exfmt:

  • It makes code easier to write, because you never have to worry about minor formatting concerns while powering out new code.
  • It makes code easier to read, because there are no longer distracting minor stylistic differences between different code bases. As such, your brain can map more efficiently from source to mental model.
  • It makes code easier to maintain, because you can no longer have diffs related only to formatting; every diff necessarily involves a material change.
  • It saves your team time debating how to format things, because there is a standard tool that formats everything the same way.
  • It saves you time because you don't have to nitpick over formatting details of your code.

exfmt is still in alpha. If you run into any problems, please report them.

The format produced by exfmt may change significantly before the 1.0.0 release. If this will cause problems for you, please refrain from using exfmt during the alpha- and beta-test periods.

Contents

Usage

To install exfmt as a command-line utility, run:

mix escript.install github lpil/exfmt

You can then run exfmt like so: (the default max line width is 80 characters)

exfmt --max-width 100 file.ex file2.exs

which will rewrite the files, formatted. If there is any kind of error in the process, exfmt will abort and leave your existing files as-is.

You can also include exfmt as a mix dependency and use the Elixir API directly.

Development

exfmt is an open project, contributions are very much welcomed. If you have feedback or have found a bug, please open an issue. If you wish to make a code contribution please open a pull request, though for larger code changes it may be good to open an issue first so we can work out the best way to move forward.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

# Install the deps
mix deps.get

# Run the tests
mix test

# Run the tests when files change
mix test.watch

exfmt's People

Contributors

ericentin avatar lpil avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.