imports-order
Description
Order the imports of the contract to follow a certain hierarchy (read “Notes section”)
Options
This rule accepts a string option of rule severity. Must be one of “error”, “warn”, “off”. Default to warn.
Example Config
{
"rules": {
"imports-order": "warn"
}
}
Notes
- Paths starting with “@” like “@openzeppelin/” and urls (“http” and “https”) will go first
- Order by hierarchy of directories first, e.g. ./../../ comes before ./../, which comes before ./, which comes before ./foo
- Direct imports come before relative imports
- Order alphabetically for each path at the same level, e.g. ./contract/Zbar.sol comes before ./interface/Ifoo.sol
- Rule does NOT support this kind of import “import * as Alias from “./filename.sol”
- When “–fix”, rule will re-write this notation “../folder/file.sol” or this one “../file.sol” to “./../folder/file.sol” or this one “./../file.sol”
Examples
This rule does not have examples.
Version
This rule was introduced in Solhint 5.0.2
Resources