lint-trap
lint-trap copied to clipboard
Incorrect labelling of nesting "depth" thru eslint
'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
*/
A contrived example to reproduce a pain point I hit in real code @Raynos @malandrew
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
Looks like it's an eslint bug, we should report it to eslint. ( https://github.com/eslint/eslint/issues/1835 ).