lint-trap icon indicating copy to clipboard operation
lint-trap copied to clipboard

Incorrect labelling of nesting "depth" thru eslint

Open jcorbin opened this issue 10 years ago • 3 comments

'use strict';

var process = require('process');

function log(m) {
    process.stdout.log(m + '\n');
}

function foo(a) {
    if (a === 1) {
        log('1');
    } else if (a === 2) {
        log('2');
    } else if (a === 3) {
        log('3');
    } else if (a === 4) {
        log('4');
    } else if (a === 5) {
        log('5');
    } else if (a === 6) {
        log('6');
    }
}

var x = 3;
foo(x);

/* $ lint-trap foo.js
 *
 * foo.js
 *     error  eslint    18:11   Blocks are nested too deeply (5).  max-depth
 *     error  eslint    20:11   Blocks are nested too deeply (6).  max-depth
 */

jcorbin avatar Feb 14 '15 00:02 jcorbin

A contrived example to reproduce a pain point I hit in real code @Raynos @malandrew

jcorbin avatar Feb 14 '15 00:02 jcorbin

fwiw in my real code, it was a: function > for > if > if / else if / else if / ..., so I was trying to put an appropriately complex if/else if/... at depth 4 and got dinged on something like the 2nd or 3rd else if

jcorbin avatar Feb 14 '15 00:02 jcorbin

Looks like it's an eslint bug, we should report it to eslint. ( https://github.com/eslint/eslint/issues/1835 ).

Raynos avatar Feb 14 '15 00:02 Raynos