less-terrible-coffeelint-loader
Advanced tools
Comparing version 0.1.0 to 0.1.1
15
index.js
@@ -85,3 +85,3 @@ 'use strict'; | ||
// Custom reporter. | ||
var reporter = config.reporter; | ||
var reporter = (config.reporter) ? config.reporter : defaultReporter; | ||
delete config.reporter; | ||
@@ -91,15 +91,4 @@ | ||
if (errors.length > 0) { | ||
if (reporter) { | ||
reporter.call(this, errors); | ||
} else { | ||
var emitter = emitErrors ? this.emitError : this.emitWarning; | ||
reporter.call(this, errors, emitErrors); | ||
if (emitter) { | ||
emitter(defaultReporter(errors)); | ||
} else { | ||
throw new Error('Your module system doesn\'t support emitWarning.' + | ||
' Update available? \n' + defaultReporter(errors)); | ||
} | ||
} | ||
if (failOnHint && errors.length > 0) { | ||
@@ -106,0 +95,0 @@ throw new Error('Module failed because of coffeelint error.'); |
@@ -5,4 +5,8 @@ 'use strict'; | ||
module.exports = function(errors) { | ||
return table(errors.map(function(error) { | ||
module.exports = function(errors, emitErrors) { | ||
var emitter = emitErrors ? this.emitError : this.emitWarning; | ||
var errorCount = errors.filter(function(error) { return (error.level === 'error'); }).length; | ||
var warningCount = errors.filter(function(error) { return (error.level === 'warning'); }).length; | ||
var report = table(errors.map(function(error) { | ||
var line = [ | ||
@@ -21,2 +25,20 @@ '', | ||
})); | ||
if (errors.length > 0) { | ||
report = report + | ||
'\n\n' + | ||
chalk.yellow([ | ||
'✖ ', | ||
errors.length, | ||
' problems', | ||
' (', | ||
errorCount, | ||
' errors, ', | ||
warningCount, | ||
' warnings)' | ||
].join('')); | ||
} | ||
emitter(report); | ||
}; |
{ | ||
"name": "less-terrible-coffeelint-loader", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Tommy Brunn <tommy.brunn@gmail.com", | ||
@@ -5,0 +5,0 @@ "description": "Coffeelint loader module for webpack", |
@@ -61,5 +61,5 @@ # Less Terrible Coffeelint Loader | ||
The reporter function will be passed the array returned from `coffeelint.lint`: | ||
The reporter function will be passed the array returned from `coffeelint.lint` as well as a boolean indicating whether you should `emitError` or `emitWarning`: | ||
```js | ||
[ | ||
reporter.call(this, [ | ||
{ | ||
@@ -72,3 +72,3 @@ rule : 'Name of the violated rule', | ||
} | ||
] | ||
], true); // emitErrors | ||
``` | ||
@@ -75,0 +75,0 @@ |
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
9121
7
135