Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Upgrade gulp-eslint and require Gulp 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 18, 2019
1 parent 3fdfdee commit 976be86
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const gulp = require('gulp');
const xo = require('.');

gulp.task('default', () =>
exports.default = () => (
gulp.src('_fixture.js')
.pipe(xo())
.pipe(xo.format())
Expand Down
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ const xo = require('xo');
const PluginError = require('plugin-error');

module.exports = options => {
options = Object.assign({
quiet: false
}, options);
options = {
quiet: false,
...options
};

return through.obj(function (file, enc, cb) {
return through.obj(function (file, encoding, callback) {
if (file.isNull()) {
cb(null, file);
callback(null, file);
return;
}

if (file.isStream()) {
cb(new PluginError('gulp-xo', 'Streaming not supported'));
callback(new PluginError('gulp-xo', 'Streaming not supported'));
return;
}

let report;

try {
report = xo.lintText(file.contents.toString(), {
cwd: file.cwd,
filename: file.path,
fix: options.fix
});
} catch (err) {
this.emit('error', new PluginError('gulp-xo', err, {fileName: file.path}));
} catch (error) {
this.emit('error', new PluginError('gulp-xo', error, {fileName: file.path}));
}

let result = report.results;

if (result.length === 0) {
cb(null, file);
callback(null, file);
return;
}

Expand All @@ -51,7 +51,7 @@ module.exports = options => {
file.eslint.fixed = true;
}

cb(null, file);
callback(null, file);
});
};

Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "ava"
Expand Down Expand Up @@ -48,21 +48,24 @@
],
"dependencies": {
"eslint-formatter-pretty": "^2.0.0",
"gulp-eslint": "^5.0.0",
"gulp-eslint": "^6.0.0",
"plugin-error": "^1.0.1",
"through2": "^3.0.0",
"xo": "^0.24.0"
},
"devDependencies": {
"ava": "^1.1.0",
"ava": "^2.3.0",
"gulp": "^4.0.0",
"p-event": "^2.1.0",
"p-event": "^4.1.0",
"vinyl": "^2.1.0",
"vinyl-file": "^3.0.0"
},
"peerDependencies": {
"gulp": ">=4"
},
"xo": {
"ignores": [
"test/fixture/**"
"test/_fixture.js"
]
}
}
13 changes: 5 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ npm install --save-dev gulp-xo
const gulp = require('gulp');
const xo = require('gulp-xo');

gulp.task('default', () =>
exports.default = () => (
gulp.src('src/app.js')
.pipe(xo())
.pipe(xo.format())
Expand All @@ -31,11 +31,13 @@ gulp.task('default', () =>

## API

### xo([options])
### xo(options?)

#### options

##### options.fix
Type: `object`

##### fix

Type: `boolean`

Expand Down Expand Up @@ -67,8 +69,3 @@ Report errors only.

- [gulp-eslint](https://github.com/adametry/gulp-eslint) - Gulp plugin for ESLint
- [gulp-reporter](https://github.com/gucong3000/gulp-reporter) - Error reporter for CSSLint, EditorConfig, ESLint, HTMLHint, PostCSS, TSLint, XO


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

0 comments on commit 976be86

Please sign in to comment.