sparksp / elm-review-ports / NoDuplicatePorts

rule : Review.Rule.Rule

Forbid duplicate port names in your project.

config : List Rule
config =
    [ NoDuplicatePorts.rule
    ]

Why is this a problem?

The only way to tell which port you want to address in JavaScript is by its name, and so these must be unique within your project. When there are multiple ports with the same name you may encounter a JavaScript runtime error.

It is common practice to have a single Ports module to contain all of the ports in a project. The Ports module can then be imported anywhere that needs access to a port.

When (not) to use this rule

Ports are not allowed in Elm packages - you should not enable this when developing an Elm package.

Try it out

You can try this rule out by running the following command:

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