The {“extends”: “solhint:recommended”} property in a configuration file enables this rule.
Enforces the presence and correctness of NatSpec tags.
This rule accepts an array of options:
Index | Description | Default Value |
---|---|---|
0 | Rule severity. Must be one of “error”, “warn”, “off”. | warn |
1 | A JSON object with natspec properties. See EXAMPLE CONFIG section below. | Check EXAMPLE CONFIG |
{
"rules": {
"use-natspec": [
"warn",
{
"title": {
"enabled": true,
"ignore": {}
},
"author": {
"enabled": true,
"ignore": {}
},
"notice": {
"enabled": true,
"ignore": {}
},
"param": {
"enabled": true,
"ignore": {}
},
"return": {
"enabled": true,
"ignore": {}
}
}
]
}
}
function foo(uint256)
), the rule only checks the number of @param
or @return
tags, not their names.@inheritdoc
, the rule skips the validation.///
and /** */
style NatSpec comments.
/// @title Token contract
/// @author Me
/// @notice This contract handles tokens
contract Token {
/// @notice Transfers tokens
/// @param to The recipient address
/// @param amount The amount to transfer
/// @return success Whether the transfer succeeded
function transfer(address to, uint256 amount) public returns (bool success) {
return true;
}
}
ignore
option in the config. For example:{
"use-natspec": [
"warn",
{
"title": {
"enabled": true,
"ignore": {
"contract": ["MyContract"],
"*": ["LegacyContract"]
}
},
"param": { "enabled": false }
}
]
}
{
"title": { "enabled": true, "ignore": {} },
"author": { "enabled": true, "ignore": {} },
"notice": { "enabled": true, "ignore": {} },
"param": { "enabled": true, "ignore": {} },
"return": { "enabled": true, "ignore": {} }
}
/// @title Token contract
contract Token {
/// @param wrongParam Not matching actual parameter
function transfer(address to) public returns (bool) {
return true;
}
}
This rule was introduced in the latest version.