Skip to content

Commit 7bb705b

Browse files
committed
Cleanup
1 parent dbaf9d5 commit 7bb705b

File tree

6 files changed

+68
-63
lines changed

6 files changed

+68
-63
lines changed

.github/funding.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- 12
1616
steps:
1717
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v2
1919
with:
2020
node-version: ${{ matrix.node-version }}
2121
- run: npm install

gruntfile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ module.exports = grunt => {
1313
eslint: {
1414
command: 'grunt eslint',
1515
options: {
16-
callback: (err, stdout, stderr, cb) => {
16+
callback: (error, stdout, stderr, callback) => {
1717
if (/test\/fixture\/2\.js/.test(stdout)) {
1818
if (/camelcase/.test(stdout) && !/\swarning\s/.test(stdout)) {
19-
cb();
19+
callback();
2020
} else {
21-
cb(false);
21+
callback(false);
2222
}
2323
} else {
24-
cb(false);
24+
callback(false);
2525
}
2626
}
2727
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
"report"
2828
],
2929
"dependencies": {
30-
"chalk": "^4.0.0",
31-
"eslint": "^8.0.0"
30+
"chalk": "^4.1.2",
31+
"eslint": "^8.0.1"
3232
},
3333
"devDependencies": {
3434
"grunt": "^1.0.1",
35-
"grunt-cli": "^1.2.0",
35+
"grunt-cli": "^1.4.3",
3636
"grunt-shell": "^3.0.1"
3737
},
3838
"peerDependencies": {

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
## Install
88

9-
```
10-
$ npm install --save-dev grunt-eslint
9+
```sh
10+
npm install --save-dev grunt-eslint
1111
```
1212

1313
## Usage
@@ -64,7 +64,7 @@ In addition the following options are supported:
6464
Type: `string`\
6565
Default: `'stylish'`
6666

67-
Name of a [built-in formatter](https://github.com/eslint/eslint/tree/master/lib/cli-engine/formatters) or path to a custom one.
67+
The name of a [built-in formatter](https://github.com/eslint/eslint/tree/master/lib/cli-engine/formatters) or path to a custom one.
6868

6969
Some formatters you might find useful: [eslint-json](https://github.com/sindresorhus/eslint-json), [eslint-tap](https://github.com/sindresorhus/eslint-tap).
7070

@@ -87,7 +87,7 @@ Report errors only.
8787
Type: `number`\
8888
Default: `-1` *(Means no limit)*
8989

90-
Number of warnings to trigger non-zero exit code.
90+
The nmber of warnings to trigger non-zero exit code.
9191

9292
### failOnError
9393

tasks/eslint.js

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,76 @@
11
'use strict';
22
const chalk = require('chalk');
3-
const { ESLint } = require('eslint');
3+
const {ESLint} = require('eslint');
44

55
module.exports = grunt => {
6-
grunt.registerMultiTask('eslint', 'Validate files with ESLint', async function () {
6+
grunt.registerMultiTask('eslint', 'Validate files with ESLint', function () {
77
const done = this.async();
88

9-
try {
10-
const { format, quiet, maxWarnings, failOnError, outputFile, ...options } = this.options({
11-
outputFile: false,
12-
quiet: false,
13-
maxWarnings: -1,
14-
failOnError: true,
15-
format: "stylish"
16-
});
9+
(async () => {
10+
try {
11+
const {
12+
format,
13+
quiet,
14+
maxWarnings,
15+
failOnError,
16+
outputFile,
17+
...options
18+
} = this.options({
19+
outputFile: false,
20+
quiet: false,
21+
maxWarnings: -1,
22+
failOnError: true,
23+
format: 'stylish'
24+
});
1725

18-
if (this.filesSrc.length === 0) {
19-
grunt.log.writeln(chalk.magenta('Could not find any files to validate'));
20-
return true;
21-
}
26+
if (this.filesSrc.length === 0) {
27+
grunt.log.writeln(chalk.magenta('Could not find any files to validate'));
28+
return true;
29+
}
2230

23-
const engine = new ESLint(options);
31+
const engine = new ESLint(options);
2432

25-
const formatter = await engine.loadFormatter(format);
33+
const formatter = await engine.loadFormatter(format);
2634

27-
if (!formatter) {
28-
grunt.warn(`Could not find formatter ${format}`);
29-
return false;
30-
}
35+
if (!formatter) {
36+
grunt.warn(`Could not find formatter ${format}`);
37+
return false;
38+
}
3139

32-
let results = await engine.lintFiles(this.filesSrc);
40+
let results = await engine.lintFiles(this.filesSrc);
3341

34-
if (options.fix) {
35-
await ESLint.outputFixes(results);
36-
}
42+
if (options.fix) {
43+
await ESLint.outputFixes(results);
44+
}
3745

38-
if (quiet) {
39-
results = ESLint.getErrorResults(results);
40-
}
46+
if (quiet) {
47+
results = ESLint.getErrorResults(results);
48+
}
4149

42-
const output = formatter.format(results);
50+
const output = formatter.format(results);
4351

44-
if (outputFile) {
45-
grunt.file.write(outputFile, output);
46-
} else if (output) {
47-
console.log(output);
48-
}
52+
if (outputFile) {
53+
grunt.file.write(outputFile, output);
54+
} else if (output) {
55+
console.log(output);
56+
}
4957

50-
const { warningCount, errorCount } = results.reduce((count, { warningCount, errorCount }) => {
51-
count.warningCount += warningCount;
52-
count.errorCount += errorCount;
53-
return count;
54-
}, { warningCount: 0, errorCount: 0 });
58+
const {warningCount, errorCount} = results.reduce((count, {warningCount, errorCount}) => {
59+
count.warningCount += warningCount;
60+
count.errorCount += errorCount;
61+
return count;
62+
}, {warningCount: 0, errorCount: 0});
5563

56-
const tooManyWarnings = maxWarnings >= 0 && warningCount > maxWarnings;
64+
const tooManyWarnings = maxWarnings >= 0 && warningCount > maxWarnings;
5765

58-
if (errorCount === 0 && tooManyWarnings) {
59-
grunt.warn(`ESLint found too many warnings (maximum: ${maxWarnings})`);
60-
}
66+
if (errorCount === 0 && tooManyWarnings) {
67+
grunt.warn(`ESLint found too many warnings (maximum: ${maxWarnings})`);
68+
}
6169

62-
done(failOnError ? errorCount === 0 : 0);
63-
} catch (err) {
64-
done(err);
65-
}
70+
done(failOnError ? errorCount === 0 : 0);
71+
} catch (error) {
72+
done(error);
73+
}
74+
})();
6675
});
67-
};
76+
};

0 commit comments

Comments
 (0)