solhint-community

explicit-types

Recommended Badge Category Badge Default Severity Badge warn

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

Description

Enforce explicit types (like uint256) over implicit ones(like uint).

Options

This rule accepts an array of options:

Index Description Default Value
0 Rule severity. Must be one of “error”, “warn”, “off”. warn

Example Config

{
  "rules": {
    "explicit-types": ["warn"]
  }
}

Examples

👍 Examples of correct code for this rule

using a type that explicitly states the variable size

uint256 public variableName

using a type that explicitly states the variable size

fixed128x18 public foo

using a type that explicitly states the variable size

uint256 public variableName = uint256(5)

👎 Examples of incorrect code for this rule

using the shorter alias for a type, which is implicit about its size

uint public variableName

using the shorter alias for a type, which is implicit about its size

fixed public foo

using the shorter alias for a type, which is implicit about its size

uint public variableName = uint(5)

Version

This rule was introduced in Solhint 3.7.0-rc02

Resources