Skip to content

tolbrino/arcanist-elixir-support

Repository files navigation

Arcanist Elixir Support

This is an extension for Arcanist to provide support for linting and unit testing Elixir code.

Installation

These installation instruction were borrowed and adapted from clang-format-linter.

arcanist can load modules from an absolute path. But there is one more trick - it also searches for modules in a directory up one level from itself.

It means that you can clone this repository to the same directory where arcanist and libphutil are located. In the end it should look like this:

> ls
arcanist
arcanist-elixir-support
libphutil

General Requirements

  • Erlang/OTP 18.1 - an older version might work as well, but hasn't been tested
  • Elixir 1.1.1 - an older version might work as well, but hasn't been tested
  • Mix - used for running linting and unit testing

Linting Setup

Pre Elixir v1.6.0

You must use this version to get support for Elixir prior to v1.6.0.

In order to be able to run arc lint you need to use the Elixir linting library dogma. It needs to be installed as part of your dependencies of your Mix project in mix.exs:

{:dogma, github: "lpil/dogma", ref: "586ee29", only: [:dev, :test]}

Then you need to sync your dependencies by executing: mix do deps.get, deps.update, compile

Finally you need to tell Arcanist which files it should lint by adding a snippet like the following to your .arclint:

{
  "linters": {
    "elixir": {
      "type": "elixirdogma",
      "include": [
        "(\\.ex[s]?$)"
      ],
      "exclude": [
        "(^deps/)"
      ]
    }
  }
}

Now you can run arc lint.

Post Elixir v1.6.0

You must use a version after this version to get support for Elixir v1.6.0 and later.

You need to tell Arcanist which files it should lint by adding a snippet like the following to your .arclint:

{
  "linters": {
    "elixir": {
      "type": "elixir",
      "include": [
        "(\\.ex[s]?$)"
      ],
      "exclude": [
        "(^deps/)"
      ]
    }
  }
}

Now you can run arc lint.

Unit Testing Setup

The unit testing supports uses the ExUnit library which comes with Elixir out-of-the-box. However, an additional library is needed to generate proper XML report files which can be consumed by Arcanist. Therefore, you need to add junit_formatter to your project dependencies in mix.exs:

{:junit_formatter, "~> 1.3.0", only: :test}

To enable the XML report generation you need to configure ExUnit just before you actually start it within your test suite:

ExUnit.configure formatters: [JUnitFormatter, ExUnit.CLIFormatter]
ExUnit.start

Then you need to sync your dependencies by executing: mix do deps.get, deps.update, compile

Finally you need to tell Arcanist which files it should test by adding a snippet like the following to your .arcunit:

{
  "engines": {
    "exunit": {
      "type": "exunit",
      "include": [
        "(^test/.+_test\\.ex[s]?$)"
      ],
      "exclude": [
        "(^deps/)"
      ]
    }
  }
}

Now you can run arc unit.

About

Linter and unit testing engines for Arcanist

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages