max-lines-per-function
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"max-lines-per-function": "error",
},
},
];function foo() {
const x = 0;
}function foo() {
// a comment
const x = 0;
}function foo() {
// a comment followed by a blank line
const x = 0;
}function foo() {
const x = 0;
}function foo() {
// a comment
const x = 0;
}function foo() {
// a comment followed by a blank line
const x = 0;
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
max-lines-per-function
eslint
export default [
{
rules: {
"max-lines-per-function": "error",
},
},
];max-lines-per-function
eslint plugin · pedantic
{
"rules": {
"max-lines-per-function": "error"
}
}complexity/noExcessiveLinesPerFunction
complexity · since 2.0.0
{
"linter": {
"rules": {
"complexity": {
"noExcessiveLinesPerFunction": "error"
}
}
}
}Require or disallow initialization in variable declarations
Enforce a maximum number of statements allowed in function blocks
Disallow assignments that can lead to race conditions due to usage of await or yield