solhint

private-vars-leading-underscore

Category Badge Default Severity Badge warn

Description

Non-external functions and state variables should start with a single underscore. Others, shouldn’t

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 “strict” specifying if the rule should apply to ALL non state variables. Default: { strict: false }. {“strict”:false}

Example Config

{
  "rules": {
    "private-vars-leading-underscore": ["warn",{"strict":false}]
  }
}

Notes

Examples

👍 Examples of correct code for this rule

Internal function with correct naming

function _thisIsInternal() internal {}

Private function with correct naming

function _thisIsPrivate() private {}

Internal state variable with correct naming

uint256 internal _thisIsInternalVariable;

Internal state variable with correct naming (no visibility is considered internal)

uint256 _thisIsInternalVariable;

👎 Examples of incorrect code for this rule

Internal function with incorrect naming

function thisIsInternal() internal {}

Private function with incorrect naming

function thisIsPrivate() private {}

Internal state variable with incorrect naming

uint256 internal thisIsInternalVariable;

Internal state variable with incorrect naming (no visibility is considered internal)

uint256 thisIsInternalVariable;

Version

This rule was introduced in Solhint 3.0.0-rc.3

Resources