Giter VIP home page Giter VIP logo

lint-unused's Introduction

DEPRECATION NOTICE

elm-lint has been deprecated in favor of elm-review. To work with elm-review, this package has been republished under the name review-unused.

lint-unused

Provides elm-lint rules to detect unused functions and types in your Elm files.

Provided rules

Note

Since elm-lint only works in the scope of a single file, these rules will not report elements that are exposed but not used anywhere in the project. If you wish those to be reported, check out elm-xref.

Example configuration

module LintConfig exposing (config)

import Lint.Rule exposing (Rule)
import NoUnused.Variables
import NoUnused.CustomTypeConstructors

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

lint-unused's People

Contributors

jfmengels avatar

Watchers

James Cloos avatar  avatar  avatar

lint-unused's Issues

NoUnused.Variables: Report recursive functions

Currently, NoUnused.Variables does not report functions that call themselves, even if they are never used elsewhere

module A exposing (a)

a = 1

foo list =
  case list of
    [] -> 1
    _ :: rest -> 1 + foo rest

Here, we would like foo to be reported, since no other functions uses it and it's not exposed.

NoUnused.Variables: Report unused pattern declarations

NoUnused.Variables does not report pattern variables. This means that in the following example, b will not get reported.

foo =
  let
    (a, b) = bar
  in
  a

This is on purpose because there can be value in giving b a name.

The improvement here, would be to report the whole pattern, when none of the pattern variables are used.

foo =
  let
    (a, b) = bar
    ^^^^^^
  in
  1

This is valid for other types of patterns obviously, like {a, b}.

New rule: NoUnused.ImportedConstructors

This rule would report unused imported custom type constructors.

For instance:

import A exposing (B(..))

where none of B's constructors are used in the file.

This could be autofixed by removing the (..) part.

This requires additional work in the elm-lint package to load the Elm interface files, so that we know what the constructors of B are.

New Rule: NoUnused.TypeConstructorParameters

This rule would report unused parameters in custom type constructors.

For instance:

type MyType
  = A
  | B String

where B's String parameter is always ignored (B _ -> ...) or just not used (B notUsed -> ...).

B "" ->, B Nothing ->, etc. should make B's argument considered.

A has no parameters, and should thus not be reported.

Having MyType's constructors exposed should ignore reporting B.

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.