useMaxParams
Summary
Section titled “Summary”- Rule available since:
v2.2.0 - Diagnostic Category:
lint/nursery/useMaxParams - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
- Same as
max-params - Same as
too_many_arguments - Same as
@typescript-eslint/max-params
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useMaxParams": "error" } } }}Description
Section titled “Description”Enforce a maximum number of parameters in function definitions.
Functions that take numerous parameters can be difficult to read and write because it requires the memorization of what each parameter is, its type, and the order they should appear in.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”function foo(a, b, c, d, e, f, g, h) { // too many parameters}code-block.js:1:13 lint/nursery/useMaxParams ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Function has 8 parameters, but only 4 are allowed.
> 1 │ function foo(a, b, c, d, e, f, g, h) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^
2 │ // too many parameters
3 │ }
ℹ Functions with many parameters are hard to read and maintain.
ℹ Consider using an options object, splitting into smaller functions, or grouping related parameters.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
const bar = (a, b, c, d, e, f, g, h) => { // too many parameters}code-block.js:1:13 lint/nursery/useMaxParams ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Function has 8 parameters, but only 4 are allowed.
> 1 │ const bar = (a, b, c, d, e, f, g, h) => {
│ ^^^^^^^^^^^^^^^^^^^^^^^^
2 │ // too many parameters
3 │ }
ℹ Functions with many parameters are hard to read and maintain.
ℹ Consider using an options object, splitting into smaller functions, or grouping related parameters.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
class Baz { method(a, b, c, d, e, f, g, h) { // too many parameters }}code-block.js:2:11 lint/nursery/useMaxParams ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Function has 8 parameters, but only 4 are allowed.
1 │ class Baz {
> 2 │ method(a, b, c, d, e, f, g, h) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^
3 │ // too many parameters
4 │ }
ℹ Functions with many parameters are hard to read and maintain.
ℹ Consider using an options object, splitting into smaller functions, or grouping related parameters.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
function foo(a, b, c) { // within limit}const bar = (a, b, c) => { // within limit}class Baz { method(a, b, c) { // within limit }}Options
Section titled “Options”The maximum number of parameters allowed (default: 4).
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.