Skip to content

Commit

Permalink
✅ Add Test for Empty File
Browse files Browse the repository at this point in the history
Only run parsing for files with stuff in them

Resolves sasstools#91
  • Loading branch information
Snugug committed Sep 6, 2015
1 parent e7d65d9 commit e5dfcd6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
25 changes: 14 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ sassLint.lintText = function (file, options, configPath) {
errors = 0,
warnings = 0;

rules.forEach(function (rule) {
detects = rule.rule.detect(ast, rule);
results = results.concat(detects);
if (detects.length) {
if (rule.severity === 1) {
warnings += detects.length;
if (ast.content.length > 0) {
rules.forEach(function (rule) {
detects = rule.rule.detect(ast, rule);
results = results.concat(detects);
if (detects.length) {
if (rule.severity === 1) {
warnings += detects.length;
}
else if (rule.severity === 2) {
errors += detects.length;
}
}
else if (rule.severity === 2) {
errors += detects.length;
}
}
});
});
}


results.sort(helpers.sortDetects);

Expand Down
9 changes: 9 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,4 +1057,13 @@ describe('rule', function () {
done();
});
});

it('should not error if a file is empty', function (done) {
lintFile('empty-file.scss', function (data) {
assert.equal(0, data.warningCount);
assert.equal(0, data.errorCount);
assert.equal(0, data.messages.length);
done();
});
});
});
Empty file added tests/sass/empty-file.scss
Empty file.

0 comments on commit e5dfcd6

Please sign in to comment.