Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit c3ba86e

Browse files
committed
Indentation: Fix crash caused by multiline case statements that fall through.
Fixes #459
1 parent 051ff9a commit c3ba86e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

lib/rules/validate-indentation.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,15 @@ module.exports.prototype = {
212212
var childrenProperty = indentableNodes[node.type];
213213
var children = node[childrenProperty];
214214

215-
if (children.length > 1 || children[0].type !== 'BlockStatement') {
215+
if (children.length > 1 ||
216+
(children[0] && children[0].type !== 'BlockStatement')) {
216217
markChildren(node);
217218
markPop(node, 1, true);
218219
markPushAndCheck(node, 1);
220+
} else if (children.length === 0) {
221+
linesToCheck[node.loc.start.line - 1].push = 1;
222+
linesToCheck[node.loc.start.line - 1].check = true;
223+
markPop(node, 1, true);
219224
}
220225
});
221226

test/data/validate-indentation.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,17 @@ var a = b.c(function() {
392392
d++;
393393
}),
394394
e;
395+
396+
switch (true) {
397+
case (a
398+
&& b):
399+
case (c // ->
400+
&& d):
401+
case (e // <-
402+
&& f):
403+
case (g
404+
&& h):
405+
var i = j; // <-
406+
var k = l;
407+
var m = n; // ->
408+
}

test/rules/validate-indentation.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ describe('rules/validate-indentation', function() {
119119
379,
120120
380,
121121
386,
122-
388
122+
388,
123+
399,
124+
401,
125+
405,
126+
407
123127
]);
124128
});
125129
});

0 commit comments

Comments
 (0)