npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jfmengels/elm-lint

v1.0.0-beta.6

Published

Run elm-lint from Node.js

Downloads

3

Readme

DEPRECATION NOTICE

elm-lint has been deprecated in favor of elm-review. You can find the CLI for elm-review at https://www.npmjs.com/package/elm-review, and install it using npm install elm-review.

elm-lint CLI

Run elm-lint from Node.js.

WARNING: This project is still under construction. The CLI for the latest version of elm-lint has not been released yet, and will not work.

elm-lint reporter output

Installation

# Save it to your package.json, if you use npm in your project.
# This is the recommended way.
npm install @jfmengels/elm-lint --save-dev

# Install globally. This is not recommended.
npm install -g @jfmengels/elm-lint

Note: Not to be confused with the elm-lint package, which has no relationship to this project.

Usage

elm-lint --help  # Print the help
elm-lint init    # Creates an empty lint configuration
elm-lint         # Lint your project

Configuration

To run elm-lint for the first time, you need to run

elm-lint init
elm-lint init --help # for more information and the available flags

This will create a lint/ directory containing an elm.json and a LintConfig.elm file, which you should commit into your project. Here is what it may look like:

module LintConfig exposing (config)

import Lint.Rule exposing Rule
import NoDebug
import NoUnused.Variables


config : List Rule
config =
    [ NoDebug.rule
    , NoUnused.Variables.rule
    ]

elm-lint does not come with any built-in rules. You can read why here. You can find rules in the Elm package registry by using elm-search and searching for Lint.Rule.Rule, and use by going to your lint directory and running elm install in your terminal.

cd lint/ # Go inside your lint configuration directory
elm install authorName/packageName

Run linting

Once you're done configuring, run elm-lint to analyze your project.

You can also run elm-lint --fix. The CLI will present you fixes for the errors that offer an automatic fix, which you can then accept or not. When there are no more fixable errors left, elm-lint will report the remaining errors as if it was called without --fix. Fixed errors will be reformatted using elm-format.

Run elm-lint --help for more information on the available flags.

elm-lint # Analyze your project
elm-lint --fix # Analyze your project and potentially proposes automatic fixes
elm-lint --help # for more information and the available flags

Which parts of the project will be analyzed?

elm-lint targets a project, and therefore requires an elm.json. It will lint all the files of the project

  • For packages: all the Elm files in src/
  • For applications: all the Elm files in the project's elm.json's source-directories

If you wish to also lint your tests directory or the lint configuration itself, then you should specify all the directories you want to be looked at.

elm-lint src/ tests/ lint/

Exit status

If any rule from your configuration reports a pattern in one of the analyzed files, the process will exit with status 1. Otherwise, it will exit with status 0.

If the process fails at some point, it will exit with status 1.

Why is there a need for a lint directory?

When the CLI uses looks at your configuration, it is in practice compiling an application using the configuration in your project, then running that application to analyze your project.

The CLI need at least two pieces of information from your configuration:

  • An elm.json file to know the external packages your configuration depends upon
  • A LintConfig.elm file that determines your configuration.

Your custom rules, unless you want to share them in the Elm package registry, should be in the lint/ directory too, so as not to pollute your main project's dependencies. If they are in here, we need to include these custom rules and their dependencies in the application files.