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
]
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!
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.
model_
model___
=> model_
hasAThing
toHTML
person1
address_1stLine
=> address1StLine
(note the St
)one_two3four_five
=> oneTwo3FourFive
(note the Four
)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.
HasAThing
ToHTML
CONSTANT_CASE
=> ConstantCase
TO_HTML
=> ToHtml
Person1
Person_1
=> Person1
Address_1stLine
=> Address1StLine
(note the St
)One_Two3four_Five
=> OneTwo3FourFive
(note the Four
)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 for the UseCamelCase rule.
default : Config
Default configuration that will suit most people.
config : List Rule
config =
[ UseCamelCase.rule UseCamelCase.default
]
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
)
]