🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

gulp-eslint

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-eslint - npm Package Compare versions

Comparing version
0.2.0
to
0.2.2
+58
CHANGELOG.md
# Changelog
## 0.1.0
* initial plugin
## 0.1.1
* Update dependency versions
* Loosen version peer dependency on Gulp
## 0.1.2
* Update eslint version to 0.3.0
## 0.1.3
* Change default formatter to 'stylish'
* Add support for .eslintignore file
* Skip non-JS files to play well with multi-filetype streams
* Add "failOnError" method to stop streams when an eslint error has occurred
* Use gulp-util's PluginError
* Ignore shebangs in JS files
## 0.1.4
* Update eslint version to 0.4.0
## 0.1.5
* Do not format when there are no eslint'd files
## 0.1.6
* Update dependencies, include eslint 0.5.0
* Integrate eslint cli-config changes
* Accept string array of environments to enable
* Accept string array of globals ('key:boolean' or 'key')
## 0.1.7
* Open eslint dependency to future versions
* Cut out several unnecessary dependencies
* Declare eslint as a peer dependency to support variation in version
* Fix support for nodejs 0.11
## 0.1.8
* Use "dependencies" instead of "peerDependencies"
* Update .eslintrc to account for new eol-last rule in eslint 0.7.1
* Check for message.severity when evaluating messages in failOnError
## 0.2.0
* WAY overdue upgrade to eslint (^0.9.2)
* Use eslint's CLIEngine module to do most of the configuration work (yay!)
* Semi-Breaking Change: Remove gulpEslint.linter. Linting will occur with compatible, installed version of eslint.
Copyright 2013 ADAMETRY
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+40
-12

@@ -5,3 +5,4 @@ 'use strict';

PluginError = require('gulp-util').PluginError,
EsLint = require('eslint').CLIEngine,
eslint = require('eslint').linter,
CLIEngine = require('eslint').CLIEngine,
util = require('./util');

@@ -13,9 +14,12 @@

function gulpEslint(options) {
var linter = new EsLint(util.migrateOptions(options));
options = util.migrateOptions(options);
var linter = new CLIEngine(options);
function verify(filePath, contents) {
var result = linter.executeOnText(contents).results[0];
var config = linter.getConfigForFile(filePath);
var messages = eslint.verify(contents, config, filePath);
//eslint.reset();
return {
filePath: filePath,
messages: result && result.messages || []
messages: messages || []
};

@@ -25,4 +29,4 @@ }

return map(function (file, output) {
if (linter.isPathIgnored(file.path) || file.isNull()) {
// remove base path from file path before calling isPathIgnored
if (util.isPathIgnored(file, linter.options) || file.isNull()) {
output(null, file);

@@ -57,8 +61,3 @@

messages.some(function (message) {
var level = message.fatal ? 2 : message.severity;
if (Array.isArray(level)) {
level = level[0];
}
if (level > 1) {
if (util.isErrorMessage(message)) {
error = new PluginError(

@@ -82,2 +81,31 @@ 'gulp-eslint',

/**
* Fail when the stream ends if any eslint error(s) occurred
*/
gulpEslint.failAfterError = function () {
var errorCount = 0;
return map(function (file, output) {
var messages = file.eslint && file.eslint.messages || [];
messages.forEach(function (message) {
if (util.isErrorMessage(message)) {
errorCount++;
}
});
output(null, file);
}).once('end', function () {
// Only format results if files has been lint'd
if (errorCount > 0) {
this.emit('error', new PluginError(
'gulp-eslint',
{
name: 'ESLintError',
message: 'Failed with ' + errorCount + (errorCount === 1 ? ' error' : ' errors')
}
));
}
});
};
/**
* Wait until all files have been linted and format all results at once.

@@ -84,0 +112,0 @@ */

{
"name": "gulp-eslint",
"version": "0.2.0",
"version": "0.2.2",
"description": "A gulp plugin for processing files with eslint",

@@ -18,3 +18,5 @@ "main": "index.js",

"test": "mocha",
"gulp": "gulp"
"gulp": "gulp",
"throw-on-error": "gulp throw-on-error",
"throw-after-error": "gulp throw-after-error"
},

@@ -47,3 +49,3 @@ "keywords": [

"dependencies": {
"eslint": "^0.9.2",
"eslint": "^0.13.0",
"gulp-util": "^3.0.1",

@@ -50,0 +52,0 @@ "map-stream": "^0.1.0",

# 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](https://github.com/wearefractal/gulp).
> A [Gulp](https://github.com/wearefractal/gulp) plugin for [eslint](http://eslint.org/).

@@ -4,0 +4,0 @@ ## Usage

+37
-4

@@ -6,4 +6,8 @@ 'use strict';

through = require('through'),
Config = require('eslint/lib/config');
EsLint = require('eslint').CLIEngine,
IgnoredPaths = require('eslint/lib/ignored-paths'),
FileFinder = require('eslint/lib/file-finder');
var ignoreFileFinder = new FileFinder('.eslintignore');
/**

@@ -35,2 +39,21 @@ * Optional import, if not found, returns null.

/**
* Mimic the CLIEngine.isPathIgnored, but resolve .eslintignore based on file's directory rather than process.cwd()
*/
exports.isPathIgnored = function (file, options) {
var filePath;
if (!options.ignore) {
return false;
}
if (typeof options.ignorePath !== 'string') {
options = {
ignore: true,
ignorePath: ignoreFileFinder.findInDirectoryOrParents(path.dirname(file.path || ''))
};
}
// set file path relative to the .eslintignore directory or cwd
filePath = path.relative(path.dirname(options.ignorePath || '') || process.cwd(), file.path);
return IgnoredPaths.load(options).contains(filePath);
};
/**
* Create config helper to merge various config sources

@@ -92,2 +115,13 @@ */

/**
* Resolve writable
*/
exports.isErrorMessage = function (message) {
var level = message.fatal ? 2 : message.severity;
if (Array.isArray(level)) {
level = level[0];
}
return (level > 1);
};
/**
* Resolve formatter from unknown type (accepts string or function)

@@ -103,6 +137,5 @@ * @exception TypeError thrown if unable to resolve the formatter type

if (typeof formatter === 'string') {
// load formatter (module, relative to cwd, eslint formatter)
formatter = optional(formatter)
|| optional(path.resolve(process.cwd(), formatter))
|| optional('eslint/lib/formatters/' + formatter);
formatter = (new EsLint()).getFormatter(formatter);

@@ -109,0 +142,0 @@ if (typeof formatter === 'string') {