linter-elm-make

Lint Elm code with elm-make

mybuddymichael

58,564

38

0.29.0

MIT

GitHub

This package provides the following services:

linter-elm-make

https://atom.io/packages/linter-elm-make

Lint your Elm files in Atom with linter and elm-make.

diffs

Installation

  1. Install Elm.
  2. Install linter, language-elm, and linter-elm-make from the Settings view (Edit > Preferences > Install) or by running these from the command line:
apm install linter
apm install language-elm
apm install linter-elm-make
  1. Run which elm-make (Unix/Linux) or where.exe elm-make (Windows) from the command line and set the result as your executable path in this installed package's configuration.

Configuration

Lint On The Fly

By default, linting is only done after saving the file. If you want to lint while typing, turn on the Lint On The Fly option in the package settings. Also make sure that the Lint on Change option (Lint As You Type for Linter v1) is enabled in the linter package settings.

NOTE: Linting on the fly is experimental and currently works by copying the source files to the Work Directory (or to a temporary directory if Work Directory is blank) and running elm-make there.

lint-on-fly

Always Compile Main

If enabled, the main file(s) will always be compiled instead of the active file. The main files can be set using Linter Elm Make: Set Main Paths. If not set, the linter will look for Main.elm files in the source directories. Take note that if this is enabled, modules unreachable from the main modules will not be linted. Disabled by default.

Report Warnings

Show elm-make warnings. Enabled by default.

Show Inferred Type Annotations

Note: This will only work if Report Warnings is also checked.

show-inferred-type-annotations

show-inferred-type-annotations-2

Use Datatips

This is an experimental feature that uses Datatips instead of the Diagnostics UI (from Nuclide or atom-ide-ui) to show the issues. This also enables integration with the elmjutsu package.

use-datatips

Work Directory

If this option is not blank, a file watcher will watch the project directory for source file changes and synchronize those with the work directory.

IMPORTANT WARNING: If the current work directory is inside the project directory and you want to change the value of Work Directory in the settings, delete the current work directory first! Else, the linter will consider that directory as part of your project!

If this option makes no sense and/or is confusing, just leave it blank. 😃

Commands

Linter Elm Make: Quick Fix

Move your cursor to a problematic text range and invoke this command to show the possible fixes. Select a fix from the list to apply it to your code.

quick-fix

quick-fix-intentions

quick-fix-diagnostics

The number of available fixes for a given cursor position is shown with the linter tooltip and in the status bar.

Linter Elm Make: Quick Fix All

Fixes all issues in the active text editor in one go. If there is more than one fix for an issue, it will choose the first from the list.

Linter Elm Make: Set Main Paths

Sets the main paths of the project and saves them to linter-elm-make.json.

Example:

{
  "mainPaths": ["Todo.elm", "Test.elm"]
}

The main paths are only relevant if Always Compile Main is enabled. See above.

Linter Elm Make: Clear Project Build Artifacts

Deletes the .elmi and .elmo files in your project's build artifacts directory (e.g. elm-stuff/build-artifacts/0.17.0/user/project/1.0.0). This is useful after toggling Lint On The Fly and/or Always Compile Main to prevent confusing lint results. If using a work directory or temporary directory, the artifact files of that directory will also be deleted.

Linter Elm Make: Toggle Lint On The Fly

Linter Elm Make: Toggle Always Compile Main

Linter Elm Make: Toggle Report Warnings

Keybindings

Here is an example:

'atom-text-editor:not([mini])[data-grammar^="source elm"]':
  'shift-f6': 'linter-elm-make:quick-fix-all'

  # Add this to use the default UI:
  'f6': 'linter-elm-make:quick-fix'

  # Add this instead if you want to use the Intentions UI:
  'f6': 'intentions:show'

  # Add this instead if you want to use `atom-ide-ui`:
  'f6': 'diagnostics:show-actions-at-position'

'.linter-elm-make atom-text-editor[mini]':
    'f6': 'core:confirm'

Add them to your keymap.cson or bind them from Settings > Keybindings.

Useful linter Commands

Linter: Lint

Linter v2:

Linter v1:

Notes