sparksp / elm-review-camelcase / UseCamelCase

rule : Config -> Review.Rule.Rule

Report any variables, constants, and other declarations that are using the wrong case style.

config : List Rule
config =
    [ UseCamelCase.rule UseCamelCase.default
    ]

When (not) to use this rule

This rule will report any deviation from camelCase or PascalCase (as appropriate). Read the notes below and make sure that you and your team are 100% happy to adopt this for your codebase!

Implementation Notes

Camel Case

Variable and constant names must be formatted in camelCase, such that each word in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. This includes all variables, function names and arguments, and port names.

Pascal Case

Module and type names must be formatted in PascalCase, such that each word of the phrase begins with a capital letter, with no intervening spaces or punctuation.

Unknown suggestion

If the converter fails to parse a term it will suggest "Unknown" as the replacement. We're confident that this will not happen, so if you encounter this please report an issue on GitHub so we can take a look.

Configuration


type Config

Configuration for the UseCamelCase rule.

default : Config

Default configuration that will suit most people.

config : List Rule
config =
    [ UseCamelCase.rule UseCamelCase.default
    ]

Ignoring specific files

You can ignore the errors reported for specific files. Use this when you don't want to review generated source code or files from external sources that you copied over to your project and don't want to be touched.

config : List Rule
config =
    [ UseCamelCase.rule UseCamelCase.default
        |> Rule.ignoreErrorsForFiles [ "src/TW.elm" ]
    ]

There are more examples of configuring exceptions in the elm-review documentation.

withCamel : (String -> String) -> Config -> Config

If you do not like the provided camelCase rules you can supply your own.

config : List Rule
config =
    [ UseCamelCase.rule
        (UseCamelCase.default
            |> UseCamelCase.withCamel customToCamel
        )
    ]

withPascal : (String -> String) -> Config -> Config

If you do not like the provided PascalCase rules you can supply your own.

config : List Rule
config =
    [ UseCamelCase.rule
        (UseCamelCase.default
            |> UseCamelCase.withPascal customToPascal
        )
    ]