eslint-html-reporter
Advanced tools
Comparing version 0.4.3 to 0.4.4
{ | ||
"name": "eslint-html-reporter", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "HTML Reporter for ESLint", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,31 +17,24 @@ /** | ||
exports.sortErrors = function(a, b) { | ||
return (b.errors - a.errors); | ||
}; | ||
/** | ||
* Sort files with only warnings so the ones with the most warnings are at the top | ||
* @param {object} a - Object to compare to b | ||
* @param {object} b - Object to compare to a | ||
* @returns {int} - Value used to sort the list of files | ||
*/ | ||
exports.sortWarnings = function(a, b) { | ||
return (b.warnings - a.warnings); | ||
}; | ||
/** | ||
* Sort clean files alphabetically | ||
* @param {object} a - Object to compare to b | ||
* @param {object} b - Object to compare to a | ||
* @returns {int} - Value used to sort the list of files | ||
*/ | ||
exports.sortClean = function(a, b) { | ||
if (a.path < b.path) { | ||
return -1; | ||
} else if (a.path > b.path) { | ||
return 1; | ||
if (b.errors === 0 && a.errors === 0) { | ||
if (b.warnings === 0 && a.warnings === 0) { | ||
if (a.path < b.path) { | ||
return -1; | ||
} else if (a.path > b.path) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} else { | ||
return (b.warnings - a.warnings); | ||
} | ||
} else { | ||
return 0; | ||
if (b.errors === a.errors) { | ||
return (b.warnings - a.warnings); | ||
} else { | ||
return (b.errors - a.errors); | ||
} | ||
} | ||
}; | ||
/** | ||
@@ -48,0 +41,0 @@ * Summarize reported data |
@@ -1,41 +0,39 @@ | ||
"use strict"; | ||
var assert = require('assert'); | ||
var assert = require("assert"); | ||
var util = require('../src/js/util'); | ||
var util = require("../src/js/util"); | ||
describe("util", function() { | ||
describe("sortErrors(a, b)", function() { | ||
it("should return -1 when a.errors = 2 and b.errors = 1", function() { | ||
assert.equal(-1, util.sortErrors({ "errors": 2 }, { "errors": 1 })); | ||
describe('util', function() { | ||
describe('sortErrors(a, b)', function() { | ||
it('should return -1 when a.errors = 2 and b.errors = 1', function() { | ||
assert.equal(-1, util.sortErrors({ 'errors': 2 }, { 'errors': 1 })); | ||
}); | ||
it("should return 1 when a.errors = 1 and b.errors = 2", function() { | ||
assert.equal(1, util.sortErrors({ "errors": 1 }, { "errors": 2 })); | ||
it('should return 1 when a.errors = 1 and b.errors = 2', function() { | ||
assert.equal(1, util.sortErrors({ 'errors': 1 }, { 'errors': 2 })); | ||
}); | ||
}); | ||
describe("sortWarnings(a, b)", function() { | ||
it("should return -1 when a.warnings = 2 and b.warnings = 1", function() { | ||
assert.equal(-1, util.sortWarnings({ "warnings": 2 }, { "warnings": 1 })); | ||
// only warnings | ||
it('should return -1 when a.warnings = 2 and b.warnings = 1', function() { | ||
assert.equal(-1, util.sortErrors({ 'errors': 0, 'warnings': 2 }, { 'errors': 0, 'warnings': 1 })); | ||
}); | ||
it("should return 1 when a.warnings = 1 and b.warnings = 2", function() { | ||
assert.equal(1, util.sortWarnings({ "warnings": 1 }, { "warnings": 2 })); | ||
it('should return 1 when a.warnings = 1 and b.warnings = 2', function() { | ||
assert.equal(1, util.sortErrors({ 'warnings': 1 }, { 'warnings': 2 })); | ||
}); | ||
}); | ||
describe("sortClean(a, b)", function() { | ||
it("should return 1 when a.path = 'fileA.js' and b.path = 'fileB.js'", function() { | ||
assert.equal(-1, util.sortClean({ "path": "fileA.js" }, { "path": "fileB.js" })); | ||
// clean files | ||
it('should return 1 when a.path = "fileA.js" and b.path = "fileB.js"', function() { | ||
assert.equal(-1, util.sortErrors({ 'errors': 0, 'warnings': 0, 'path': 'fileA.js' }, { 'errors': 0, 'warnings': 0, 'path': 'fileB.js' })); | ||
}); | ||
it("should return 1 when a.path = 'fileB.js' and b.path = 'fileA.js'", function() { | ||
assert.equal(1, util.sortClean({ "path": "fileB.js" }, { "path": "fileA.js" })); | ||
it('should return 1 when a.path = "fileB.js" and b.path = "fileA.js"', function() { | ||
assert.equal(1, util.sortErrors({ 'errors': 0, 'warnings': 0, 'path': 'fileB.js' }, { 'errors': 0, 'warnings': 0, 'path': 'fileA.js' })); | ||
}); | ||
it("should return 0 when a.path = 'fileA.js' and b.path = 'fileA.js'", function() { | ||
assert.equal(0, util.sortClean({ "path": "fileA.js" }, { "path": "fileA.js" })); | ||
it('should return 0 when a.path = "fileA.js" and b.path = "fileA.js"', function() { | ||
assert.equal(0, util.sortErrors({ 'errors': 0, 'warnings': 0, 'path': 'fileA.js' }, { 'errors': 0, 'warnings': 0, 'path': 'fileA.js' })); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27
406
0
24077