diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e91fe0a..f0304637 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## [5.0.3] - 2024-08-03
+### Fixed
+- New Rule: Imports order [#593](https://github.com/protofire/solhint/pull/593)
+
+
+
## [5.0.2] - 2024-07-25
### Fixed
- `func-named-parameters` exclude abi.encodeX from the rule [#583](https://github.com/protofire/solhint/pull/583) (Thanks to [@0xCLARITY](https://github.com/0xCLARITY))
diff --git a/docker/Dockerfile b/docker/Dockerfile
index e7af3f49..61c9a8c3 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,5 +1,5 @@
FROM node:20-alpine
LABEL maintainer="diego.bale@protofire.io"
-ENV VERSION=5.0.2
+ENV VERSION=5.0.3
RUN npm install -g solhint@"$VERSION"
\ No newline at end of file
diff --git a/docs/rules/naming/func-named-parameters.md b/docs/rules/naming/func-named-parameters.md
index 44fe7da6..88b660f9 100644
--- a/docs/rules/naming/func-named-parameters.md
+++ b/docs/rules/naming/func-named-parameters.md
@@ -51,6 +51,12 @@ functionName({ sender: '0xA81705c8C247C413a19A244938ae7f4A0393944e', amount: 1e1
functionName({ sender: _senderAddress, amount: 1e18, token: _tokenAddress, receiver: _receiverAddress })
```
+#### abi.encodeX call with four UNNAMED parameters
+
+```solidity
+abi.encodePacked(_senderAddress, 1e18, _tokenAddress, _receiverAddress )
+```
+
### 👎 Examples of **incorrect** code for this rule
#### Function call with four UNNAMED parameters (default 4)
diff --git a/docs/rules/naming/imports-order.md b/docs/rules/naming/imports-order.md
index b5322754..484934b6 100644
--- a/docs/rules/naming/imports-order.md
+++ b/docs/rules/naming/imports-order.md
@@ -26,6 +26,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
### 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"
@@ -34,7 +35,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
This rule does not have examples.
## Version
-This rule is introduced in the latest version.
+This rule was introduced in [Solhint 5.0.2](https://github.com/protofire/solhint/tree/v5.0.2)
## Resources
- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/imports-order.js)
diff --git a/lib/rules/naming/imports-order.js b/lib/rules/naming/imports-order.js
index 6d3a255e..77807d37 100644
--- a/lib/rules/naming/imports-order.js
+++ b/lib/rules/naming/imports-order.js
@@ -23,6 +23,9 @@ const meta = {
{
note: 'Order by hierarchy of directories first, e.g. ./../../ comes before ./../, which comes before ./, which comes before ./foo',
},
+ {
+ note: 'Direct imports come before relative imports',
+ },
{
note: 'Order alphabetically for each path at the same level, e.g. ./contract/Zbar.sol comes before ./interface/Ifoo.sol',
},
@@ -135,18 +138,25 @@ class ImportsOrderChecker extends BaseChecker {
function getHierarchyLevel(path) {
// put very large numbers so these comes first in precedence
const protocolOrder = {
- '@': -30000,
- 'http://': -20000,
- 'https://': -10000,
+ '@': -40000,
+ 'http://': -30000,
+ 'https://': -20000,
+ // eslint-disable-next-line prettier/prettier
+ folderPath: -10000,
}
// Check for protocol-specific paths and assign them their respective order levels
for (const protocol in protocolOrder) {
- if (path.startsWith(protocol)) {
+ if (protocol !== 'folderPath' && path.startsWith(protocol)) {
return protocolOrder[protocol]
}
}
+ // Handling for paths that are likely folder names without a leading './'
+ if (!path.startsWith('./') && /^[a-zA-Z0-9]/.test(path)) {
+ return protocolOrder.folderPath
+ }
+
// Relative path handling
if (path.startsWith('./')) {
// Count the number of '../' sequences to determine depth
diff --git a/package.json b/package.json
index bb17a54e..74324f37 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "solhint",
- "version": "5.0.2",
+ "version": "5.0.3",
"description": "Solidity Code Linter",
"main": "lib/index.js",
"keywords": [