solhint-community

one-contract-per-file

Recommended Badge Category Badge Default Severity Badge warn

The {“extends”: “solhint:recommended”} property in a configuration file enables this rule.

Description

Enforces the use of ONE Contract per file see here

Options

This rule accepts a string option of rule severity. Must be one of “error”, “warn”, “off”. Default to warn.

Example Config

{
  "rules": {
    "one-contract-per-file": "warn"
  }
}

Examples

👍 Examples of correct code for this rule

One contract per file


            contract Foo {

            }
            

👎 Examples of incorrect code for this rule

Two contract in the same file


            contract Foo {

            }

            contract Bar {

            }
            

One contract and one library in the same file


            contract Foo {

            }

            Library ReusableThing {

            }
            

Version

This rule was introduced in Solhint 3.7.0-rc02

Resources