mocha-eslint
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,7 +5,11 @@ # mocha-eslint Changelog | ||
### v.0.1.1 | ||
### v0.1.2 | ||
* [ENHANCEMENT] Add ability to pass glob patterns as arguments | ||
* [BUGFIX] Display ESLint warnings even if tests pass | ||
### v0.1.1 | ||
* [ENHANCEMENT] Added acceptance tests | ||
### v.0.1.0 | ||
### v0.1.0 | ||
* [BUGFIX] Removed template strings for Node compatibility | ||
* [ENHANCEMENT] Added badges to readme |
58
index.js
var CLIEngine = require('eslint').CLIEngine; | ||
var chalk = require('chalk'); | ||
var glob = require('glob'); | ||
var cli = new CLIEngine({}); | ||
var format = ''; | ||
var format; | ||
module.exports = function (paths, options) { | ||
function test(p) { | ||
it('should have no errors in ' + p, function () { | ||
try { | ||
var report = cli.executeOnFiles([p]); | ||
var formatter = cli.getFormatter(format); | ||
} catch (err) { | ||
throw new Error(err); | ||
} | ||
if ( | ||
report && | ||
report.errorCount > 0 | ||
) { | ||
throw new Error( | ||
chalk.red('Code did not pass lint rules') + | ||
formatter(report.results) | ||
); | ||
} else if ( | ||
report && | ||
report.warningCount > 0 | ||
) { | ||
console.log(formatter(report.results)); | ||
} | ||
}); | ||
} | ||
module.exports = function (patterns, options) { | ||
if (options && options.formatter) { | ||
@@ -11,22 +39,12 @@ format = options.formatter; | ||
describe('eslint', function () { | ||
paths.forEach(function (p) { | ||
it('should have no errors in ' + p, function () { | ||
try { | ||
var report = cli.executeOnFiles([p]); | ||
var formatter = cli.getFormatter(format); | ||
} catch (err) { | ||
throw new Error(err); | ||
} | ||
if ( | ||
report && | ||
report.errorCount > 0 | ||
) { | ||
throw new Error( | ||
chalk.red('Code did not pass lint rules') + | ||
formatter(report.results) | ||
); | ||
} | ||
}); | ||
patterns.forEach(function (pattern) { | ||
if (glob.hasMagic(pattern)) { | ||
glob.sync(pattern).forEach(function (file) { | ||
test(file); | ||
}); | ||
} else { | ||
test(pattern); | ||
} | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "mocha-eslint", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "run ESLint as mocha tests", | ||
@@ -22,3 +22,3 @@ "main": "index.js", | ||
"mocha": "^2.0", | ||
"glob": "4.0.5" | ||
"glob": "5.0.3" | ||
}, | ||
@@ -25,0 +25,0 @@ "repository": { |
@@ -37,2 +37,24 @@ /*eslint-env node, mocha */ | ||
}); | ||
it('should display warnings if no errors are present, but still pass', function (done) { | ||
runTest('tests/lint/warningLintTest.js', function (results) { | ||
if (results[2].indexOf('warning') === -1) { | ||
throw new Error('Did not give a warning'); | ||
} | ||
if (results[4].indexOf('1 passing') === -1) { | ||
throw new Error('Did not pass test'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
it('should accept glob patterns', function (done) { | ||
runTest('tests/lint/globLintTest.js', function (results) { | ||
if (results[3].indexOf('1 passing') === -1 || | ||
results[4].indexOf('1 failing') === -1) { | ||
throw new Error('Did not get a single pass and single failure'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); |
/*eslint no-process-exit:0*/ | ||
'use strict'; | ||
var glob = require('glob'); | ||
var Mocha = require('mocha'); | ||
@@ -6,0 +5,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29716
23
210