• Stars
    star
    925
  • Rank 49,378 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Solhint is an open-source project to provide a linting utility for Solidity code.

By Protofire

Donate with Ethereum NPM version Coverage Status MIT licensed

This is an open source project for linting Solidity code. This project provides both Security and Style Guide validations.

Installation

You can install Solhint using npm:

npm install -g solhint

# verify that it was installed correctly
solhint --version

Usage

First initialize a configuration file, if you don't have one:

solhint --init

This will create a .solhint.json file with the default rules enabled. Then 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

Run solhint without arguments to get more information:

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 allowed warnings
  -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
  --fix                                   automatically fix problems
  --init                                  create configuration file for solhint
  -h, --help                              output usage information

Commands:

  stdin [options]                         linting of source code data provided to STDIN

Configuration

You can use a .solhint.json file to configure Solhint for the whole project.

To generate a new sample .solhint.json file in current folder you can do:

solhint --init 

This file has the following format:

Default

{
  "extends": "solhint:default"
}

Sample

  {
    "extends": "solhint:recommended",
    "plugins": [],
    "rules": {
      "avoid-suicide": "error",
      "avoid-sha3": "warn"
    }
  }

A full list of all supported rules can be found here.

To ignore files that do not require validation you can use a .solhintignore file. It supports rules in the .gitignore format.

node_modules/
additional-tests.sol

Extendable rulesets

The default rulesets provided by solhint are the following:

  • solhint:default
  • solhint:recommended

Use one of these as the value for the "extends" property in your configuration file.

Configure the linter with comments

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 specific rules on a given line. For example:

  // solhint-disable-next-line not-rely-on-time, not-rely-on-block-hash
  uint pseudoRand = uint(keccak256(abi.encodePacked(now, blockhash(block.number))));

Disable validation on current line:

  uint pseudoRand = uint(keccak256(abi.encodePacked(now, blockhash(block.number)))); // solhint-disable-line

Disable specific rules on current line:

   uint pseudoRand = uint(keccak256(abi.encodePacked(now, blockhash(block.number)))); // solhint-disable-line not-rely-on-time, not-rely-on-block-hash

You can disable a rule for a group of lines:

  /* solhint-disable avoid-tx-origin */
  function transferTo(address to, uint amount) public {
    require(tx.origin == owner);
    to.call.value(amount)();
  }
  /* solhint-enable avoid-tx-origin */

Or disable all validations for a group of lines:

  /* solhint-disable */
  function transferTo(address to, uint amount) public {
    require(tx.origin == owner);
    to.call.value(amount)();
  }
  /* solhint-enable */

Rules

Security Rules

Full list with all supported Security Rules

Style Guide Rules

Full list with all supported Style Guide Rules

Best Practices Rules

Full list with all supported Best Practices Rules

Documentation

Related documentation you may find here.

IDE Integrations

Table of Contents

  • Roadmap: The core project's roadmap - what the core team is looking to work on in the near future.
  • Contributing: The core Solhint team ❀️ contributions. This describes how you can contribute to the Solhint Project.
  • Shareable configs: How to create and share your own configurations.
  • Writing plugins: How to extend Solhint with your own rules.

Plugins

Who uses Solhint?

OpenZeppelin POA Network - Public EVM Sidechain 0x GNOSIS

Projects

Acknowledgements

The Solidity parser used is @solidity-parser/parser.

Licence

MIT

Back us

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 :)

Donate with Ethereum

Related projects

  • eth-cli: CLI swiss army knife for Ethereum developers.

More Repositories

1

blockchain-learning-path

A suggested learning path for blockchain development
2,438
star
2

eth-cli

CLI swiss army knife for Ethereum developers
TypeScript
237
star
3

omen-exchange

Omen exchange
TypeScript
64
star
4

subgraph-toolkit

A collection of utilities and helpers to support the development of subgraphs
TypeScript
52
star
5

lens-protocol-subgraph

Subgraph for lens protocol
TypeScript
44
star
6

opensea-wyvern-exchange-subgraph-v1

opensea-wyvern-exchange-subgraph
TypeScript
22
star
7

big-number-input

React input component for big number values
TypeScript
21
star
8

tezos-react-starter

A Tezos DApp starter kit based on React
TypeScript
20
star
9

awesome-ligo

A curated list of awesome Ligo resources, libraries, tools and more
19
star
10

filecoin-CID-checker

Filecoin CID checker and Storage Oracle
TypeScript
17
star
11

