Skip to content

Commit

Permalink
Merge 3cbb5cf into 52a5143
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed Jun 14, 2021
2 parents 52a5143 + 3cbb5cf commit 8eb8a53
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ analyzer.prototype = {
var rule = require("./../rules/" + name);
rule(this);

debug('"%s" loaded: %s', name, rule.description || "-");
debug('"%s" loaded: %s', name, rule.description);
}, this);
},

Expand Down Expand Up @@ -209,6 +209,7 @@ analyzer.prototype = {
this.emit("media", rule.media, rule.rules);

// now run recursively to parse rules within the media query
/* istanbul ignore else */
if (rule.rules) {
this.parseRules(rule.rules);
}
Expand Down
1 change: 1 addition & 0 deletions lib/preprocessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ preprocessors.prototype = {
files = glob.sync(__dirname + "/preprocessors/*.js");
debug("Initializing...");

/* istanbul ignore next */
if (Array.isArray(files)) {
files.forEach(function (file) {
res.push(require(file));
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@
},
"jest": {
"verbose": true,
"coveragePathIgnorePatterns": [
"test/"
],
"coverageThreshold": {
"global": {
"statements": 99,
"branches": 95,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 99
"lines": 100
}
}
}
Expand Down
1 change: 1 addition & 0 deletions rules/duplicated.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function rule(analyzer) {
analyzer.on("rule", function (rule) {
var propertiesHash = {};

/* istanbul ignore else */
if (rule.declarations) {
rule.declarations.forEach(function (declaration) {
var propertyName;
Expand Down
2 changes: 1 addition & 1 deletion rules/mediaQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function rule(analyzer) {
analyzer.incrMetric("mediaQueries");
analyzer.addOffender(
"mediaQueries",
format("@media %s (%d rules)", query, (rules && rules.length) || 0)
format("@media %s (%d rules)", query, rules.length)
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion rules/propertyResets.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function rule(analyzer) {
analyzer.setMetric("propertyResets");

analyzer.on("selector", function (rule, selector) {
var declarations = rule.declarations || [],
var declarations = rule.declarations,
properties;

// prepare the list of properties used in this selector
Expand Down
1 change: 1 addition & 0 deletions rules/specificity.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function rule(analyzer) {
var selectorSpecificity = specificity.calculate(selector),
parts;

/* istanbul ignore if */
if (!selectorSpecificity) {
debug("not counted for %s!", selector);
return;
Expand Down
14 changes: 14 additions & 0 deletions test/sass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,18 @@ describe('SASS preprocessor [' + (isSassInstalled ? 'node-sass installed' : 'nod
preprocessor: 'sass'
}, done);
});

it('should report parsing error when provided an incorrect syntax', done => {
try {
new analyzer("bar {foo--}", {
preprocessor: 'sass'
}, done);
}
catch (err) {
assert.ok(err instanceof Error);
assert.ok(err.message.indexOf("Preprocessing failed:") === 0);
done();
}
});

});

0 comments on commit 8eb8a53

Please sign in to comment.