Socket
Socket
Sign inDemoInstall

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.1.0-rc-3 to 1.1.0

11

CHANGELOG.md
# Changelog
## 1.1.0
* Bump eslint dependency to ^1.4.0, when "fix" option was added
* Apply eslint-fixed source to gulp file contents
* Add "quiet" option to filter eslint messages
* Update .eslintignore resolution to match eslint
* Add file ignore warnings behind "warnFileIgnored" option
* Migrate "ecmaFeatures" and "extends" option to "baseConfig" option
* Add "result" and "results" methods and tests
* Refactor "failOnError", "failAfterError", "format", and "formatEach" to use "result" or "results" methods
## 1.0.0

@@ -4,0 +15,0 @@

2

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

@@ -5,0 +5,0 @@ "repository": "adametry/gulp-eslint",

@@ -20,3 +20,7 @@ # 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)

gulp.task('lint', function () {
return gulp.src(['js/**/*.js'])
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
return gulp.src(['**/*.js','!node_modules/**'])
// eslint() attaches the lint output to the "eslint" property

@@ -41,7 +45,4 @@ // of the file object so it can be used by other modules.

```javascript
gulp.src('js/**/*.js')
gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint({
// "expree" is installed with ESLint.
// Any other parser will need to be installed.
parser: 'espree',
extends: 'eslint:recommended',

@@ -51,5 +52,2 @@ ecmaFeatures: {

},
rulePaths: [
'custom-rules/'
],
rules: {

@@ -70,2 +68,4 @@ 'my-custom-rule': 1,

For additional examples, look through the [example directory](https://github.com/adametry/gulp-eslint/tree/master/example).
## API

@@ -79,34 +79,2 @@

#### options.rulePaths
Type: `Array`
A list of rules file paths rules to import. For more information about rules, see the ESLint [rules](http://eslint.org/docs/rules/).
Type: `String` *(deprecated)*
Load a single rules file.
Alias: `rulesdir` *(deprecated)*
#### options.configFile
Type: `String`
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).
#### options.reset
Type: `Boolean`
When true, ESLint will not include its default set of rules when configured.
#### options.useEslintrc
Type: `Boolean`
When false, ESLint will not load (http://eslint.org/docs/user-guide/configuring#using-configuration-files).
Alias: `eslintrc` *(deprecated)*
#### options.rules

@@ -143,2 +111,20 @@

#### options.fix
Type: `Boolean`
This option instructs ESLint to try to fix as many issues as possible. The fixes are applied to the gulp stream. The fixed content can be saved to file using `gulp.dest` (See [example/fix.js](https://github.com/adametry/gulp-eslint/blob/master/example/fix.js)). Rules that are fixable can be found in ESLint's [rules list](http://eslint.org/docs/rules/).
When fixes are applied, a "fixed" property is set to `true` on the fixed file's ESLint result.
#### options.quiet
Type: `Boolean`
When `true`, this option will filter warning messages from ESLint results. This mimics the ESLint CLI [quiet option](http://eslint.org/docs/user-guide/command-line-interface#quiet).
Type: `function (message, index, list) { return Boolean(); }`
When provided a function, it will be used to filter ESLint result messages, removing any messages that do not return a `true` (or truthy) value.
#### options.envs

@@ -156,2 +142,34 @@

#### options.rulePaths
Type: `Array`
This option allows you to specify additional directories from which to load rules files. This is useful when you have custom rules that aren't suitable for being bundled with ESLint. This option works much like the ESLint CLI's [rulesdir option](http://eslint.org/docs/user-guide/command-line-interface#rulesdir).
Type: `String` *(deprecated)*
Load a single rules file.
Alias: `rulesdir` *(deprecated)*
#### options.configFile
Type: `String`
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).
#### options.warnFileIgnored
Type: `Boolean`
When `true`, add a result warning when ESLint ignores a file. This can be used to file files that are needlessly being loaded by `gulp.src`. For example, since ESLint automatically ignores "node_modules" file paths and gulp.src does not, a gulp task may take seconds longer just reading files from the "node_modules" directory.
#### <a name="options.useEslintrc"></a>options.useEslintrc
Type: `Boolean`
When `false`, ESLint will not load [.eslintrc files](http://eslint.org/docs/user-guide/configuring#using-configuration-files).
Alias: `eslintrc` *(deprecated)*
### eslint(configFilePath)

@@ -163,2 +181,48 @@

### eslint.result(action)
Type: `function (result) {}`
Call a function for each ESLint file result. No returned value is expected. If an error is thrown, it will be wrapped in a Gulp PluginError and emitted from the stream.
```javascript
gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.result(function (result) {
// Called for each ESLint result.
console.log('ESLint result: ' + result.filePath);
console.log('# Messages: ' + result.messages.length);
console.log('# Warnings: ' + result.warningCount);
console.log('# Errors: ' + result.errorCount);
}));
```
Type: `function (result, callback) { callback(error); }`
Call an asynchronous function for each ESLint file result. The callback must be called for the stream to finish. If a value is passed to the callback, it will be wrapped in a Gulp PluginError and emitted from the stream.
### eslint.results(action)
Type: `function (results) {}`
Call a function once for all ESLint file results before a stream finishes. No returned value is expected. If an error is thrown, it will be wrapped in a Gulp PluginError and emitted from the stream.
The results list has a "warningCount" property that is the sum of warnings in all results; likewise, an "errorCount" property is set to the sum of errors in all results.
```javascript
gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.results(function (results) {
// Called once for all ESLint results.
console.log('Total Results: ' + results.length);
console.log('Total Warnings: ' + result.warningCount);
console.log('Total Errors: ' + result.errorCount);
}));
```
Type: `function (results, callback) { callback(error); }`
Call an asynchronous function once for all ESLint file results before a stream finishes. The callback must be called for the stream to finish. If a value is passed to the callback, it will be wrapped in a Gulp PluginError and emitted from the stream.
### eslint.failOnError()

@@ -170,6 +234,5 @@

// Cause the stream to stop(/fail) before copying an invalid JS file to the output directory
gulp.src('**/*.js')
gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.failOnError())
.pipe(gulp.dest('../output'));
.pipe(eslint.failOnError());
```

@@ -183,6 +246,5 @@

// Cause the stream to stop(/fail) when the stream ends if any ESLint error(s) occurred.
gulp.src('**/*.js')
gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.failAfterError())
.pipe(gulp.dest('../output'));
.pipe(eslint.failAfterError());
```

@@ -227,3 +289,3 @@

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.
ESLint may be configured explicity by using any of the following plugin options: `config`, `rules`, `globals`, or `env`. If the [useEslintrc option](#useEslintrc) is not set to `false`, 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.

@@ -234,6 +296,9 @@ ##Ignore 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 at the cwd or a parent directory. See the [ESLint docs](http://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories) to learn how to construct this file.
```javascript
['**/*.min.js','output/**/*']
```
## Extensions
ESLint results are attached as an "eslint" property to the vinyl files that pass through a Gulp.js stream pipeline. This is available to streams that follow the initial `eslint` stream. The [eslint.result](#result) and [eslint.results](#results) methods are made available to support extensions and custom handling of ESLint results.
#### Gulp-Eslint Extensions:
* [gulp-eslint-threshold](https://github.com/krmbkt/gulp-eslint-threshold)
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