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

Commit

Permalink
Require Node.js 10 and upgrade XO
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 3, 2020
1 parent 98b15a1 commit dd16768
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
- '6'
12 changes: 6 additions & 6 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ module.exports = grunt => {
xo: {
command: 'grunt xo',
options: {
callback(_, stdout, stderr, cb) {
if (/test\/fixture\.js/.test(stdout)) {
if (/camelcase/.test(stdout) && /no-unused-vars/.test(stdout)) {
cb();
callback(_, stdout, stderr, done) {
if (stdout.includes('test/fixture.js')) {
if (stdout.includes('camelcase') && stdout.includes('no-unused-vars')) {
done();
} else {
cb(false);
done(false);
}
} else {
cb(false);
done(false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

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:

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"description": "Validate files with XO",
"license": "MIT",
"repository": "xojs/grunt-xo",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=10"
},
"scripts": {
"test": "xo --ignore=test/fixture.js && grunt"
Expand Down Expand Up @@ -47,7 +48,7 @@
"simple"
],
"dependencies": {
"xo": "^0.24.0"
"xo": "^0.32.0"
},
"devDependencies": {
"grunt": "^1.0.1",
Expand Down
16 changes: 4 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# grunt-xo [![Build Status](https://travis-ci.org/xojs/grunt-xo.svg?branch=master)](https://travis-ci.org/xojs/grunt-xo)
# grunt-xo [![Build Status](https://travis-ci.com/xojs/grunt-xo.svg?branch=master)](https://travis-ci.com/github/xojs/grunt-xo)

> Validate files with [XO](https://github.com/xojs/xo)
Expand All @@ -8,14 +8,12 @@ Please consider if you really need Grunt for this. Using a [npm run script](http

*Issues regarding rules should be reported on the ESLint [issue tracker](https://github.com/eslint/eslint/issues) as it's the actual linter.*


## Install

```
$ npm install --save-dev grunt-xo
```


## Usage

```js
Expand All @@ -33,7 +31,6 @@ grunt.initConfig({
grunt.registerTask('default', ['xo']);
```


## Options

XO [options](https://github.com/xojs/xo#config) can be specified in package.json.
Expand All @@ -42,8 +39,8 @@ In the Gruntfile you can specify the following options:

##### reporter

Type: `string`<br>
Default: [`eslint-formatter-pretty`](https://github.com/sindresorhus/eslint-formatter-pretty)
Type: `string`\
Default: [`'eslint-formatter-pretty'`](https://github.com/sindresorhus/eslint-formatter-pretty)

Any [ESLint reporter](http://eslint.org/docs/user-guide/command-line-interface#f---format).

Expand All @@ -55,12 +52,7 @@ Output the report to a file.

### quiet

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

Report errors only.


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)
42 changes: 23 additions & 19 deletions tasks/xo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,40 @@ const xo = require('xo');

module.exports = grunt => {
grunt.registerMultiTask('xo', 'Validate files with XO', function () {
const cb = this.async();
const opts = this.options({
const done = this.async();

const options = this.options({
outputFile: false,
quiet: false
});

if (this.filesSrc.length === 0) {
cb();
done();
return;
}

xo.lintFiles(this.filesSrc).then(report => {
let {results} = report;
(async () => {
try {
const report = await xo.lintFiles(this.filesSrc);
let {results} = report;

if (opts.quiet) {
results = xo.getErrorResults(results);
}
if (options.quiet) {
results = xo.getErrorResults(results);
}

const output = xo.getFormatter(opts.reporter)(results);
const output = xo.getFormatter(options.reporter)(results);

if (opts.outputFile) {
grunt.file.write(opts.outputFile, output);
} else {
console.log(output);
}
if (options.outputFile) {
grunt.file.write(options.outputFile, output);
} else {
console.log(output);
}

cb(report.errorCount === 0);
}).catch(error => {
grunt.warn(error);
cb();
});
done(report.errorCount === 0);
} catch (error) {
grunt.warn(error);
done();
}
})();
});
};

0 comments on commit dd16768

Please sign in to comment.