polkadot-mempool-explorer

Mempool Explorer allow users to monitor pending transactions on Polkadot.
TypeScript
16
star
12

tezos-defi-dapp

User interface with high level of deFi functionalities
TypeScript
16
star
13

maker-governance-dashboard

MakerDAO Governance Dashboard
TypeScript
16
star
14

kyber-pool-master-proxy-contract

KyberDAO - Smart Contract Proxy For Pool Masters
JavaScript
15
star
15

maker-protocol-subgraph

Subgraph for Maker Protocol (MCD)
TypeScript
15
star
16

maker-governance-subgraph

TypeScript
15
star
17

superrare-subgraph-deprecated

Subgraph for SuperRare platform
TypeScript
14
star
18

polkadot-failover-mechanism

Failover mechanism for operators running Polkadot nodes to optimize uptime without jeopardising being slashed due to issues such as double signing
Go
13
star
19

polkadot-contract-wizard

Tool that allows users to create their own smart contracts in Polkadot.
TypeScript
13
star
20

omen-subgraph

TypeScript
12
star
21

compound-governance-subgraph

Compound Governance Subgraph
TypeScript
9
star
22

idea-solidity-solhint

JetBrains IDEA plugin to provide Solhint code verification
Kotlin
9
star
23

curve-subgraph

Subgraph for Curve.fi
TypeScript
9
star
24

web3_ethers_guide

A guide to showcase use cases for web3.js and ethers.js libraries
JavaScript
7
star
25

autoglyphs

Autoglyphs are an experiment in generative art, each one unique and created by code running on the Ethereum blockchain.
TypeScript
7
star
26

platzi-web3-libs

Platzi Web3 libraries Exercise
6
star
27

chainlink-external-adapter-example

A Chainlink external adapter example
JavaScript
6
star
28

chainlink-avalanche-node

Chainlink Avalanche Development Node
Shell
6
star
29

subgraph-devkit

Happiness kit for subgraph developers
TypeScript
6
star
30

dydx-subgraph

Subgraph for dYdX Margin Trading protocol and derivatives
TypeScript
6
star
31

web3-react-boilerplate

JavaScript
5
star
32

loopringv3.6-subgraph

Loopring Exchange V2 (Loopring 3.6) subgraph. Supports L2 Blocks and Transactions, as well as L2 accounts, balances and more.
TypeScript
5
star
33

instadapp-dsa-subgraph

InstaDapp DeFi Smart Accounts subgraph
TypeScript
5
star
34

cdp-alert

Monitoring and alerting system for MakerDAO DAI Stablecoin CDPs (Collateralized Debt Position)
JavaScript
5
star
35

gnosis-safe-toolchain

A collection of utilities and helpers to interact with Gnosis Safe
JavaScript
5
star
36

tezos-defi-dev-experience

Developer experience, form Ethereum to Tezos through deFi
4
star
37

tezos-contracts-examples

This is a recopilation of smart contracts made with Ligo for the Tezos blockchain
JavaScript
4
star
38

ethblockart-subgraph

Subgraph for EthBlock.art
TypeScript
4
star
39

cryptopepes-subgraph

Subgraph for cryptopepes.io project
Solidity
4
star
40

tezos-price-oracle

Tezos price oracle for a liquidity pool
JavaScript
4
star
41

livepeer-alerts-frontend

Provide pro-active alert notifications that will help LPT token holders to be updated and understand how the transcoders they are delegating the tokens to are performing in near real time
JavaScript
4
star
42

atom-solidity-linter

Implement integration of Solhint linter to Atom editor
JavaScript
4
star
43

Cardano-Developer-Studio

Cardano - Portal dApp - Scaffold
Haskell
4
star
44

simplestate-ui

TypeScript
3
star
45

op-middleware

POC middleware to use Filecoin as a storage strategy.
TypeScript
3
star
46

kyber-subgraph

Subgraph for the Kyber Network contracts
TypeScript
3
star
47

euler-beats-subgraph

Music as mathematical art on an NFT substrate
TypeScript
3
star
48

humanitydao-subgraph

Subgraph of humanitydao.org
TypeScript
3
star
49

monitoring

Shell
3
star
50

augur-v2-subgraph

Subgraph for the Augur v2 protocol
TypeScript
3
star
51

chainlink-xdai-test-dapp

This is a sample dapp for testing interactions with Chainlink price feeds.
JavaScript
3
star
52

avastars-subgraph

avastars-subgraph
TypeScript
3
star
53

