max-depth
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"max-depth": "error",
},
},
];function foo() {
for (;;) { // Nested 1 deep
while (true) { // Nested 2 deep
if (true) { // Nested 3 deep
if (true) { // Nested 4 deep
if (true) { // Nested 5 deep
}
}
}
}
}
}function foo() {
if (true) { // Nested 1 deep
class C {
static {
if (true) { // Nested 1 deep
if (true) { // Nested 2 deep
if (true) { // Nested 3 deep
}
}
}
}
}
}
}function foo() {
for (;;) { // Nested 1 deep
while (true) { // Nested 2 deep
if (true) { // Nested 3 deep
if (true) { // Nested 4 deep
}
}
}
}
}function foo() {
if (true) { // Nested 1 deep
class C {
static {
if (true) { // Nested 1 deep
if (true) { // Nested 2 deep
}
}
}
}
}
}Examples from the ESLint documentation.
max-depth
eslint
export default [
{
rules: {
"max-depth": "error",
},
},
];max-depth
eslint plugin · pedantic
{
"rules": {
"max-depth": "error"
}
}nursery/noExcessiveNestedBlocks
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"noExcessiveNestedBlocks": "error"
}
}
}
}Disallow use of this in contexts where the value of this is undefined
Enforce a maximum number of lines per file
Enforce a maximum number of parameters in function definitions
Disallow shorthand type conversions
Enforce or disallow capitalization of the first letter of a comment
Disallow assignments that can lead to race conditions due to usage of await or yield