Standard configuration for linting Solidity code using Solhint.
Uses the solhint:recommended
ruleset, which itself is taken from the
Solidity Style Guide.
- Install the linter and config -
yarn add -D solhint https://github.com/thesis/solhint-config.git
- Create your
.solhint.json
(you can add additional rules or plugins):
{
"extends": "thesis",
"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:
- [email protected]