hardhat-ignore-warnings
Advanced tools
@@ -31,3 +31,7 @@ "use strict"; | ||
(0, config_1.extendConfig)((config, userConfig) => { | ||
config.warnings = userConfig.warnings ?? {}; | ||
let warnings = userConfig.warnings ?? {}; | ||
if (typeof warnings !== 'object') { | ||
warnings = { '*': warnings }; | ||
} | ||
config.warnings = warnings; | ||
}); | ||
@@ -34,0 +38,0 @@ (0, config_1.task)(task_names_1.TASK_COMPILE_SOLIDITY_COMPILE_SOLC, async (args, hre, runSuper) => { |
@@ -13,3 +13,3 @@ import 'hardhat/types/config'; | ||
interface HardhatUserConfig { | ||
warnings?: Config; | ||
warnings?: WarningRule | Config; | ||
} | ||
@@ -16,0 +16,0 @@ interface HardhatConfig { |
{ | ||
"name": "hardhat-ignore-warnings", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Hardhat plugin to ignore Solidity warnings", | ||
@@ -5,0 +5,0 @@ "author": "Francisco Giordano <fg@frang.io>", |
@@ -7,6 +7,24 @@ # hardhat-ignore-warnings | ||
For warning ids refer to [`error-codes.ts`](./src/error-codes.ts). | ||
## Quickstart | ||
### Inline comments | ||
You can turn off all Solidity warnings by installing the plugin and configuring it as follows. | ||
```diff | ||
// hardhat.config.js | ||
+require('hardhat-ignore-warnings'); | ||
module.exports = { | ||
+ warnings: 'off', | ||
}; | ||
``` | ||
## Customization | ||
You can be more selective about the warnings that should be ignored and those that shouldn't. | ||
### Inline Comments | ||
If you want to ignore a warning in a particular line without setting rules for the entire project, you can use inline comments. | ||
```solidity | ||
@@ -19,3 +37,3 @@ // solc-ignore-next-line unused-param | ||
In order to ignore warnings or promote to errors across the entire project or in entire files, the plugin can be configured in your Hardhat config file. | ||
In order to ignore warnings or promote to errors across the entire project or in entire files, the plugin accepts more detailed configuration. | ||
@@ -50,1 +68,16 @@ The config is an object that maps glob patterns to warning rules. These rules will be applied to files matched by the glob pattern. More specific patterns override the rules of less specific ones. | ||
``` | ||
### Warning IDs | ||
Both inline comments and detailed configuration use the following set of names to identify warnings. | ||
- `unreachable`: "Unreachable code." | ||
- `unused-param`: "Unused function parameter. Remove or comment out the variable name to silence this warning." | ||
- `unused-var`: "Unused local variable." | ||
- `code-size`: "Contract code size is _N_ bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries." | ||
- `shadowing`: "This declaration shadows an existing declaration." | ||
- `shadowing-builtin`: "This declaration shadows a builtin symbol." | ||
- `shadowing-opcode`: "Variable is shadowed in inline assembly by an instruction of the same name." | ||
- `func-mutability`: "Function state mutability can be restricted to pure/view." | ||
- `license`: "SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information." | ||
- `pragma-solidity`: "Source file does not specify required compiler version!" |
@@ -34,3 +34,7 @@ import { extendConfig, extendEnvironment, task } from 'hardhat/config'; | ||
extendConfig((config, userConfig) => { | ||
config.warnings = userConfig.warnings ?? {}; | ||
let warnings = userConfig.warnings ?? {}; | ||
if (typeof warnings !== 'object') { | ||
warnings = { '*': warnings }; | ||
} | ||
config.warnings = warnings; | ||
}); | ||
@@ -37,0 +41,0 @@ |
@@ -19,3 +19,3 @@ // To extend one of Hardhat's types, you need to import the module where it has been defined, and redeclare it. | ||
export interface HardhatUserConfig { | ||
warnings?: Config; | ||
warnings?: WarningRule | Config; | ||
} | ||
@@ -22,0 +22,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27582
8.01%466
1.75%81
68.75%