Skip to content

Commit

Permalink
update dependencies and devDependencies (#224)
Browse files Browse the repository at this point in the history
Highlights:

* update ESLint form v4 to v5 https://eslint.org/docs/user-guide/migrating-to-5.0.0
* update gulp form v3 to v4

fix #228
close #229
close #230
close #231
  • Loading branch information
ehmicky authored and shinnn committed Jul 5, 2018
1 parent a58a58d commit aed571b
Show file tree
Hide file tree
Showing 13 changed files with 3,054 additions and 2,149 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
sudo: false
language: node_js
node_js:
- node
- '4'
- '6'
before_install: npm install --global npm
script: npm run-script pretest && npm run-script coverage
after_script: npx istanbul-coveralls
after_script: npx coveralls < coverage/lcov.info
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 5.0.0-0

* Bump `eslint` dependency to ^5.0.0 <https://eslint.org/blog/2018/06/eslint-v5.0.0-released>

## 4.0.2

* Update `plugin-error` to ^1.0.0
Expand Down
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# 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-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/github/adametry/gulp-eslint)

> A [gulp](https://gulpjs.com/) plugin for [ESLint](https://eslint.org/).
> A [gulp](https://gulpjs.com/) plugin for [ESLint](https://eslint.org/)
## Installation

[Use npm](https://docs.npmjs.com/cli/install).
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).

```sh
```
npm install gulp-eslint
```

## Usage

```javascript
const gulp = require('gulp');
const {src, task} = require('gulp');
const eslint = require('gulp-eslint');

gulp.task('lint', () => {
// 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/**'])
task('default', () => {
return src(['scripts/*.js'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint())
Expand All @@ -32,10 +28,6 @@ gulp.task('lint', () => {
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});

gulp.task('default', ['lint'], function () {
// This will only run if the lint task is successful...
});
```

Or use the plugin API to do things like:
Expand Down
22 changes: 11 additions & 11 deletions example/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

// npm install gulp gulp-eslint
// npm install gulp@next gulp-eslint

const gulp = require('gulp');
const {src, task} = require('gulp');
const eslint = require('..');

/**
Expand All @@ -11,8 +11,8 @@ const eslint = require('..');
* Use format or formatEach to print ESLint results.
* @returns {stream} gulp file stream
*/
gulp.task('basic', () => {
return gulp.src('../test/fixtures/**/*.js')
task('basic', () => {
return src('../test/fixtures/**/*.js')
// default: use local linting config
.pipe(eslint())
// format ESLint results and print them to the console
Expand All @@ -23,8 +23,8 @@ gulp.task('basic', () => {
* Inline ESLint configuration
* @returns {stream} gulp file stream
*/
gulp.task('inline-config', () => {
return gulp.src('../test/fixtures/**/*.js')
task('inline-config', () => {
return src('../test/fixtures/**/*.js')
.pipe(eslint({
rules: {
'no-alert': 0,
Expand Down Expand Up @@ -64,8 +64,8 @@ gulp.task('inline-config', () => {
* Load configuration file
* @returns {stream} gulp file stream
*/
gulp.task('load-config', () => {
return gulp.src('../test/fixtures/**/*.js')
task('load-config', () => {
return src('../test/fixtures/**/*.js')
.pipe(eslint({
// Load a specific ESLint config
configFile: 'config.json'
Expand All @@ -77,8 +77,8 @@ gulp.task('load-config', () => {
* Shorthand way to load a configuration file
* @returns {stream} gulp file stream
*/
gulp.task('load-config-shorthand', () => {
return gulp.src('../test/fixtures/**/*.js')
task('load-config-shorthand', () => {
return src('../test/fixtures/**/*.js')
// Load a specific ESLint config
.pipe(eslint('config.json'))
.pipe(eslint.format());
Expand All @@ -87,7 +87,7 @@ gulp.task('load-config-shorthand', () => {
/**
* The default task will run all above tasks
*/
gulp.task('default', [
task('default', [
'basic',
'inline-config',
'load-config',
Expand Down
14 changes: 7 additions & 7 deletions example/fail.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

// npm install gulp gulp-eslint
// npm install gulp@next gulp-eslint

const gulp = require('gulp');
const {src, task} = require('gulp');
const fancyLog = require('fancy-log');
const eslint = require('../');

gulp.task('fail-immediately', () => {
return gulp.src('../test/fixtures/**/*.js')
task('fail-immediately', () => {
return src('../test/fixtures/**/*.js')
.pipe(eslint())
// format one at time since this stream may fail before it can format them all at the end
.pipe(eslint.formatEach())
Expand All @@ -19,13 +19,13 @@ gulp.task('fail-immediately', () => {
});
});

gulp.task('fail-at-end', () => {
return gulp.src('../test/fixtures/**/*.js')
task('fail-at-end', () => {
return src('../test/fixtures/**/*.js')
.pipe(eslint())
// Format all results at once, at the end
.pipe(eslint.format())
// failAfterError will emit an error (fail) just before the stream finishes if any file has an error
.pipe(eslint.failAfterError());
});

gulp.task('default', ['fail-immediately']);
task('default', ['fail-immediately']);
32 changes: 12 additions & 20 deletions example/fix.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
'use strict';

// npm install gulp gulp-eslint gulp-if
// npm install gulp@next gulp-eslint gulp-if

const gulp = require('gulp');
const {dest, src, task} = require('gulp');
const gulpIf = require('gulp-if');
const eslint = require('..');

function isFixed(file) {
// Has ESLint fixed the file contents?
return file.eslint != null && file.eslint.fixed;
}

gulp.task('lint-n-fix', () => {

return gulp.src('../test/fixtures/*.js')
.pipe(eslint({
fix: true
}))
task('lint-n-fix', () => {
return src('../test/fixtures/*.js')
.pipe(eslint({fix: true}))
.pipe(eslint.format())
// if fixed, write the file to dest
.pipe(gulpIf(isFixed, gulp.dest('../test/fixtures')));
.pipe(gulpIf(isFixed, dest('../test/fixtures')));
});

gulp.task('flag-n-fix', () => {
// This is a *very* basic CLI flag check.
// For a more robust method, check out [yargs](https://www.npmjs.com/package/yargs)
const hasFixFlag = (process.argv.slice(2).indexOf('--fix') >= 0);
task('flag-n-fix', () => {
const hasFixFlag = process.argv.slice(2).includes('--fix');

return gulp.src('../test/fixtures/*.js')
.pipe(eslint({
fix: hasFixFlag
}))
return src('../test/fixtures/*.js')
.pipe(eslint({fix: hasFixFlag}))
.pipe(eslint.format())
// if fixed, write the file to dest
.pipe(gulpIf(isFixed, gulp.dest('../test/fixtures')));
.pipe(gulpIf(isFixed, dest('../test/fixtures')));
});

gulp.task('default', ['lint-n-fix']);
task('default', ['lint-n-fix']);
15 changes: 7 additions & 8 deletions example/format.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';

// npm install gulp gulp-eslint
// npm install gulp@next gulp-eslint

const gulp = require('gulp');
const {src, task} = require('gulp');
const eslint = require('..');


gulp.task('eslint-formatter', () => {
task('eslint-formatter', () => {
// lint each file, and format all files at once (mul)
return gulp.src('../test/fixtures/**/*.js')
return src('../test/fixtures/**/*.js')
.pipe(eslint())
// use eslint's default formatter by default
.pipe(eslint.format())
Expand All @@ -17,7 +16,7 @@ gulp.task('eslint-formatter', () => {
.pipe(eslint.format('compact'));
});

gulp.task('custom-formatter', () => {
task('custom-formatter', () => {
function embolden(text) {
return `\u001b[1m${text}\u001b[22m `;
}
Expand All @@ -26,7 +25,7 @@ gulp.task('custom-formatter', () => {
return `${count} ${text}${count === 1 ? '' : 's'}`;
}

return gulp.src('../test/fixtures/**/*.js')
return src('../test/fixtures/**/*.js')
.pipe(eslint())
.pipe(eslint.format(results => {

Expand All @@ -38,4 +37,4 @@ gulp.task('custom-formatter', () => {
}));
});

gulp.task('default', ['eslint-formatter','custom-formatter']);
task('default', ['eslint-formatter','custom-formatter']);
25 changes: 9 additions & 16 deletions example/quiet.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
'use strict';

// npm install gulp gulp-eslint
// npm install gulp@next gulp-eslint

const gulp = require('gulp');
const {src, task} = require('gulp');
const eslint = require('..');

gulp.task('quiet-lint', () => {
return gulp.src('../test/fixtures/*.js')
.pipe(eslint({
// only report errors
quiet: true
}))
task('quiet-lint', () => {
return src('../test/fixtures/*.js')
.pipe(eslint({quiet: true}))
.pipe(eslint.format());
});



function isWarning(message) {
return message.severity === 1;
}

gulp.task('lint-warnings', () => {
return gulp.src('../test/fixtures/*.js')
.pipe(eslint({
quiet: isWarning
}))
task('lint-warnings', () => {
return src('../test/fixtures/*.js')
.pipe(eslint({quiet: isWarning}))
.pipe(eslint.format());
});

gulp.task('default', ['quiet-lint','lint-warnings']);
task('default', ['quiet-lint','lint-warnings']);
30 changes: 13 additions & 17 deletions example/result.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
'use strict';

// npm install gulp gulp-eslint
// npm install gulp@next gulp-eslint

const gulp = require('gulp');
const {src, task} = require('gulp');
const eslint = require('..');

const MAX_WARNINGS = 1;


gulp.task('lint-result', () => {
task('lint-result', () => {
const count = 0;

// Be sure to return the stream; otherwise, you may not get a proper exit code.
return gulp.src('../test/fixtures/*.js')
return src('../test/fixtures/*.js')
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.result(result => {
Expand All @@ -31,18 +30,18 @@ gulp.task('lint-result', () => {
}));
});

gulp.task('lint-resu1lt-async', () => {
const count = 0;
task('lint-resu1lt-async', () => {
let count = 0;

return gulp.src('../test/fixtures/*.js')
return src('../test/fixtures/*.js')
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.result((result, done) => {
// As a basic example, we'll use process.nextTick as an async process.
process.nextTick(function asyncStub() {
count += result.warningCount;

const error = null;
let error = null;
if (count > MAX_WARNINGS) {
// Define the error. Any non-null/undefined value will work
error = {
Expand All @@ -53,14 +52,12 @@ gulp.task('lint-resu1lt-async', () => {
};
}
done(error);

}, 100);

}));
});

gulp.task('lint-results', () => {
return gulp.src('../test/fixtures/*.js')
task('lint-results', () => {
return src('../test/fixtures/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.results(results => {
Expand All @@ -73,8 +70,8 @@ gulp.task('lint-results', () => {
}));
});

gulp.task('lint-results-async', () => {
return gulp.src('../test/fixtures/*.js')
task('lint-results-async', () => {
return src('../test/fixtures/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.results((results, done) => {
Expand All @@ -87,8 +84,7 @@ gulp.task('lint-results-async', () => {
done(error);

}, 100);

}));
});

gulp.task('default', ['lint-results']);
task('default', ['lint-results']);
Loading

0 comments on commit aed571b

Please sign in to comment.