Giter Club home page Giter Club logo

elm-review-ports's Introduction

elm-review-ports

elm package elm-review 2.6 elm 0.19 Tests

Provides elm-review rules to detect errant elm ports.

Provided rules

Configuration

import NoDuplicatePorts
import NoUnsafePorts
import NoUnusedPorts
import Review.Rule exposing (Rule)


config : List Rule
config =
    [ NoDuplicatePorts.rule
    , NoUnsafePorts.rule NoUnsafePorts.any
    , NoUnusedPorts.rule
    ]

Try it out

You can try the example configuration above out by running the following command:

elm-review --template sparksp/elm-review-ports/example

elm-review-ports's People

Contributors

dependabot[bot] avatar sparksp avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

elm-review-ports's Issues

Inconsistent behaviour when aliasing Encode/Decode Import

I usually import the Json.Decode module as D and the Json.Encode module as E.
Regardless if that is a good idea or not, i was surprised to see that E.Value was analysed to be a safe port value, while D.Value was not. Moreover, Json.Decode.Value works fine.

The reason seems to be additional imported modules using the same alias (in this case: "D")

Expected behaviour:

import Json.Decode as D
import Json.Decode.Pipeline as D

port portName: (D.Value -> msg) -> Sub msg

should not result in any errors.

Rule that detects unused ports

I think it would be useful to have a rule that checks whether a port is unused. This can crash people's applications, and is also a common problem that beginners run into but do not understand.

If this gets added, I think the package's documentation (in the README and in the elm.json at least) should change to say it's a general review package for rules, one way or another.

Thanks for making this package ❤️

NoUnusedPorts erroring incorrectly

Hi, I'm experiencing false positives from the NoUnusedPorts rule and was curious whether it is a known issue.

I'm thinking that the biggest contributing factors are either that I'm using elm-spa and the code path to a main function is therefore quite complex and includes the page it is referenced in being in a record, and the main function accessing it through a key in a record, or maybe because I don't explicitly use the port in a subscription call, but wrap it in a helper function. I'm thinking the most likely is the first one though.

Let me know if it's not a known issue and you'd like me to spend more time narrowing down the cause of the false positive

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.