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

Commit 3e517a8

Browse files
committed
validateIndentation: ignore empty module bodies
Fixes #1034
1 parent ff6bb6c commit 3e517a8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/rules/validate-indentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ module.exports.prototype = {
365365

366366
// set number of indents for modules by detecting
367367
// whether the first statement is indented or not
368-
if (moduleBody) {
368+
if (moduleBody && moduleBody.body.length) {
369369
_this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0;
370370
}
371371
}

test/rules/validate-indentation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ describe('rules/validate-indentation', function() {
157157

158158
var cases = {
159159
'no indentation': 'a++;',
160-
indentation: ' a++;'
160+
indentation: ' a++;',
161+
'empty body': ''
161162
};
162163

163164
Object.keys(cases).forEach(function(title) {

0 commit comments

Comments
 (0)