gulp-eslint
Advanced tools
Comparing version 0.3.0 to 0.4.0
49
index.js
'use strict'; | ||
var map = require('map-stream'), | ||
var through = require('through2'), | ||
BufferStreams = require('bufferstreams'), | ||
PluginError = require('gulp-util').PluginError, | ||
@@ -28,6 +29,6 @@ eslint = require('eslint').linter, | ||
return map(function (file, output) { | ||
return through.obj(function(file, enc, cb) { | ||
// remove base path from file path before calling isPathIgnored | ||
if (util.isPathIgnored(file, linter.options) || file.isNull()) { | ||
output(null, file); | ||
cb(null, file); | ||
@@ -37,11 +38,11 @@ } else if (file.isStream()) { | ||
// replace content stream with new readable content stream | ||
file.contents = file.contents.pipe(util.wait(function (contents) { | ||
file.eslint = verify(file.path, contents); | ||
output(null, file); | ||
file.contents = file.contents.pipe(new BufferStreams(function(none, buf, done) { | ||
file.eslint = verify(file.path, String(buf)); | ||
cb(null, file); | ||
done(null, buf); | ||
})); | ||
} else { | ||
file.eslint = verify(file.path, file.contents.toString('utf8')); | ||
output(null, file); | ||
file.eslint = verify(file.path, file.contents.toString()); | ||
cb(null, file); | ||
} | ||
@@ -55,9 +56,9 @@ }); | ||
*/ | ||
gulpEslint.failOnError = function () { | ||
gulpEslint.failOnError = function() { | ||
return map(function (file, output) { | ||
return through.obj(function(file, enc, output) { | ||
var messages = file.eslint && file.eslint.messages || [], | ||
error = null; | ||
messages.some(function (message) { | ||
messages.some(function(message) { | ||
if (util.isErrorMessage(message)) { | ||
@@ -84,8 +85,8 @@ error = new PluginError( | ||
*/ | ||
gulpEslint.failAfterError = function () { | ||
gulpEslint.failAfterError = function() { | ||
var errorCount = 0; | ||
return map(function (file, output) { | ||
return through.obj(function(file, enc, cb) { | ||
var messages = file.eslint && file.eslint.messages || []; | ||
messages.forEach(function (message) { | ||
messages.forEach(function(message) { | ||
if (util.isErrorMessage(message)) { | ||
@@ -95,5 +96,5 @@ errorCount++; | ||
}); | ||
output(null, file); | ||
cb(null, file); | ||
}).once('end', function () { | ||
}).once('end', function() { | ||
// Only format results if files has been lint'd | ||
@@ -115,3 +116,3 @@ if (errorCount > 0) { | ||
*/ | ||
gulpEslint.format = function (formatter, writable) { | ||
gulpEslint.format = function(formatter, writable) { | ||
var results = []; | ||
@@ -121,9 +122,9 @@ formatter = util.resolveFormatter(formatter); | ||
return map(function (file, output) { | ||
return through.obj(function(file, enc, cb) { | ||
if (file.eslint) { | ||
results.push(file.eslint); | ||
} | ||
output(null, file); | ||
cb(null, file); | ||
}).once('end', function () { | ||
}).once('finish', function() { | ||
// Only format results if files has been lint'd | ||
@@ -141,7 +142,7 @@ if (results.length) { | ||
*/ | ||
gulpEslint.formatEach = function (formatter, writable) { | ||
gulpEslint.formatEach = function(formatter, writable) { | ||
formatter = util.resolveFormatter(formatter); | ||
writable = util.resolveWritable(writable); | ||
return map(function (file, output) { | ||
return through.obj(function(file, enc, cb) { | ||
var error = null; | ||
@@ -155,3 +156,3 @@ if (file.eslint) { | ||
} | ||
output(error, file); | ||
cb(error, file); | ||
}); | ||
@@ -158,0 +159,0 @@ }; |
{ | ||
"name": "gulp-eslint", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A gulp plugin for processing files with eslint", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/adametry/gulp-eslint" | ||
}, | ||
"homepage": "http://github.com/adametry/gulp-eslint", | ||
"bugs": "https://github.com/adametry/gulp-eslint/issues", | ||
"repository": "adametry/gulp-eslint", | ||
"files": [ | ||
"index.js", | ||
"util.js" | ||
], | ||
"directories": { | ||
@@ -17,2 +15,3 @@ "example": "example", | ||
"scripts": { | ||
"pretest": "jscs *.js test/*.js && eslint *.js test/*.js", | ||
"test": "mocha", | ||
@@ -39,22 +38,32 @@ "gulp": "gulp", | ||
], | ||
"engines": { | ||
"node": ">=0.9" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"util.js" | ||
"author": "Adametry", | ||
"contribtutor": "Shinnosuke Watanabe <snnskwtnb@gmail.com> (https://github.com/shinnn)", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/adametry/gulp-eslint/blob/master/LICENSE" | ||
} | ||
], | ||
"author": "Adametry", | ||
"license": "MIT", | ||
"dependencies": { | ||
"eslint": "^0.13.0", | ||
"bufferstreams": "0.0.2", | ||
"eslint": "^0.14.0", | ||
"gulp-util": "^3.0.1", | ||
"map-stream": "^0.1.0", | ||
"through": "^2.3.4" | ||
"through2": "^0.6.3" | ||
}, | ||
"devDependencies": { | ||
"gulp": "*", | ||
"jscs": "^1.11.0", | ||
"mocha": "*", | ||
"should": "^4.0.4" | ||
"should": "^4.6.5", | ||
"through": "^2.3.6" | ||
}, | ||
"jscsConfig": { | ||
"preset": "google", | ||
"validateIndentation": "\t", | ||
"disallowMultipleVarDecl": null, | ||
"maximumLineLength": { | ||
"value": 98, | ||
"allowComments": true | ||
} | ||
} | ||
} |
@@ -1,4 +0,5 @@ | ||
# gulp-eslint [![Build Status](https://travis-ci.org/adametry/gulp-eslint.png)](https://travis-ci.org/adametry/gulp-eslint) | ||
> A [Gulp](https://github.com/wearefractal/gulp) plugin for [eslint](http://eslint.org/). | ||
# gulp-eslint [![Build Status](https://travis-ci.org/adametry/gulp-eslint.svg)](https://travis-ci.org/adametry/gulp-eslint) | ||
> A [gulp](http://gulpjs.com/) plugin for [ESLint](http://eslint.org/). | ||
## Usage | ||
@@ -5,0 +6,0 @@ |
31
util.js
@@ -5,3 +5,2 @@ 'use strict'; | ||
gutil = require('gulp-util'), | ||
through = require('through'), | ||
CLIEngine = require('eslint').CLIEngine, | ||
@@ -25,19 +24,5 @@ IgnoredPaths = require('eslint/lib/ignored-paths'), | ||
/** | ||
* Variation on event-stream's "wait" method that returns a "reset" stream. | ||
*/ | ||
exports.wait = function wait(cb) { | ||
var content = new Buffer([]); | ||
return through(function bufferData(data) { | ||
content = Buffer.concat([content, data]); | ||
this.queue(data); | ||
}, function releaseData() { | ||
cb(content.toString()); | ||
this.emit('end'); | ||
}); | ||
}; | ||
/** | ||
* Mimic the CLIEngine.isPathIgnored, but resolve .eslintignore based on file's directory rather than process.cwd() | ||
*/ | ||
exports.isPathIgnored = function (file, options) { | ||
exports.isPathIgnored = function(file, options) { | ||
var filePath; | ||
@@ -61,6 +46,6 @@ if (!options.ignore) { | ||
*/ | ||
exports.loadPlugins = function (pluginNames) { | ||
exports.loadPlugins = function(pluginNames) { | ||
// WARNING: HACK AHEAD! | ||
// We can either process text/file, or create a new CLIEngine instance to make use of the internal plugin cache. | ||
// Creating a new CLIEngine is probably the cheapest approach. | ||
// Creating a new CLIEngine is probably the cheapest approach. | ||
return pluginNames && new CLIEngine({ | ||
@@ -130,3 +115,3 @@ plugins: pluginNames | ||
*/ | ||
exports.isErrorMessage = function (message) { | ||
exports.isErrorMessage = function(message) { | ||
var level = message.fatal ? 2 : message.severity; | ||
@@ -143,3 +128,3 @@ if (Array.isArray(level)) { | ||
*/ | ||
exports.resolveFormatter = function (formatter) { | ||
exports.resolveFormatter = function(formatter) { | ||
if (!formatter) { | ||
@@ -176,3 +161,3 @@ // default formatter | ||
*/ | ||
exports.resolveWritable = function (writable) { | ||
exports.resolveWritable = function(writable) { | ||
if (!writable) { | ||
@@ -189,3 +174,3 @@ writable = gutil.log; | ||
*/ | ||
exports.writeResults = function (results, formatter, writable) { | ||
exports.writeResults = function(results, formatter, writable) { | ||
var config; | ||
@@ -196,3 +181,3 @@ if (!results) { | ||
// get the first result config | ||
results.some(function (result) { | ||
results.some(function(result) { | ||
config = result && result.config; | ||
@@ -199,0 +184,0 @@ return config; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
212
19154
5
291
2
2
1
+ Addedbufferstreams@0.0.2
+ Addedthrough2@^0.6.3
+ Addedbufferstreams@0.0.2(transitive)
+ Addedeslint@0.14.1(transitive)
+ Addedglobals@6.4.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedthrough2@0.6.5(transitive)
- Removedmap-stream@^0.1.0
- Removedthrough@^2.3.4
- Removedeslint@0.13.0(transitive)
- Removedglobals@5.1.0(transitive)
- Removedmap-stream@0.1.0(transitive)
- Removedthrough@2.3.8(transitive)
Updatedeslint@^0.14.0