-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulp-eslint7+0.3.1.patch
70 lines (63 loc) · 2.72 KB
/
gulp-eslint7+0.3.1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
diff --git a/node_modules/gulp-eslint7/index.js b/node_modules/gulp-eslint7/index.js
index 533550e..7592722 100644
--- a/node_modules/gulp-eslint7/index.js
+++ b/node_modules/gulp-eslint7/index.js
@@ -70,6 +70,11 @@ function gulpEslint(options) {
const { eslintOptions, quiet, warnIgnored } = migrateOptions(options);
const linter = new ESLint(eslintOptions);
+ // yes that's ugly, we'll see for a better solution in a PR
+ resolveFormatter(linter, "stylish").then(formatter => {
+ gulpEslint.formatter = formatter;
+ })
+
return transform((file, enc, cb) => {
lintFile(linter, file, quiet, warnIgnored)
.then(() => cb(null, file))
@@ -174,10 +179,9 @@ gulpEslint.failAfterError = () => {
* @returns {stream} gulp file stream
*/
gulpEslint.formatEach = (formatter, writable) => {
- formatter = resolveFormatter(formatter);
writable = resolveWritable(writable);
- return gulpEslint.result(result => writeResults([result], formatter, writable));
+ return gulpEslint.result(result => writeResults([result], gulpEslint.formatter, writable));
};
/**
@@ -188,13 +192,12 @@ gulpEslint.formatEach = (formatter, writable) => {
* @returns {stream} gulp file stream
*/
gulpEslint.format = (formatter, writable) => {
- formatter = resolveFormatter(formatter);
writable = resolveWritable(writable);
return gulpEslint.results(results => {
// Only format results if files has been lint'd
if (results.length) {
- writeResults(results, formatter, writable);
+ writeResults(results, gulpEslint.formatter, writable);
}
});
};
diff --git a/node_modules/gulp-eslint7/util.js b/node_modules/gulp-eslint7/util.js
index bf44540..9635b59 100644
--- a/node_modules/gulp-eslint7/util.js
+++ b/node_modules/gulp-eslint7/util.js
@@ -282,11 +282,11 @@ exports.filterResult = (result, filter) => {
* @param {(String|Function)} [formatter=stylish] - A name to resolve as a formatter. If a function is provided, the same function is returned.
* @returns {Function} An ESLint formatter
*/
-exports.resolveFormatter = (formatter) => {
+exports.resolveFormatter = async (linter, formatter) => {
// use ESLint to look up formatter references
if (typeof formatter !== 'function') {
// load formatter (module, relative to cwd, ESLint formatter)
- formatter = CLIEngine.getFormatter(formatter);
+ formatter = linter.loadFormatter(formatter);
}
return formatter;
@@ -321,7 +321,7 @@ exports.writeResults = (results, formatter, writable) => {
const firstResult = results.find(result => result.config);
- const message = formatter(results, firstResult ? firstResult.config : {});
+ const message = formatter.format(results, firstResult ? firstResult.config : {});
if (writable && message != null && message !== '') {
writable(message);
}