Skip to content

Documentation bug in max-depth #11991

@imai0917

Description

@imai0917

The version of ESLint you are using.
v5.16.0

The problem you want to solve.
The below example is from https://eslint.org/docs/rules/max-depth, ESLint v5.16.0 doesn't make issues for the example.

/*eslint max-depth: ["error", 4]*/
/*eslint-env es6*/

function foo() {
    for (;;) { // Nested 1 deep
        let val = () => (param) => { // Nested 2 deep
            if (true) { // Nested 3 deep
                if (true) { // Nested 4 deep
                    if (true) { // Nested 5 deep
                    }
                }
            }
        };
    }
}

Nesting function expressions would not be counted as a nesting depth, so the arrow function expression would not increase the depth count but reset the count.

Your take on the correct solution to problem.
The below example or other equivalents would work.

/*eslint max-depth: ["error", 3]*/

function foo() {
    for (;;) { // Nested 1 deep
        if (true) { // Nested 2 deep
            if (true) { // Nested 3 deep
                if (true) { // Nested 4 deep
                }
            }
        }
    }
}

Are you willing to submit a pull request to implement this change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestRecommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussiondocumentationRelates to ESLint's documentationgood first issueGood for people who haven't worked on ESLint beforehelp wantedThe team would welcome a contribution from the community for this issueruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions