Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-eslint

Package Overview
Dependencies
Maintainers
2
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 1.0.0 to 1.1.0-rc-1

5

CHANGELOG.md
# Changelog
## 1.0.0
* Bump eslint dependency to ^1.0.0
* Update dev-dependencies and js-doc formats
## 0.15.0

@@ -4,0 +9,0 @@

52

index.js

@@ -7,2 +7,3 @@ 'use strict';

var util = require('./util');
var path = require('path');

@@ -19,17 +20,46 @@ /**

function verify(filePath, str) {
// woot! eslint now supports text processing with localized config files!
return linter.executeOnText(str, filePath).results[0];
function verify(str, filePath) {
var result = linter.executeOnText(str, filePath).results[0];
// Note: Fixes are applied as part of "executeOnText".
// Any applied fix messages have been removed from the result.
if (options.quiet) {
// ignore warnings
result = util.getQuietResult(result, options.quiet);
}
return result;
}
return util.transform(function(file, enc, cb) {
// remove base path from file path before calling isPathIgnored
if (util.isPathIgnored(file, linter.options) || file.isNull()) {
var filePath = path.relative(process.cwd(), file.path);
if (file.isNull()) {
// quietly ignore null files (read:false or directories)
cb(null, file);
} else if (linter.isPathIgnored(filePath)) {
// Note:
// Vinyl files can have an independently defined cwd, but eslint works relative to `process.cwd()`.
// (https://github.com/gulpjs/gulp/blob/master/docs/recipes/specifying-a-cwd.md)
// Also, eslint doesn't adjust file paths relative to an ancestory .eslintignore path.
// E.g., If ../.eslintignore has "foo/*.js", eslint will ignore ./foo/*.js, instead of ../foo/*.js.
// Eslint rolls this into `CLIEngine.executeOnText`. So, gulp-eslint must account for this limitation.
if (linter.options.ignore && options.warnFileIgnored) {
// Warn that gulp.src is needlessly reading files that eslint ignores
file.eslint = util.createIgnoreResult(file);
}
cb(null, file);
} else if (file.isStream()) {
// eslint is synchronous, so wait for the complete contents
// replace content stream with new readable content stream
file.contents = file.contents.pipe(new BufferStreams(function(none, buf, done) {
file.eslint = verify(file.path, String(buf));
file.contents = file.contents.pipe(new BufferStreams(function(err, buf, done) {
file.eslint = verify(String(buf), filePath);
// Update the fixed output; otherwise, fixable messages are simply ignored.
if (file.eslint.hasOwnProperty('output')) {
buf = new Buffer(file.eslint.output);
}
done(null, buf);

@@ -40,3 +70,7 @@ cb(null, file);

} else {
file.eslint = verify(file.path, file.contents.toString());
file.eslint = verify(file.contents.toString(), filePath);
// Update the fixed output; otherwise, fixable messages are simply ignored.
if (file.eslint.hasOwnProperty('output')) {
file.contents = new Buffer(file.eslint.output);
}
cb(null, file);

@@ -53,3 +87,2 @@ }

gulpEslint.failOnError = function() {
return util.transform(function(file, enc, output) {

@@ -85,3 +118,2 @@ var messages = file.eslint && file.eslint.messages || [],

var errorCount = 0;
return util.transform(function(file, enc, cb) {

@@ -88,0 +120,0 @@ var messages = file.eslint && file.eslint.messages || [];

12

package.json
{
"name": "gulp-eslint",
"version": "1.0.0",
"version": "1.1.0-rc-1",
"description": "A gulp plugin for processing files with eslint",

@@ -44,6 +44,6 @@ "repository": "adametry/gulp-eslint",

"dependencies": {
"bufferstreams": "1.0.2",
"eslint": "^1.0.0",
"bufferstreams": "^1.1.0",
"eslint": "^1.4.0",
"gulp-util": "^3.0.6",
"object-assign": "^3.0.0"
"object-assign": "^4.0.1"
},

@@ -53,3 +53,3 @@ "devDependencies": {

"gulp": "^3.9.0",
"istanbul": "^0.3.17",
"istanbul": "^0.4.0",
"istanbul-coveralls": "^1.0.3",

@@ -59,3 +59,3 @@ "jscs": "^2.0.0",

"should": "^7.0.1",
"vinyl": "^0.5.0"
"vinyl": "^1.0.0"
},

@@ -62,0 +62,0 @@ "jscsConfig": {

@@ -28,4 +28,4 @@ # gulp-eslint [![Build Status](https://travis-ci.org/adametry/gulp-eslint.svg)](https://travis-ci.org/adametry/gulp-eslint) [![Coverage Status](https://img.shields.io/coveralls/adametry/gulp-eslint.svg)](https://coveralls.io/r/adametry/gulp-eslint)

// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError());
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});

@@ -73,3 +73,3 @@

A list of rules file paths rules to import. For more information about rules, see the eslint [rules doc](https://github.com/eslint/eslint/wiki/Rules).
A list of rules file paths rules to import. For more information about rules, see the ESLint [rules](http://eslint.org/docs/rules/).

@@ -86,3 +86,3 @@ Type: `String` *(deprecated)*

Path to the eslint rules configuration file. For more information, see the eslint CLI [configFile option](https://github.com/nzakas/eslint/wiki/Command-line-interface#-c---config) and [configFile file info](https://github.com/nzakas/eslint/wiki/Command-line-interface#configuration-files). *Note:* This file must have a “.json” file extension.
Path to the ESLint rules configuration file. For more information, see the ESLint CLI [config option](http://eslint.org/docs/user-guide/command-line-interface#c-config) and [Using Configuration Files](http://eslint.org/docs/user-guide/configuring#using-configuration-files).

@@ -93,3 +93,3 @@ #### options.reset

When true, eslint will not include its default set of rules when configured.
When true, ESLint will not include its default set of rules when configured.

@@ -100,3 +100,3 @@ #### options.useEslintrc

When false, eslint will not load [.eslintrc](http://eslint.org/docs/configuring/).
When false, ESLint will not load (http://eslint.org/docs/user-guide/configuring#using-configuration-files).

@@ -109,3 +109,3 @@ Alias: `eslintrc` *(deprecated)*

Set [configuration](http://eslint.org/docs/configuring/#configuring-rules) of [rules](http://eslint.org/docs/rules/).
Set [configuration](http://eslint.org/docs/user-guide/configuring#configuring-rules) of [rules](http://eslint.org/docs/rules/).

@@ -126,3 +126,3 @@ ```javascript

Specify [globals](http://eslint.org/docs/configuring/#specifying-globals).
Specify [globals](http://eslint.org/docs/user-guide/configuring#specifying-globals).

@@ -142,7 +142,7 @@ ```javascript

Specify a list of [environments](http://eslint.org/docs/configuring/#specifying-environments) to be applied.
Specify a list of [environments](http://eslint.org/docs/user-guide/configuring#specifying-environments) to be applied.
Type: `Object`
Specify [environments](http://eslint.org/docs/configuring/#specifying-environments). Each key must match an existing env definition, and the key determines whether the env’s rules are applied (`true`) or not (`false`).
Specify [environments](http://eslint.org/docs/user-guide/configuring#specifying-environments). Each key must match an existing env definition, and the key determines whether the env’s rules are applied (`true`) or not (`false`).

@@ -159,3 +159,3 @@ Alias: `env` *(deprecated)*

Stop a task/stream if an eslint error has been reported for any file.
Stop a task/stream if an ESLint error has been reported for any file.

@@ -172,3 +172,3 @@ ```javascript

Stop a task/stream if an eslint error has been reported for any file, but wait for all of them to be processed first.
Stop a task/stream if an ESLint error has been reported for any file, but wait for all of them to be processed first.

@@ -187,3 +187,3 @@ ```javascript

The `formatter` argument may be a `String`, `Function`, or `undefined`. As a `String`, a formatter module by that name or path will be resolved as a module, relative to `process.cwd()`, or as one of the [eslint-provided formatters](https://github.com/nzakas/eslint/tree/master/lib/formatters). If `undefined`, the eslint “stylish” formatter will be resolved. A `Function` will be called with an `Array` of file linting results to format.
The `formatter` argument may be a `String`, `Function`, or `undefined`. As a `String`, a formatter module by that name or path will be resolved as a module, relative to `process.cwd()`, or as one of the [ESLint-provided formatters](https://github.com/eslint/eslint/tree/master/lib/formatters). If `undefined`, the ESLint “stylish” formatter will be resolved. A `Function` will be called with an `Array` of file linting results to format.

@@ -214,3 +214,3 @@ ```javascript

Format each linted file individually. This should be used in the stream after piping through `eslint`; otherwise, this will find no eslint results to format.
Format each linted file individually. This should be used in the stream after piping through `eslint`; otherwise, this will find no ESLint results to format.

@@ -222,9 +222,9 @@ The arguments for `formatEach` are the same as the arguments for `format`.

Eslint may be theured explicity by using any of the following plugin options: `config`, `rules`, `globals`, or `env`. When not configured in this way, eslint will attempt to resolve a file by the name of `.eslintrc` within the same directory as the file to be linted. If not found there, parent directories will be searched until `.eslintrc` is found or the directory root is reached. Any configuration will expand upon the [default eslint configuration](https://github.com/nzakas/eslint/wiki/Rules).
ESLint may be configured explicity by using any of the following plugin options: `config`, `rules`, `globals`, or `env`. When not configured in this way, ESLint will attempt to resolve a file by the name of `.eslintrc` within the same directory as the file to be linted. If not found there, parent directories will be searched until `.eslintrc` is found or the directory root is reached.
##Ignore Files
Eslint will ignore files that do not have a `.js` file extension at the point of linting ([some plugins](https://github.com/wearefractal/gulp-coffee) may change file extensions mid-stream). This avoids unintentional linting of non-JavaScript files.
ESLint will ignore files that do not have a `.js` file extension at the point of linting ([some plugins](https://github.com/wearefractal/gulp-coffee) may change file extensions mid-stream). This avoids unintentional linting of non-JavaScript files.
Eslint will also detect an `.eslintignore` file when a directory passes through the pipeline. All subsequent files that pass through may be skipped if they match any pattern found in this file. The file may contain multiple globs as strings within a JSON array:
ESLint will also detect an `.eslintignore` file when a directory passes through the pipeline. All subsequent files that pass through may be skipped if they match any pattern found in this file. The file may contain multiple globs as strings within a JSON array:

@@ -231,0 +231,0 @@ ```javascript

'use strict';
var path = require('path'),
TransformStream = require('stream').Transform,
var TransformStream = require('stream').Transform,
gutil = require('gulp-util'),
objectAssign = require('object-assign'),
CLIEngine = require('eslint').CLIEngine,
esUtil = require('eslint/lib/util'),
IgnoredPaths = require('eslint/lib/ignored-paths'),
FileFinder = require('eslint/lib/file-finder');
CLIEngine = require('eslint').CLIEngine;
var ignoreFileFinder = new FileFinder('.eslintignore');
/**

@@ -33,26 +27,21 @@ * Convenience method for creating a transform stream in object mode

/**
* Mimic the CLIEngine.isPathIgnored,
* but resolve .eslintignore based on file's directory rather than process.cwd()
* Mimic the CLIEngine's createIgnoreResult function,
* only without the eslint CLI reference.
*
* @param {Object} file - file with a "path" property
* @param {Object} options - linter options
* @returns {Boolean} Whether the path is ignored
* @returns {Object} An eslint report with an ignore warning
*/
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);
exports.createIgnoreResult = function(file) {
return {
filePath: file.path,
messages: [{
fatal: false,
severity: 1,
message: file.path.indexOf('node_modules/') < 0 ?
'File ignored because of .eslintignore file' :
'File ignored because it has a node_modules/** path'
}],
errorCount: 0,
warningCount: 1
};
};

