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

Commit f12830a

Browse files
markeloghzoo
authored andcommitted
Internal: Checker - return correct arguments for excluded files
Fixes #1816 Closes gh-1817
1 parent 4132219 commit f12830a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/checker.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ Checker.prototype._processPath = function(path, fileHandler) {
183183
}
184184

185185
return fileHandler(path).then(function(errors) {
186-
return [errors];
186+
if (errors) {
187+
return [errors];
188+
}
189+
190+
return [];
187191
});
188192
}, this);
189193
}, this);

test/specs/checker.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
var fs = require('fs');
12
var assert = require('assert');
3+
24
var sinon = require('sinon');
5+
36
var Checker = require('../../lib/checker');
4-
var fs = require('fs');
57

68
describe('checker', function() {
79
var checker;
@@ -34,6 +36,19 @@ describe('checker', function() {
3436
assert(errors.length === 3);
3537
});
3638
});
39+
40+
it('should return empty array for excluded dir', function() {
41+
checker = new Checker();
42+
checker.registerDefaultRules();
43+
checker.configure({
44+
disallowKeywords: ['with'],
45+
excludeFiles: ['./test/**']
46+
});
47+
return checker.checkDirectory('./test/data/checker').then(function(errors) {
48+
assert(Array.isArray(errors));
49+
assert.equal(errors.length, 0);
50+
});
51+
});
3752
});
3853

3954
describe('checkPath', function() {
@@ -72,6 +87,19 @@ describe('checker', function() {
7287
assert(true);
7388
});
7489
});
90+
91+
it('should return empty array for excluded files', function() {
92+
checker = new Checker();
93+
checker.registerDefaultRules();
94+
checker.configure({
95+
disallowKeywords: ['with'],
96+
excludeFiles: ['./test/**']
97+
});
98+
return checker.checkPath('./test/data/checker/file.js').then(function(errors) {
99+
assert(Array.isArray(errors));
100+
assert.equal(errors.length, 0);
101+
});
102+
});
75103
});
76104

77105
describe('checkStdin', function() {

0 commit comments

Comments
 (0)