react-subgraph-starter-kit

starter-kit-subgraph
JavaScript
3
star
54

ink-multisig

TypeScript
3
star
55

bloom-subgraph

Subgraph for Bloom protocol
TypeScript
3
star
56

gnosis-beacon-chain-automation

The repository contains Infractructure as Code (IaC) resources to deploy Gnosis Beacon Chain validators in a decentralized manner.
HCL
3
star
57

uma-subgraph

UMA Protocol subgraph
TypeScript
3
star
58

cl-defi-score-oracle

Chainlink: DefiScore Oracle
JavaScript
3
star
59

remix-solhint-plugin

JavaScript
3
star
60

tokens-faucet

Faucet for ERC20 tokens
JavaScript
3
star
61

set-protocol-subgraph

Subgraph for Set Protocol
TypeScript
2
star
62

filecoin-rpc-proxy

Go
2
star
63

truffle-plugin-solhint

Solhint linter plugin for Truffle Framework
JavaScript
2
star
64

fairdex

TypeScript
2
star
65

wallaby

Go
2
star
66

subgraph-prettier-config

Shared Prettier configuration to use in subgraph projects
JavaScript
2
star
67

Visitors-Nft-Subgraph

Subgraph for Visitors Nfts on polygon network
TypeScript
2
star
68

chainlink-xdai-node

Shell
2
star
69

dai-erc20-subgraph

DAI (ERC20 contract) Subgraph
TypeScript
2
star
70

filecoin-cloud-images

An automatic IaC solution that will periodically update the AMI of top 3 cloud providers (AWS, Azure, GCP).
Shell
2
star
71

frontend-ui-ux-developer-learning-path

An opinionated learning path for getting into speed with frontend development.
2
star
72

ve8020-launchpad

TypeScript
2
star
73

ink-multisig-ui

TypeScript
2
star
74

portfolio-balancer

JavaScript
2
star
75

loopringv3-subgraph

TypeScript
2
star
76

ray-subgraph

Subgraph for Robo-Advisor for Yield (RAY)
TypeScript
2
star
77

hardhat-chainlink-plugin

Solidity
2
star
78

chainlink-plasm-node

Tooling for easy deployments of Chainlink Nodes on Plasm's Dusty Test Network.
Shell
1
star
79

thegraph-node-protofire

This image is based on graph-node from @graphprotocol and it contains also both graph-cli and indexer-cli to help us to manage the indexer.
Shell
1
star
80

memeltd-subgraph

Solidity
1
star
81

0x-dashboard

0x Dashboard Prototype
JavaScript
1
star
82

ocr-deploy-script

Go
1
star
83

meter-passport-playbooks

This is the repo that contains an Ansible role to automate Meter Passport relayer deployment
Jinja
1
star
84

nexus-mutual-subgraph

Nexus Mutual Subgraph
TypeScript
1
star
85

chainlink-harmony-node

Configuration files to quickly setup a Chainlink node on Harmony's testnet (shard 0)
Shell
1
star
86

embark-solhint

A solhint plugin for Embark
JavaScript
1
star
87

curve-gauges-subgraph

Subgraph providing data of gauges in Curve Finance
TypeScript
1
star
88

bullrunbabes-subgraph

Subgraph for bullrunbabes nfts
Solidity
1
star
89

open-cdp

Easy DAI Borrowing for Consumers
JavaScript
1
star
90

kilt

🧬 Recipe application that shows an attestation process in order to verify CTypes for DiDs on the KILT blockchain.
TypeScript
1
star
91

fuel-multisig-ui

TypeScript
1
star
92

xs-doc

XSigners documentation
TypeScript
1
star
93

makers-place-subgraph

makers-place-subgraph
TypeScript
1
star
94

livepeer-alerts-backend

Provide pro-active alert notifications that will help LPT token holders to be updated and understand how the transcoders are delegating tokens in near real time
JavaScript
1
star
95

chainlink-celo-node

Ready-to-go docker-compose configuration and external adapter for the Chainlink Network on the Celo Blockchain
JavaScript
1
star
96

subgraph-tests

Automated tests for subgraphs
TypeScript
1
star
97

artblocks-subgraph

artblocks-subgrapg
TypeScript
1
star
98

makerdao-scd-subgraph

MakerDAO Single-Collateral Dai subgraph
TypeScript
1
star
99

VineMoneyFrontEnd

VineMoneyFrontEnd
JavaScript
1
star
100

VineMoney

Solidity
1
star