Standard configuration for linting Solidity code using
Solhint.
Solhint
is an alternative to Solium(ethlint)
which is no longer maintained.
Uses the solhint:recommended
ruleset, which itself is taken from the
Solidity Style Guide.
npm i https://github.com/keep-network/solhint-config-keep.git
- Install the linter and config -
npm i -D solhint https://github.com/keep-network/solhint-config-keep.git
- Create your
.solhint.json
(you can add additional rules or plugins):
{
"extends": "keep",
"plugins": [],
"rules": {
}
}
- Add commands for linting to your
package.json
:
{
"scripts": {
"lint:sol": "solhint 'contracts/**/*.sol'",
"lint:fix:sol": "solhint 'contracts/**/*.sol' --fix"
}
}
Edit the .solhint.json
.
/* solhint-disable */
/* solhint-disable */
/* solhint-enable */
Prefer /*
over //
, as it looks different to a comment on the rationale of code.
/* solhint-disable-next-line <rules> */
- repo: local
hooks:
- id: solhint
name: Solidity linter
language: node
entry: solhint
files: '\.sol$'
args:
- ./contracts/**/*.sol
- --config=./.solhint.json
additional_dependencies:
- solhint@3.3.4