@slippy-lint/slippy
Version:
A simple but powerful linter for Solidity
41 lines (28 loc) • 915 B
Markdown
Enforces a specific order for functions and state variable modifiers.
The enforced order for functions is:
1. Visibility modifiers (`public`, `private`, `internal`, `external`)
2. State mutability modifiers (`pure`, `view`, `payable`)
3. The `virtual` modifier
4. The `override` modifier
5. Custom modifiers
The enforced order for state variables is:
1. Visibility modifiers (`public`, `private`, `internal`)
2. Storage location (`constant`, `immutable`, `transient`)
Examples of **correct** code for this rule:
```solidity
contract Example {
uint public constant x = 1;
function f() public pure virtual override myModifier {}
}
```
Examples of **incorrect** code for this rule:
<!-- prettier-ignore-start -->
```solidity
contract Example {
uint immutable private x = 1;
function f() myModifier public pure virtual override {}
}
```
<!-- prettier-ignore-end -->