jfmengels / elm-review-common / NoMissingTypeExpose

rule : Review.Rule.Rule

Reports types that should be exposed but are not.

🔧 Running with --fix will automatically fix all the reported errors.

If a type is not exposed then it can be impossible to annotate functions or values that use them outside of the module. Affected types may be used in exposed function signatures, type aliases or other custom types.

import NoMissingTypeExpose

config : List Rule
config =
    [ NoMissingTypeExpose.rule
    ]

Fail

module Happiness exposing (happy, toString)

-- Type `Happiness` is private because it's not been exposed

type Happiness
    = Happy

-- Private type `Happiness` used by exposed function `toString`
toString : Happiness -> String
toString happiness =
    "Happy"

-- Private type `Happiness` used by exposed value `happy`
happy : Happiness
happy =
    Happy

Success

module Happiness exposing (Happiness, happy, toString)

type Happiness
    = Happy

toString : Happiness -> String
toString happiness =
    "Happy"

happy : Happiness
happy =
    Happy

Try it out

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

elm-review --template jfmengels/elm-review-common/example --rules NoMissingTypeExpose