rule : Config -> Review.Rule.Rule
Ensure consistent use of import aliases throughout your project.
config : List Rule
config =
[ NoInconsistentAliases.config
[ ( "Html.Attributes", "Attr" )
]
|> NoInconsistentAliases.rule
]
config : List ( String, String ) -> Config
Provide a list of preferred names to be enforced. If we find any of the given modules imported with a different alias we will report them.
NoInconsistentAliases.config
[ ( "Html.Attributes", "Attr" )
, ( "Json.Decode", "Decode" )
, ( "Json.Encode", "Encode" )
]
|> NoInconsistentAliases.rule
noMissingAliases : Config -> Config
Ensure that imports are aliased if a module is used to qualify a function or type, and has a known alias.
NoInconsistentAliases.config
[ ( "Html.Attributes", "Attr" )
]
|> NoInconsistentAliases.noMissingAliases
|> NoInconsistentAliases.rule
Here Html.Attributes
has been used to call class
and the preferred alias has not been used.
import Html.Attributes
view children =
div [ Html.Attributes.class "container" ] children
Here Html.Attributes
has been aliased to Attr
as expected.
import Html.Attributes as Attr
view children =
div [ Attr.class "container" ] children
Here class
has been exposed so the alias is not needed.
import Html.Attributes exposing (class)
view children =
div [ class "container" ] children
Config
Configuration for the NoInconsistentAliases rule.