@@ -109,2 +98,7 @@

if (options.extends) {
// nest options as baseConfig, since it's basically an .eslintrc config file
options.baseConfig = objectAssign(options.baseConfig || {}, options, {baseConfig: null});
}
return options;

@@ -119,3 +113,3 @@ };

*/
exports.isErrorMessage = function(message) {
function isErrorMessage(message) {
var level = message.fatal ? 2 : message.severity;

@@ -126,2 +120,22 @@ if (Array.isArray(level)) {

return (level > 1);
}
exports.isErrorMessage = isErrorMessage;
function reduceErrorCount(count, message) {
return count + isErrorMessage(message);
}
function reduceWarningCount(count, message) {
return count + (message.severity === 1);
}
exports.getQuietResult = function(result, filter) {
if (typeof filter !== 'function') {
filter = isErrorMessage;
}
var messages = result.messages.filter(filter);
return {
filePath: result.filePath,
messages: messages,
errorCount: messages.reduce(reduceErrorCount, 0),
warningCount: messages.reduce(reduceWarningCount, 0)
};
};

@@ -140,3 +154,3 @@

// load formatter (module, relative to cwd, eslint formatter)
formatter = (new CLIEngine()).getFormatter(formatter) || formatter;
formatter = CLIEngine.getFormatter(formatter) || formatter;
}

@@ -143,0 +157,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc