diff --git a/.solhint.json b/.solhint.json index cb1238d3d..d4e1d0bed 100644 --- a/.solhint.json +++ b/.solhint.json @@ -13,6 +13,7 @@ "reason-string": "off", "no-empty-blocks": "off", "avoid-low-level-calls": "off", - "gas-custom-errors": "off" + "gas-custom-errors": "off", + "imports-order": "warn" } } diff --git a/contracts/Safe.sol b/contracts/Safe.sol index dca6bd605..e22fd3445 100644 --- a/contracts/Safe.sol +++ b/contracts/Safe.sol @@ -1,19 +1,19 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; +import {FallbackManager} from "./base/FallbackManager.sol"; import {ITransactionGuard, GuardManager} from "./base/GuardManager.sol"; import {ModuleManager} from "./base/ModuleManager.sol"; import {OwnerManager} from "./base/OwnerManager.sol"; -import {FallbackManager} from "./base/FallbackManager.sol"; import {NativeCurrencyPaymentFallback} from "./common/NativeCurrencyPaymentFallback.sol"; -import {Singleton} from "./common/Singleton.sol"; -import {SignatureDecoder} from "./common/SignatureDecoder.sol"; import {SecuredTokenTransfer} from "./common/SecuredTokenTransfer.sol"; +import {SignatureDecoder} from "./common/SignatureDecoder.sol"; +import {Singleton} from "./common/Singleton.sol"; import {StorageAccessible} from "./common/StorageAccessible.sol"; -import {Enum} from "./libraries/Enum.sol"; -import {ISignatureValidator, ISignatureValidatorConstants} from "./interfaces/ISignatureValidator.sol"; import {SafeMath} from "./external/SafeMath.sol"; import {ISafe} from "./interfaces/ISafe.sol"; +import {ISignatureValidator, ISignatureValidatorConstants} from "./interfaces/ISignatureValidator.sol"; +import {Enum} from "./libraries/Enum.sol"; /** * @title Safe - A multisignature wallet with support for confirmations using signed messages based on EIP-712. diff --git a/contracts/SafeL2.sol b/contracts/SafeL2.sol index f91a9c79c..44c303a3a 100644 --- a/contracts/SafeL2.sol +++ b/contracts/SafeL2.sol @@ -1,12 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {Safe, Enum} from "./Safe.sol"; - -// Imports are required for NatSpec validation of the compiler, and falsely detected as unused by -// the linter, so disable the `no-unused-imports` rule for the next line. +// The import is used in the @inheritdoc, false positive // solhint-disable-next-line no-unused-import import {ModuleManager} from "./base/ModuleManager.sol"; +import {Safe, Enum} from "./Safe.sol"; /** * @title SafeL2 - An implementation of the Safe contract that emits additional events on transaction executions. diff --git a/contracts/base/GuardManager.sol b/contracts/base/GuardManager.sol index 539b399bd..e57df501f 100644 --- a/contracts/base/GuardManager.sol +++ b/contracts/base/GuardManager.sol @@ -2,10 +2,10 @@ /* solhint-disable one-contract-per-file */ pragma solidity >=0.7.0 <0.9.0; -import {Enum} from "../libraries/Enum.sol"; -import {SelfAuthorized} from "../common/SelfAuthorized.sol"; -import {IERC165} from "../interfaces/IERC165.sol"; -import {IGuardManager} from "../interfaces/IGuardManager.sol"; +import {SelfAuthorized} from "./../common/SelfAuthorized.sol"; +import {IERC165} from "./../interfaces/IERC165.sol"; +import {IGuardManager} from "./../interfaces/IGuardManager.sol"; +import {Enum} from "./../libraries/Enum.sol"; /** * @title ITransactionGuard Interface diff --git a/contracts/base/ModuleManager.sol b/contracts/base/ModuleManager.sol index b7b051777..ebdb4df7f 100644 --- a/contracts/base/ModuleManager.sol +++ b/contracts/base/ModuleManager.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: LGPL-3.0-only /* solhint-disable one-contract-per-file */ pragma solidity >=0.7.0 <0.9.0; -import {Enum} from "../libraries/Enum.sol"; -import {SelfAuthorized} from "../common/SelfAuthorized.sol"; +import {SelfAuthorized} from "./../common/SelfAuthorized.sol"; +import {IERC165} from "./../interfaces/IERC165.sol"; +import {IModuleManager} from "./../interfaces/IModuleManager.sol"; +import {Enum} from "./../libraries/Enum.sol"; import {Executor} from "./Executor.sol"; -import {IModuleManager} from "../interfaces/IModuleManager.sol"; -import {IERC165} from "../interfaces/IERC165.sol"; /** * @title IModuleGuard Interface diff --git a/contracts/examples/guards/BaseGuard.sol b/contracts/examples/guards/BaseGuard.sol index 705505567..479128a12 100644 --- a/contracts/examples/guards/BaseGuard.sol +++ b/contracts/examples/guards/BaseGuard.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {IERC165} from "../../interfaces/IERC165.sol"; -import {BaseTransactionGuard, ITransactionGuard} from "../../base/GuardManager.sol"; -import {BaseModuleGuard, IModuleGuard} from "../../base/ModuleManager.sol"; +import {BaseTransactionGuard, ITransactionGuard} from "./../../base/GuardManager.sol"; +import {BaseModuleGuard, IModuleGuard} from "./../../base/ModuleManager.sol"; +import {IERC165} from "./../../interfaces/IERC165.sol"; /** * @title BaseGuard - Inherits BaseTransactionGuard and BaseModuleGuard. diff --git a/contracts/examples/guards/DebugTransactionGuard.sol b/contracts/examples/guards/DebugTransactionGuard.sol index 9f55574df..2b73d4c21 100644 --- a/contracts/examples/guards/DebugTransactionGuard.sol +++ b/contracts/examples/guards/DebugTransactionGuard.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {Enum} from "../../libraries/Enum.sol"; -import {ISafe} from "../../interfaces/ISafe.sol"; +import {ISafe} from "./../../interfaces/ISafe.sol"; +import {Enum} from "./../../libraries/Enum.sol"; import {BaseGuard} from "./BaseGuard.sol"; /** * @title Debug Transaction Guard - Emits transaction events with extended information. diff --git a/contracts/examples/guards/OnlyOwnersGuard.sol b/contracts/examples/guards/OnlyOwnersGuard.sol index 0b56c4949..c2f7be4da 100644 --- a/contracts/examples/guards/OnlyOwnersGuard.sol +++ b/contracts/examples/guards/OnlyOwnersGuard.sol @@ -2,9 +2,9 @@ /* solhint-disable one-contract-per-file */ pragma solidity >=0.7.0 <0.9.0; -import {Enum} from "../../libraries/Enum.sol"; -import {BaseTransactionGuard} from "../../base/GuardManager.sol"; -import {ISafe} from "../../interfaces/ISafe.sol"; +import {BaseTransactionGuard} from "./../../base/GuardManager.sol"; +import {ISafe} from "./../../interfaces/ISafe.sol"; +import {Enum} from "./../../libraries/Enum.sol"; /** * @title OnlyOwnersGuard - Only allows owners to execute transactions. diff --git a/contracts/handler/CompatibilityFallbackHandler.sol b/contracts/handler/CompatibilityFallbackHandler.sol index 681385691..11c93231b 100644 --- a/contracts/handler/CompatibilityFallbackHandler.sol +++ b/contracts/handler/CompatibilityFallbackHandler.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {TokenCallbackHandler} from "./TokenCallbackHandler.sol"; -import {ISignatureValidator} from "../interfaces/ISignatureValidator.sol"; -import {ISafe} from "../interfaces/ISafe.sol"; +import {ISafe} from "./../interfaces/ISafe.sol"; +import {ISignatureValidator} from "./../interfaces/ISignatureValidator.sol"; import {HandlerContext} from "./HandlerContext.sol"; +import {TokenCallbackHandler} from "./TokenCallbackHandler.sol"; /** * @title Compatibility Fallback Handler - Provides compatibility between pre 1.3.0 and 1.3.0+ Safe Smart Account contracts. diff --git a/contracts/interfaces/ISafe.sol b/contracts/interfaces/ISafe.sol index 7b1057a40..001ccf526 100644 --- a/contracts/interfaces/ISafe.sol +++ b/contracts/interfaces/ISafe.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {Enum} from "../libraries/Enum.sol"; -import {IModuleManager} from "./IModuleManager.sol"; -import {IOwnerManager} from "./IOwnerManager.sol"; +import {Enum} from "./../libraries/Enum.sol"; import {IFallbackManager} from "./IFallbackManager.sol"; import {IGuardManager} from "./IGuardManager.sol"; +import {IModuleManager} from "./IModuleManager.sol"; +import {IOwnerManager} from "./IOwnerManager.sol"; /** * @title ISafe - A multisignature wallet interface with support for confirmations using signed messages based on EIP-712. diff --git a/contracts/libraries/SafeMigration.sol b/contracts/libraries/SafeMigration.sol index 3e9109fb1..28c867500 100644 --- a/contracts/libraries/SafeMigration.sol +++ b/contracts/libraries/SafeMigration.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {SafeStorage} from "../libraries/SafeStorage.sol"; -import {ISafe} from "../interfaces/ISafe.sol"; +import {ISafe} from "./../interfaces/ISafe.sol"; +import {SafeStorage} from "./../libraries/SafeStorage.sol"; /** * @title Migration Contract for Safe Upgrade diff --git a/contracts/libraries/SafeToL2Migration.sol b/contracts/libraries/SafeToL2Migration.sol index 0621370d5..9f482bc94 100644 --- a/contracts/libraries/SafeToL2Migration.sol +++ b/contracts/libraries/SafeToL2Migration.sol @@ -2,9 +2,9 @@ /* solhint-disable one-contract-per-file */ pragma solidity >=0.7.0 <0.9.0; -import {SafeStorage} from "../libraries/SafeStorage.sol"; -import {Enum} from "../libraries/Enum.sol"; -import {ISafe} from "../interfaces/ISafe.sol"; +import {ISafe} from "./../interfaces/ISafe.sol"; +import {Enum} from "./../libraries/Enum.sol"; +import {SafeStorage} from "./../libraries/SafeStorage.sol"; /** * @title Migration Contract for updating a Safe from 1.1.1/1.3.0/1.4.1 versions to a L2 version. Useful when replaying a Safe from a non L2 network in a L2 network. diff --git a/contracts/libraries/SignMessageLib.sol b/contracts/libraries/SignMessageLib.sol index 35dab60eb..32f96dcb8 100644 --- a/contracts/libraries/SignMessageLib.sol +++ b/contracts/libraries/SignMessageLib.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; +import {ISafe} from "./../interfaces/ISafe.sol"; import {SafeStorage} from "./SafeStorage.sol"; -import {ISafe} from "../interfaces/ISafe.sol"; /** * @title SignMessageLib - Allows to sign messages on-chain by writing the signed message hashes on-chain. diff --git a/contracts/proxies/SafeProxyFactory.sol b/contracts/proxies/SafeProxyFactory.sol index 169ebbe54..f066f1a72 100644 --- a/contracts/proxies/SafeProxyFactory.sol +++ b/contracts/proxies/SafeProxyFactory.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {SafeProxy} from "./SafeProxy.sol"; import {IProxyCreationCallback} from "./IProxyCreationCallback.sol"; +import {SafeProxy} from "./SafeProxy.sol"; /** * @title Proxy Factory - Allows to create a new proxy contract and execute a message call to the new proxy within one transaction. diff --git a/contracts/test/ERC1155Token.sol b/contracts/test/ERC1155Token.sol index 2e77621c2..5782cfb0f 100644 --- a/contracts/test/ERC1155Token.sol +++ b/contracts/test/ERC1155Token.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import {ERC1155TokenReceiver} from "../interfaces/ERC1155TokenReceiver.sol"; -import {SafeMath} from "../external/SafeMath.sol"; +import {SafeMath} from "./../external/SafeMath.sol"; +import {ERC1155TokenReceiver} from "./../interfaces/ERC1155TokenReceiver.sol"; /** * @title ERC1155Token - A test ERC1155 token contract diff --git a/contracts/test/TestImports.sol b/contracts/test/TestImports.sol index 4c52b2dc3..ed078ad20 100644 --- a/contracts/test/TestImports.sol +++ b/contracts/test/TestImports.sol @@ -3,7 +3,6 @@ pragma solidity >=0.7.0 <0.9.0; // Import the contract so hardhat compiles it, and we have the ABI available -// solhint-disable-next-line no-unused-import -import {MockContract} from "@safe-global/mock-contract/contracts/MockContract.sol"; -// solhint-disable-next-line no-unused-import +// solhint-disable no-unused-import import {UpgradeableProxy} from "@openzeppelin/contracts/proxy/UpgradeableProxy.sol"; +import {MockContract} from "@safe-global/mock-contract/contracts/MockContract.sol"; diff --git a/package.json b/package.json index ea1fb9f0e..7a6af5434 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,12 @@ "deploy-all": "hardhat deploy-contracts --network", "deploy": "hardhat deploy --network", "lint": "npm run lint:sol && npm run lint:ts", + "lint:fix": "npm run lint:sol:fix && npm run lint:ts:fix", "lint:sol": "solhint 'contracts/**/*.sol'", + "lint:sol:fix": "solhint --fix 'contracts/**/*.sol'", "lint:sol:prettier": "prettier 'contracts/**/*.sol' --list-different", - "lint:ts": "eslint 'src/**/*.ts' 'test/**/*.ts' --fix", + "lint:ts": "eslint 'src/**/*.ts' 'test/**/*.ts'", + "lint:ts:fix": "eslint 'src/**/*.ts' 'test/**/*.ts' --fix", "lint:ts:prettier": "prettier 'src/**/*.ts' 'test/**/*.ts' --list-different", "fmt": "npm run fmt:sol && npm run fmt:ts", "fmt:sol": "prettier 'contracts/**/*.sol' -w",