Skip to content

Commit c4fa5c9

Browse files
Merge pull request #590 from protofire/develop
5.0.2 Develop to Master
2 parents e20b8c8 + 8012672 commit c4fa5c9

22 files changed

+552
-23
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"semi": false,
33
"singleQuote": true,
4-
"printWidth": 100
4+
"printWidth": 100,
5+
"bracketSpacing": true
56
}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [5.0.2] - 2024-07-25
2+
### Fixed
3+
- `func-named-parameters` exclude abi.encodeX from the rule [#583](https://github.com/protofire/solhint/pull/583) (Thanks to [@0xCLARITY](https://github.com/0xCLARITY))
4+
- Several typos in comments [#586](https://github.com/protofire/solhint/pull/586) (Thanks to [@dropbigfish](https://github.com/dropbigfish))
5+
6+
### Added
7+
- New Rule: Imports order [#587](https://github.com/protofire/solhint/pull/587)
8+
9+
<br><br>
10+
111
## [5.0.1] - 2024-05-13
212
### BREAKING CHANGES (refer to v5.0.0)
313
Fixed an issue on the returining values where only was evaluating the first report instead of all of them.

conf/rulesets/solhint-all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = Object.freeze({
5050
immutablesAsConstants: true,
5151
},
5252
],
53+
'imports-order': 'warn',
5354
'modifier-name-mixedcase': 'warn',
5455
'named-parameters-mapping': 'warn',
5556
'private-vars-leading-underscore': [

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM node:20-alpine
22
LABEL maintainer="diego.bale@protofire.io"
3-
ENV VERSION=5.0.1
3+
ENV VERSION=5.0.2
44

55
RUN npm install -g solhint@"$VERSION"

docs/rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ title: "Rule Index of Solhint"
3737
| [func-named-parameters](./rules/naming/func-named-parameters.md) | Enforce named parameters for function calls with 4 or more arguments. This rule may have some false positives | | |
3838
| [func-param-name-mixedcase](./rules/naming/func-param-name-mixedcase.md) | Function param name must be in mixedCase. | | |
3939
| [immutable-vars-naming](./rules/naming/immutable-vars-naming.md) | Check Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configuration. | $~~~~~~~~$✔️ | |
40+
| [imports-order](./rules/naming/imports-order.md) | Order the imports of the contract to follow a certain hierarchy (read "Notes section") | | |
4041
| [modifier-name-mixedcase](./rules/naming/modifier-name-mixedcase.md) | Modifier name must be in mixedCase. | | |
4142
| [named-parameters-mapping](./rules/naming/named-parameters-mapping.md) | Solidity v0.8.18 introduced named parameters on the mappings definition. | | |
4243
| [private-vars-leading-underscore](./rules/naming/private-vars-leading-underscore.md) | Non-external functions and state variables should start with a single underscore. Others, shouldn't | | |

docs/rules/naming/imports-order.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
warning: "This is a dynamically generated file. Do not edit manually."
3+
layout: "default"
4+
title: "imports-order | Solhint"
5+
---
6+
7+
# imports-order
8+
![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational)
9+
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
10+
11+
## Description
12+
Order the imports of the contract to follow a certain hierarchy (read "Notes section")
13+
14+
## Options
15+
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.
16+
17+
### Example Config
18+
```json
19+
{
20+
"rules": {
21+
"imports-order": "warn"
22+
}
23+
}
24+
```
25+
26+
### Notes
27+
- Paths starting with "@" like "@openzeppelin/" and urls ("http" and "https") will go first
28+
- Order by hierarchy of directories first, e.g. ./../../ comes before ./../, which comes before ./, which comes before ./foo
29+
- Order alphabetically for each path at the same level, e.g. ./contract/Zbar.sol comes before ./interface/Ifoo.sol
30+
- Rule does NOT support this kind of import "import * as Alias from "./filename.sol"
31+
- 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"
32+
33+
## Examples
34+
This rule does not have examples.
35+
36+
## Version
37+
This rule is introduced in the latest version.
38+
39+
## Resources
40+
- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/imports-order.js)
41+
- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/imports-order.md)
42+
- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/imports-order.js)

docs/rules/naming/named-parameters-mapping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mapping(string name => uint256 balance) public users;
3939
mapping(address owner => mapping(address token => uint256 balance)) public tokenBalances;
4040
```
4141

42-
#### Main key of mapping is enforced. On nested mappings other naming are not neccesary
42+
#### Main key of mapping is enforced. On nested mappings other naming are not necessary
4343

4444
```solidity
4545
mapping(address owner => mapping(address => uint256)) public tokenBalances;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"imports-order": "error"
4+
}
5+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';
5+
import { Unauthorized, add as func, Point } from './Foo.sol';
6+
import 'https://github.com/owner/repo/blob/branch/path/to/Contract.sol';
7+
import { Initializable } from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
8+
import '../../../../token/interfaces/FakeContract1.sol';
9+
import { FakeContract3 } from '../../../token/interfaces/FakeContract3.sol';
10+
import './../../../../token/interfaces/AFakeContract1.sol';
11+
import './../token/interfaces/IXTokenWrapper.sol';
12+
import { IXTokenFactory, holaquetal } from '../../token/interfaces/IXTokenFactory.sol';
13+
import './../../bpath/otherfolder/otherfolder/aContract.sol';
14+
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
15+
import { FakeContract2 } from '../../../token/interfaces/FakeContract2.sol';
16+
import '../../apath/zContract.sol';
17+
import 'http://github.com/owner/repo/blob/branch/path/to/Contract2.sol';
18+
import { Afool1 } from './Afool1.sol';
19+
import './Ownable.sol';
20+
import { IXTokenWrapper2 } from '../token/interfaces/IXTokenWrapper2.sol';
21+
import { ReentrancyGuardUpgradeable2 } from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';
22+
23+
contract ImportsOrder {
24+
constructor() {}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
import { ReentrancyGuardUpgradeable2 } from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';
5+
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
6+
import 'http://github.com/owner/repo/blob/branch/path/to/Contract2.sol';
7+
import 'https://github.com/owner/repo/blob/branch/path/to/Contract.sol';
8+
import './../../../../token/interfaces/AFakeContract1.sol';
9+
import './../../../../token/interfaces/FakeContract1.sol';
10+
import { FakeContract2 } from './../../../token/interfaces/FakeContract2.sol';
11+
import { FakeContract3 } from './../../../token/interfaces/FakeContract3.sol';
12+
import './../../apath/zContract.sol';
13+
import './../../bpath/otherfolder/otherfolder/aContract.sol';
14+
import { IXTokenFactory, holaquetal } from './../../token/interfaces/IXTokenFactory.sol';
15+
import './../token/interfaces/IXTokenWrapper.sol';
16+
import { IXTokenWrapper2 } from './../token/interfaces/IXTokenWrapper2.sol';
17+
import { Afool1 } from './Afool1.sol';
18+
import { Unauthorized, add as func, Point } from './Foo.sol';
19+
import { Initializable } from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
20+
import './Ownable.sol';
21+
import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';
22+
23+
contract ImportsOrder {
24+
constructor() {}
25+
}

0 commit comments

Comments
 (0)