solhint

var-name-mixedcase

Recommended Badge Category Badge Default Severity Badge warn

The {“extends”: “solhint:recommended”} property in a configuration file enables this rule.

Description

Variable names must be in mixedCase. (Does not check IMMUTABLES nor CONSTANTS (use inherent rules for that)

Options

This rule accepts an array of options:

Index Description Default Value
0 Rule severity. Must be one of “error”, “warn”, “off”. warn
1 A JSON object with a single property “prefixForImmutables” specifying the prefix to put to consider a variable as kind of immutable to allow it to be in all CAPS. {“prefixForImmutables”:”IMM_”}

Example Config

{
  "rules": {
    "var-name-mixedcase": [
      "warn",
      {
        "prefixForImmutables": "IMM_"
      }
    ]
  }
}

Examples

👍 Examples of correct code for this rule

If config is { prefixForImmutables: “RST_” } and variable is prefixed with that prefix

string public RST_VARIABLE_NAME

If no config is provided and variable is prefixed with default

string public IMM_VARIABLE_NAME

👎 Examples of incorrect code for this rule

If no config is selected and “error” is defined in rule

string public VARIABLE_NAME

If config is { prefixForImmutables: “RST_” } and variable is not prefixed

string public VARIABLE_NAME

If config is { prefixForImmutables: “RST_” } and variable is prefixed with another prefix

string public IMM_VARIABLE_NAME

Version

This rule was introduced in Solhint 2.0.0-alpha.0

Resources