Solhint mostly follows the official solidity style guide, but where they contradict one another, we conform to Solhint. For more information on how to install and run the Solhint linter, please see the README.
Follow the Official Solidity Style Guide
Solhint doesn't check for all style violations. Where it doesn't, we follow the official solidity style guide. For example, Solhint doesn't care about exactly how hanging indents are done. The solidity style guide indicates that they should all have one more indent than the first line. We follow the solidity style guide and use a single hanging indent.
Enums/Structs that will be used within the contract should be declared prior to everything.
All variables should be declared immediately following the enums/structs. Variables should be sorted by visibility like
functions (see the Functions
section for details). Instead of sorting alphabetically within visibility groups,
however, related variables should be grouped together.
Functions should follow variable declarations. Solhint enforces that functions are ordered by:
- Constructor
- External
- Public
- Internal
- Private
In addition to this ordering by function privacy, within each of these 5 groups there are additional rules:
- All abstract functions should precede all concrete functions.
- Within the abstract/concrete groups, view/pure functions should come after other functions (in that order).
- Sort each group of functions (e.g. external abstract, external abstract view...) alphabetically.
- If two functions share a name, alphabetically order by the arguments (both type and name).
TODO