solhint-community

named-parameters-function

Category Badge Default Severity Badge warn

Description

Enforce using named parameters when invoking a function with more than N arguments

Options

This rule accepts an array of options:

Index Description Default Value
0 Rule severity. Must be one of “error”, “warn”, “off”. warn
1 A Number specifying the max amount of arguments a function can have while still allowing positional arguments. 3

Example Config

{
  "rules": {
    "named-parameters-function": ["warn",3]
  }
}

Examples

👍 Examples of correct code for this rule

Calling a function with few positional arguments

foo(10,200)

Calling a function with few named arguments

foo({amount: 10, price: 200})

Calling a function with many named arguments


          foo({
            amount: 10,
            price: 200,
            recipient: 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990,
            token: 0xdac17f958d2ee523a2206206994597c13d831ec7
          })

👎 Examples of incorrect code for this rule

Calling a function with many positional arguments


          foo(
             10,
             200,
             0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990,
             0xdac17f958d2ee523a2206206994597c13d831ec7
          )

With a config value of 0, using positional arguments in any capacity

foo(10)

Version

This rule was introduced in Solhint 3.6.0

Resources