Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
This is an open source project for linting Solidity code. This project provides both Security and Style Guide validations.
You can install Solhint using npm:
npm install -g solhint
# verify that it was installed correctly
solhint -V
For linting Solidity files you need to run Solhint with one or more Globs as arguments. For example, to lint all files inside contracts
directory, you can do:
solhint "contracts/**/*.sol"
To lint a single file:
solhint contracts/MyToken.sol
Solhint command description:
Usage: solhint [options] <file> [...other_files]
Linter for Solidity programming language
Options:
-V, --version output the version number
-f, --formatter [name] report formatter name (stylish, table, tap, unix)
-w, --max-warnings [maxWarningsNumber] number of warnings to trigger nonzero
-c, --config [file_name] file to use as your .solhint.json
-q, --quiet report errors only - default: false
--ignore-path [file_name] file to use as your .solhintignore
-h, --help output usage information
Commands:
stdin [options] put source code to stdin of this utility
init-config create sample solhint config in current folder
You can use a .solhint.json
file to configure Solhint globally. This file has the following
format:
{
"extends": "default",
"rules": {
"avoid-throw": false,
"avoid-suicide": "error",
"avoid-sha3": "warn",
"indent": ["warn", 4]
}
}
To ignore files / folders that do not require validation you may use .solhintignore
file. It supports rules in
.gitignore
format.
node_modules/
additiona-tests.sol
You can use comments in the source code to configure solhint in a given line or file.
For example, to disable all validations in the line following a comment:
// solhint-disable-next-line
uint[] a;
You can disable a single rule on a given line. For example, to disable validation of fixed compiler version in the next line:
// solhint-disable-next-line compiler-fixed, compiler-gt-0_4
pragma solidity ^0.4.4;
Disable validation on current line:
pragma solidity ^0.4.4; // solhint-disable-line
Disable validation of fixed compiler version validation on current line:
pragma solidity ^0.4.4; // solhint-disable-line compiler-fixed, compiler-gt-0_4
You can disable a rule for a group of lines:
/* solhint-disable avoid-throw */
if (a > 1) {
throw;
}
/* solhint-enable avoid-throw */
Or disable all validations for a group of lines:
/* solhint-disable */
if (a > 1) {
throw;
}
/* solhint-enable */
Full list with all supported Security Rules
Full list with all supported Style Guide Rules
Full list with all supported Best Practices Rules
Related documentation you may find there.
The grammar used by solhint was created and is maintained by Federico Bond. You can find it here.
MIT
Solhint is free to use and open-sourced. If you value our effort and feel like helping us to keep pushing this tool forward, you can send us a small donation. We'll highly appreciate it :)
FAQs
Solidity Code Linter
The npm package solhint receives a total of 61,559 weekly downloads. As such, solhint popularity was classified as popular.
We found that solhint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.