gulp-eslint-new 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -21
- package/index.d.ts +163 -157
- package/index.js +161 -162
- package/package.json +73 -67
- package/util.js +197 -181
package/README.md
CHANGED
|
@@ -27,17 +27,11 @@ const { src } = require('gulp');
|
|
|
27
27
|
const gulpESLintNew = require('gulp-eslint-new');
|
|
28
28
|
|
|
29
29
|
// Define the default gulp task.
|
|
30
|
-
exports.default =
|
|
31
|
-
()
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
.pipe(gulpESLintNew())
|
|
35
|
-
// gulpESLintNew.format() outputs the lint results to the console.
|
|
36
|
-
// Alternatively use gulpESLintNew.formatEach() (see docs).
|
|
37
|
-
.pipe(gulpESLintNew.format())
|
|
38
|
-
// To have the process exit with an error code (1) on lint error, return the
|
|
39
|
-
// stream and pipe to failAfterError last.
|
|
40
|
-
.pipe(gulpESLintNew.failAfterError());
|
|
30
|
+
exports.default = () => src(['scripts/*.js']) // Read files.
|
|
31
|
+
.pipe(gulpESLintNew({ fix: true })) // Lint files, create fixes.
|
|
32
|
+
.pipe(gulpESLintNew.fix()) // Fix files if necessary.
|
|
33
|
+
.pipe(gulpESLintNew.format()) // Outputs lint results to the console.
|
|
34
|
+
.pipe(gulpESLintNew.failAfterError()); // Exit with an error if problems are found.
|
|
41
35
|
```
|
|
42
36
|
|
|
43
37
|
Or use the plugin API to do things like:
|
|
@@ -46,18 +40,18 @@ Or use the plugin API to do things like:
|
|
|
46
40
|
gulp.src(['**/*.js', '!node_modules/**'])
|
|
47
41
|
.pipe(gulpESLintNew({
|
|
48
42
|
overrideConfig: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'strict': 2
|
|
43
|
+
env: {
|
|
44
|
+
browser: true,
|
|
45
|
+
commonjs: true,
|
|
46
|
+
jquery: true
|
|
54
47
|
},
|
|
48
|
+
extends: ['eslint:recommended', 'plugin:jquery/slim'],
|
|
55
49
|
globals: {
|
|
56
|
-
|
|
57
|
-
$: 'readonly'
|
|
50
|
+
chrome: 'readonly'
|
|
58
51
|
},
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
plugins: ['jquery'],
|
|
53
|
+
rules: {
|
|
54
|
+
'strict': 'error'
|
|
61
55
|
}
|
|
62
56
|
},
|
|
63
57
|
warnIgnored: true
|
|
@@ -138,7 +132,7 @@ When `gulpESLintNew` is passed any of these options, it will map them automatica
|
|
|
138
132
|
| `ignorePattern` | `overrideConfig.ignorePatterns` | New option name. |
|
|
139
133
|
| `parser` | `overrideConfig.parser` | |
|
|
140
134
|
| `parserOptions` | `overrideConfig.parserOptions` | |
|
|
141
|
-
| `plugins` | `overrideConfig.plugins` | `plugins` as an array of strings is migrated to `overrideConfig.plugins`.
|
|
135
|
+
| `plugins` | `overrideConfig.plugins` | `plugins` as an array of strings is migrated to `overrideConfig.plugins`. By contrast, `plugins` as an object that maps strings to plugin implementations has different semantics and is not migrated. |
|
|
142
136
|
| `rules` | `overrideConfig.rules` | |
|
|
143
137
|
| `warnFileIgnored` | `warnIgnored` | New option name. |
|
|
144
138
|
|
package/index.d.ts
CHANGED
|
@@ -2,171 +2,177 @@ import { ESLint, Linter } from 'eslint';
|
|
|
2
2
|
import 'node';
|
|
3
3
|
import { TransformCallback } from 'stream';
|
|
4
4
|
|
|
5
|
-
type FormatterFunction
|
|
6
|
-
|
|
5
|
+
type FormatterFunction
|
|
6
|
+
= (results: ESLint.LintResult[], data?: ESLint.LintResultData) => string | Promise<string>;
|
|
7
7
|
|
|
8
8
|
type LintResultStreamFunction<Type>
|
|
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
|
-
|
|
9
|
+
= ((action: (value: Type, callback: TransformCallback) => void) => NodeJS.ReadWriteStream)
|
|
10
|
+
& ((action: (value: Type) => unknown | Promise<unknown>) => NodeJS.ReadWriteStream);
|
|
11
|
+
|
|
12
|
+
interface LoadedFormatter {
|
|
13
|
+
format(results: ESLint.LintResult[]): string | Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type GulpESLintOptions
|
|
17
|
+
=
|
|
18
|
+
Omit<
|
|
19
|
+
ESLint.Options,
|
|
20
|
+
| 'cache'
|
|
21
|
+
| 'cacheLocation'
|
|
22
|
+
| 'cacheStrategy'
|
|
23
|
+
| 'errorOnUnmatchedPattern'
|
|
24
|
+
| 'extensions'
|
|
25
|
+
| 'globInputPaths'
|
|
26
|
+
| 'plugins'
|
|
27
|
+
>
|
|
28
|
+
& {
|
|
29
|
+
/** @deprecated Use `overrideConfigFile` instead. */
|
|
30
|
+
configFile?: ESLint.Options['overrideConfigFile'];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated
|
|
34
|
+
* Use `overrideConfig.env` or `baseConfig.env` instead.
|
|
35
|
+
* Note the different option name and format.
|
|
36
|
+
*/
|
|
37
|
+
envs?: string[] | undefined;
|
|
38
|
+
|
|
39
|
+
/** @deprecated Use `overrideConfig.extends` or `baseConfig.extends` instead. */
|
|
40
|
+
extends?: Linter.Config['extends'];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated
|
|
44
|
+
* Use `overrideConfig.globals` or `baseConfig.globals` instead. Note the different format.
|
|
45
|
+
*/
|
|
46
|
+
globals?: string[] | undefined;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated
|
|
50
|
+
* Use `overrideConfig.ignorePatterns` or `baseConfig.ignorePatterns` instead.
|
|
51
|
+
* Note the different option name.
|
|
52
|
+
*/
|
|
53
|
+
ignorePattern?: Linter.Config['ignorePatterns'];
|
|
54
|
+
|
|
55
|
+
/** @deprecated Use `overrideConfig.parser` or `baseConfig.parser` instead. */
|
|
56
|
+
parser?: Linter.Config['parser'];
|
|
57
|
+
|
|
58
|
+
/** @deprecated Use `overrideConfig.parserOptions` or `baseConfig.parserOptions` instead. */
|
|
59
|
+
parserOptions?: Linter.ParserOptions | undefined;
|
|
60
|
+
|
|
61
|
+
plugins?: ESLint.Options['plugins'] | Linter.Config['plugins'];
|
|
62
|
+
|
|
63
|
+
quiet?:
|
|
64
|
+
| boolean
|
|
65
|
+
| ((message: Linter.LintMessage, index: number, list: Linter.LintMessage[]) => unknown)
|
|
66
|
+
| undefined;
|
|
67
|
+
|
|
68
|
+
/** @deprecated Use `overrideConfig.rules` or `baseConfig.rules` instead. */
|
|
69
|
+
rules?: Linter.Config['rules'];
|
|
70
|
+
|
|
71
|
+
/** @deprecated Use `warnIgnored` instead. */
|
|
72
|
+
warnFileIgnored?: boolean | undefined;
|
|
73
|
+
|
|
74
|
+
warnIgnored?: boolean | undefined;
|
|
75
|
+
};
|
|
71
76
|
|
|
72
77
|
export type GulpESLintResult = ESLint.LintResult;
|
|
73
78
|
|
|
74
|
-
export type GulpESLintResults
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
export type GulpESLintResults
|
|
80
|
+
=
|
|
81
|
+
GulpESLintResult[] &
|
|
82
|
+
{
|
|
83
|
+
errorCount: number;
|
|
84
|
+
fatalErrorCount: number;
|
|
85
|
+
warningCount: number;
|
|
86
|
+
fixableErrorCount: number;
|
|
87
|
+
fixableWarningCount: number;
|
|
88
|
+
};
|
|
83
89
|
|
|
84
90
|
export type GulpESLintWriter = (str: string) => unknown | Promise<unknown>;
|
|
85
91
|
|
|
86
92
|
declare const gulpESLintNew: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Append ESLint result to each file.
|
|
95
|
+
*
|
|
96
|
+
* @param options - Options for gulp-eslint-new.
|
|
97
|
+
* @returns gulp file stream.
|
|
98
|
+
*/
|
|
99
|
+
(options?: GulpESLintOptions): NodeJS.ReadWriteStream;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Append ESLint result to each file.
|
|
103
|
+
*
|
|
104
|
+
* @param overrideConfigFile - The path to a configuration file.
|
|
105
|
+
* @returns gulp file stream.
|
|
106
|
+
*/
|
|
107
|
+
(overrideConfigFile?: string): NodeJS.ReadWriteStream;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handle each ESLint result as it passes through the stream.
|
|
111
|
+
*
|
|
112
|
+
* @param action - A function to handle each ESLint result.
|
|
113
|
+
* @returns gulp file stream.
|
|
114
|
+
*/
|
|
115
|
+
result: LintResultStreamFunction<GulpESLintResult>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Handle all ESLint results at the end of the stream.
|
|
119
|
+
*
|
|
120
|
+
* @param action - A function to handle all ESLint results.
|
|
121
|
+
* @returns gulp file stream.
|
|
122
|
+
*/
|
|
123
|
+
results: LintResultStreamFunction<GulpESLintResults>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Fail when an ESLint error is found in an ESLint result.
|
|
127
|
+
*
|
|
128
|
+
* @returns gulp file stream.
|
|
129
|
+
*/
|
|
130
|
+
failOnError(): NodeJS.ReadWriteStream;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Fail when the stream ends if any ESLint error(s) occurred.
|
|
134
|
+
*
|
|
135
|
+
* @returns gulp file stream.
|
|
136
|
+
*/
|
|
137
|
+
failAfterError(): NodeJS.ReadWriteStream;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Format the results of each file individually.
|
|
141
|
+
*
|
|
142
|
+
* @param formatter -
|
|
143
|
+
* A name or path of a formatter, a formatter object or a formatter function.
|
|
144
|
+
* Defaults to the [stylish](https://eslint.org/docs/user-guide/formatters/#stylish) formatter.
|
|
145
|
+
* @param writer -
|
|
146
|
+
* A funtion or stream to write the formatted ESLint results.
|
|
147
|
+
* Defaults to gulp's [fancy-log](https://github.com/gulpjs/fancy-log#readme).
|
|
148
|
+
* @returns gulp file stream.
|
|
149
|
+
*/
|
|
150
|
+
formatEach(
|
|
151
|
+
formatter?: string | LoadedFormatter | FormatterFunction,
|
|
152
|
+
writer?: GulpESLintWriter | NodeJS.WritableStream
|
|
153
|
+
): NodeJS.ReadWriteStream;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Wait until all files have been linted and format all results at once.
|
|
157
|
+
*
|
|
158
|
+
* @param formatter -
|
|
159
|
+
* A name or path of a formatter, a formatter object or a formatter function.
|
|
160
|
+
* Defaults to the [stylish](https://eslint.org/docs/user-guide/formatters/#stylish) formatter.
|
|
161
|
+
* @param writer -
|
|
162
|
+
* A funtion or stream to write the formatted ESLint results.
|
|
163
|
+
* Defaults to gulp's [fancy-log](https://github.com/gulpjs/fancy-log#readme).
|
|
164
|
+
* @returns gulp file stream.
|
|
165
|
+
*/
|
|
166
|
+
format(
|
|
167
|
+
formatter?: string | LoadedFormatter | FormatterFunction,
|
|
168
|
+
writer?: GulpESLintWriter | NodeJS.WritableStream
|
|
169
|
+
): NodeJS.ReadWriteStream;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Overwrite source files with the fixed content provided by ESLint if present.
|
|
173
|
+
*
|
|
174
|
+
* @returns gulp file stream.
|
|
175
|
+
*/
|
|
176
|
+
fix(): NodeJS.ReadWriteStream;
|
|
171
177
|
};
|
|
172
178
|
export default gulpESLintNew;
|