gulp-eslint-new 1.3.0 → 1.4.2

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.
Files changed (5) hide show
  1. package/README.md +22 -55
  2. package/index.d.ts +48 -20
  3. package/index.js +75 -57
  4. package/package.json +10 -8
  5. package/util.js +14 -18
package/README.md CHANGED
@@ -46,6 +46,8 @@ Or use the plugin API to do things like:
46
46
  gulp.src(['**/*.js', '!node_modules/**'])
47
47
  .pipe(gulpESLintNew({
48
48
  overrideConfig: {
49
+ plugins: ['json'],
50
+ extends: ['plugin:json/recommended'],
49
51
  rules: {
50
52
  'my-custom-rule': 1,
51
53
  'strict': 2
@@ -75,7 +77,7 @@ For additional examples, look through the [example directory](https://github.com
75
77
 
76
78
  Param type: `Object`
77
79
 
78
- Supported options include all [linting options][linting options] and [autofix options](https://eslint.org/docs/developer-guide/nodejs-api#autofix) of the `ESLint` constructor.
80
+ Supported options include all [linting options](https://eslint.org/docs/developer-guide/nodejs-api#linting) and [autofix options](https://eslint.org/docs/developer-guide/nodejs-api#autofix) of the `ESLint` constructor.
79
81
  Please, refer to the ESLint documentation for information about the usage of those options.
80
82
  Check also the notes about the [Autofix Function](#autofix-function).
81
83
  Additionally, gulp-eslint-new supports the options listed below.
@@ -100,7 +102,7 @@ When `false`, ESLint will not respect `.eslintignore` files or ignore patterns i
100
102
 
101
103
  ##### `options.ignorePath`
102
104
 
103
- Type: `string | null`
105
+ Type: `string`
104
106
 
105
107
  The path to a file ESLint uses instead of `.eslintignore` in the current working directory.
106
108
 
@@ -124,62 +126,28 @@ For example, since ESLint automatically ignores file paths inside a `node_module
124
126
 
125
127
  #### Legacy Options
126
128
 
127
- The following options are provided for backward compatibility with [gulp-eslint][gulp-eslint].
128
- Their usage is discouraged because preferable alternatives exist, that are more in line with the present ESLint conventions.
129
-
130
- ##### `options.configFile`
131
-
132
- Type: `string`
133
-
134
- _A legacy synonym for `options.overrideConfigFile` (see [linting options][linting options])._
135
-
136
- ##### `options.envs`
137
-
138
- Type: `string[]`
139
-
140
- Specify a list of environments to be applied.
141
-
142
- _Prefer using [`options.overrideConfig.env`](https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments) instead. Note the different option name and format._
143
-
144
- ##### `options.globals`
145
-
146
- Type: `string[]`
147
-
148
- Specify a list of global variables to declare.
149
- Variables declared with this option are considered readonly.
150
-
151
- _Prefer using [`options.overrideConfig.globals`](https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals) instead. Note the different format._
152
-
153
- ##### `options.parser`
154
-
155
- Type: `string`
156
-
157
- _Prefer using [`options.overrideConfig.parser`](https://eslint.org/docs/user-guide/configuring/plugins#specifying-parser) instead._
158
-
159
- ##### `options.parserOptions`
160
-
161
- Type: `Object`
162
-
163
- _Prefer using [`options.overrideConfig.parserOptions`](https://eslint.org/docs/user-guide/configuring/language-options#specifying-parser-options) instead._
164
-
165
- ##### `options.rules`
166
-
167
- Type: `Object`
168
-
169
- _Prefer using [`options.overrideConfig.rules`](https://eslint.org/docs/user-guide/configuring/rules) instead._
170
-
171
- ##### `options.warnFileIgnored`
172
-
173
- Type: `boolean`
174
-
175
- _A legacy synonym for [`options.warnIgnored`](#optionswarnignored)._
129
+ The following legacy options are provided for backward compatibility with [gulp-eslint][gulp-eslint].
130
+ When `gulpESLintNew` is passed any of these options, it will map them automatically as shown in the table to match the new ESLint conventions.
131
+
132
+ | Legacy option | Migrated to | Notes |
133
+ |-------------------|---------------------------------|-|
134
+ | `configFile` | `overrideConfigFile` | New option name. |
135
+ | `envs` | `overrideConfig.env` | New option name and format. `overrideConfig.env` should be an object as explained in the [documentation](https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments). |
136
+ | `extends` | `overrideConfig.extends` | |
137
+ | `globals` | `overrideConfig.globals` | The new option format requires `overrideConfig.globals` to be an object as explained in the [documentation](https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals). |
138
+ | `ignorePattern` | `overrideConfig.ignorePatterns` | New option name. |
139
+ | `parser` | `overrideConfig.parser` | |
140
+ | `parserOptions` | `overrideConfig.parserOptions` | |
141
+ | `plugins` | `overrideConfig.plugins` | `plugins` as an array of strings is migrated to `overrideConfig.plugins`. In contrast, `plugins` as an object that maps strings to plugin implementations has different semantics and is not migrated. |
142
+ | `rules` | `overrideConfig.rules` | |
143
+ | `warnFileIgnored` | `warnIgnored` | New option name. |
176
144
 
177
145
  #### Autofix Function
178
146
 
179
147
  When the `fix` option is specified, fixes are applied to the gulp stream.
180
148
  The fixed content can be saved to file using [`gulpESLintNew.fix()`](#gulpeslintnewfix) (See [example/fix.js](https://github.com/fasttime/gulp-eslint-new/blob/main/example/fix.js)).
181
149
  Rules that are fixable can be found in ESLint's [rules list](https://eslint.org/docs/rules/).
182
- When fixes are applied, a "fixed" property is set to `true` on the fixed file's ESLint result.
150
+ When fixes are applied, a `fixed` property is set to `true` on the fixed file's ESLint result.
183
151
 
184
152
  ### `gulpESLintNew(overrideConfigFile)`
185
153
 
@@ -337,7 +305,7 @@ gulpESLintNew.format('junit', process.stdout)
337
305
  Format each linted file individually.
338
306
  This should be used in the stream after piping through `gulpESLintNew`; otherwise, this will find no ESLint results to format.
339
307
 
340
- The arguments for `formatEach` are the same as the arguments for `format`.
308
+ The arguments for `gulpESLintNew.formatEach` are the same as the arguments for [`gulpESLintNew.format`](#gulpeslintnewformatformatter-writer).
341
309
 
342
310
  ### `gulpESLintNew.fix()`
343
311
 
@@ -359,9 +327,8 @@ ESLint may be configured explicity by using any of the supported [configuration
359
327
 
360
328
  ESLint results are attached as an `eslint` property to the Vinyl files that pass through a gulp stream pipeline.
361
329
  This is available to streams that follow the initial gulp-eslint-new stream.
362
- The [`gulpESLintNew.result`](#gulpeslintnewresultaction) and [`gulpESLintNew.results`](#gulpeslintnewresultsaction) methods are made available to support extensions and custom handling of ESLint results.
330
+ The functions [`gulpESLintNew.result`](#gulpeslintnewresultaction) and [`gulpESLintNew.results`](#gulpeslintnewresultsaction) are made available to support extensions and custom handling of ESLint results.
363
331
 
364
332
  [gulp-eslint]: https://github.com/adametry/gulp-eslint
365
- [linting options]: https://eslint.org/docs/developer-guide/nodejs-api#linting
366
333
  [npm badge]: https://badge.fury.io/js/gulp-eslint-new.svg
367
334
  [npm URL]: https://www.npmjs.com/package/gulp-eslint-new
package/index.d.ts CHANGED
@@ -2,8 +2,12 @@ import { ESLint, Linter } from 'eslint';
2
2
  import 'node';
3
3
  import { TransformCallback } from 'stream';
4
4
 
5
- export type GulpESLintAction<Type>
6
- = ((value: Type, callback: TransformCallback) => unknown) | ((value: Type) => Promise<unknown>);
5
+ type FormatterFunction =
6
+ (results: ESLint.LintResult[], data?: ESLint.LintResultData) => string | Promise<string>;
7
+
8
+ type LintResultStreamFunction<Type>
9
+ = ((action: (value: Type, callback: TransformCallback) => void) => NodeJS.ReadWriteStream)
10
+ & ((action: (value: Type) => unknown | Promise<unknown>) => NodeJS.ReadWriteStream);
7
11
 
8
12
  export type GulpESLintOptions =
9
13
  Omit<
@@ -14,33 +18,50 @@ export type GulpESLintOptions =
14
18
  | 'errorOnUnmatchedPattern'
15
19
  | 'extensions'
16
20
  | 'globInputPaths'
21
+ | 'plugins'
17
22
  >
18
23
  & {
19
24
  /** @deprecated Use `overrideConfigFile` instead. */
20
- configFile?: string | undefined;
25
+ configFile?: ESLint.Options['overrideConfigFile'];
21
26
 
22
27
  /**
23
28
  * @deprecated
24
- * Use `overrideConfig.env` instead. Note the different option name and format.
29
+ * Use `overrideConfig.env` or `baseConfig.env` instead.
30
+ * Note the different option name and format.
25
31
  */
26
32
  envs?: string[] | undefined;
27
33
 
28
- /** @deprecated Use `overrideConfig.globals` instead. Note the different format. */
34
+ /** @deprecated Use `overrideConfig.extends` or `baseConfig.extends` instead. */
35
+ extends?: Linter.Config['extends'];
36
+
37
+ /**
38
+ * @deprecated
39
+ * Use `overrideConfig.globals` or `baseConfig.globals` instead. Note the different format.
40
+ */
29
41
  globals?: string[] | undefined;
30
42
 
31
- /** @deprecated Use `overrideConfig.parser` instead. */
32
- parser?: string | undefined;
43
+ /**
44
+ * @deprecated
45
+ * Use `overrideConfig.ignorePatterns` or `baseConfig.ignorePatterns` instead.
46
+ * Note the different option name.
47
+ */
48
+ ignorePattern?: Linter.Config['ignorePatterns'];
33
49
 
34
- /** @deprecated Use `overrideConfig.parserOptions` instead. */
50
+ /** @deprecated Use `overrideConfig.parser` or `baseConfig.parser` instead. */
51
+ parser?: Linter.Config['parser'];
52
+
53
+ /** @deprecated Use `overrideConfig.parserOptions` or `baseConfig.parserOptions` instead. */
35
54
  parserOptions?: Linter.ParserOptions | undefined;
36
55
 
56
+ plugins?: ESLint.Options['plugins'] | Linter.Config['plugins'];
57
+
37
58
  quiet?:
38
59
  | boolean
39
60
  | ((message: Linter.LintMessage, index: number, list: Linter.LintMessage[]) => unknown)
40
61
  | undefined;
41
62
 
42
- /** @deprecated Use `overrideConfig.rules` instead. */
43
- rules?: Partial<Linter.RulesRecord> | undefined;
63
+ /** @deprecated Use `overrideConfig.rules` or `baseConfig.rules` instead. */
64
+ rules?: Linter.Config['rules'];
44
65
 
45
66
  /** @deprecated Use `warnIgnored` instead. */
46
67
  warnFileIgnored?: boolean | undefined;
@@ -66,7 +87,7 @@ declare const gulpESLintNew: {
66
87
  /**
67
88
  * Append ESLint result to each file.
68
89
  *
69
- * @param options Options for gulp-eslint-new.
90
+ * @param options - Options for gulp-eslint-new.
70
91
  * @returns gulp file stream.
71
92
  */
72
93
  (options?: GulpESLintOptions): NodeJS.ReadWriteStream;
@@ -74,7 +95,7 @@ declare const gulpESLintNew: {
74
95
  /**
75
96
  * Append ESLint result to each file.
76
97
  *
77
- * @param overrideConfigFile The path to a configuration file.
98
+ * @param overrideConfigFile - The path to a configuration file.
78
99
  * @returns gulp file stream.
79
100
  */
80
101
  (overrideConfigFile?: string): NodeJS.ReadWriteStream;
@@ -85,7 +106,7 @@ declare const gulpESLintNew: {
85
106
  * @param action - A function to handle each ESLint result.
86
107
  * @returns gulp file stream.
87
108
  */
88
- result(action: GulpESLintAction<GulpESLintResult>): NodeJS.ReadWriteStream;
109
+ result: LintResultStreamFunction<GulpESLintResult>;
89
110
 
90
111
  /**
91
112
  * Handle all ESLint results at the end of the stream.
@@ -93,7 +114,7 @@ declare const gulpESLintNew: {
93
114
  * @param action - A function to handle all ESLint results.
94
115
  * @returns gulp file stream.
95
116
  */
96
- results(action: GulpESLintAction<GulpESLintResults>): NodeJS.ReadWriteStream;
117
+ results: LintResultStreamFunction<GulpESLintResults>;
97
118
 
98
119
  /**
99
120
  * Fail when an ESLint error is found in an ESLint result.
@@ -112,33 +133,40 @@ declare const gulpESLintNew: {
112
133
  /**
113
134
  * Format the results of each file individually.
114
135
  *
115
- * @param formatter
136
+ * @param formatter -
116
137
  * A name or path of a formatter, a formatter object or a formatter function.
117
138
  * Defaults to the [stylish](https://eslint.org/docs/user-guide/formatters/#stylish) formatter.
118
- * @param writer
139
+ * @param writer -
119
140
  * A funtion or stream to write the formatted ESLint results.
120
141
  * Defaults to gulp's [fancy-log](https://github.com/gulpjs/fancy-log#readme).
121
142
  * @returns gulp file stream.
122
143
  */
123
144
  formatEach(
124
- formatter?: string | ESLint.Formatter | ESLint.Formatter['format'],
145
+ formatter?: string | ESLint.Formatter | FormatterFunction,
125
146
  writer?: GulpESLintWriter | NodeJS.WritableStream
126
147
  ): NodeJS.ReadWriteStream;
127
148
 
128
149
  /**
129
150
  * Wait until all files have been linted and format all results at once.
130
151
  *
131
- * @param formatter
152
+ * @param formatter -
132
153
  * A name or path of a formatter, a formatter object or a formatter function.
133
154
  * Defaults to the [stylish](https://eslint.org/docs/user-guide/formatters/#stylish) formatter.
134
- * @param writer
155
+ * @param writer -
135
156
  * A funtion or stream to write the formatted ESLint results.
136
157
  * Defaults to gulp's [fancy-log](https://github.com/gulpjs/fancy-log#readme).
137
158
  * @returns gulp file stream.
138
159
  */
139
160
  format(
140
- formatter?: string | ESLint.Formatter | ESLint.Formatter['format'],
161
+ formatter?: string | ESLint.Formatter | FormatterFunction,
141
162
  writer?: GulpESLintWriter | NodeJS.WritableStream
142
163
  ): NodeJS.ReadWriteStream;
164
+
165
+ /**
166
+ * Overwrite source files with the fixed content provided by ESLint if present.
167
+ *
168
+ * @returns gulp file stream.
169
+ */
170
+ fix(): NodeJS.ReadWriteStream;
143
171
  };
144
172
  export default gulpESLintNew;
package/index.js CHANGED
@@ -9,6 +9,7 @@ const {
9
9
  hasOwn,
10
10
  isErrorMessage,
11
11
  migrateOptions,
12
+ resolveFormatter,
12
13
  resolveWriter,
13
14
  writeResults
14
15
  } = require('./util');
@@ -16,14 +17,6 @@ const { ESLint } = require('eslint');
16
17
  const { promisify } = require('util');
17
18
  const { dest } = require('vinyl-fs');
18
19
 
19
- function getESLintInfo(file) {
20
- const eslintInfo = file._eslintInfo;
21
- if (eslintInfo != null) {
22
- return eslintInfo;
23
- }
24
- throw createPluginError({ fileName: file.path, message: 'ESLint information not available' });
25
- }
26
-
27
20
  function wrapAction(action) {
28
21
  if (typeof action !== 'function') {
29
22
  throw TypeError('Argument is not a function');
@@ -34,6 +27,52 @@ function wrapAction(action) {
34
27
  return action;
35
28
  }
36
29
 
30
+ const createResultStream = action => {
31
+ action = wrapAction(action);
32
+ return createTransform(
33
+ async file => {
34
+ const { eslint } = file;
35
+ if (eslint) {
36
+ await action(eslint);
37
+ }
38
+ }
39
+ );
40
+ };
41
+
42
+ const createResultsStream = action => {
43
+ action = wrapAction(action);
44
+ const results = [];
45
+ results.errorCount = 0;
46
+ results.warningCount = 0;
47
+ results.fixableErrorCount = 0;
48
+ results.fixableWarningCount = 0;
49
+ results.fatalErrorCount = 0;
50
+ return createTransform(
51
+ ({ eslint }) => {
52
+ if (eslint) {
53
+ results.push(eslint);
54
+ // Collect total error/warning count.
55
+ results.errorCount += eslint.errorCount;
56
+ results.warningCount += eslint.warningCount;
57
+ results.fixableErrorCount += eslint.fixableErrorCount;
58
+ results.fixableWarningCount += eslint.fixableWarningCount;
59
+ results.fatalErrorCount += eslint.fatalErrorCount;
60
+ }
61
+ },
62
+ async () => {
63
+ await action(results);
64
+ }
65
+ );
66
+ };
67
+
68
+ function getESLintInfo(file) {
69
+ const eslintInfo = file._eslintInfo;
70
+ if (eslintInfo != null) {
71
+ return eslintInfo;
72
+ }
73
+ throw createPluginError({ fileName: file.path, message: 'ESLint information not available' });
74
+ }
75
+
37
76
  async function lintFile(eslintInfo, file, quiet, warnIgnored) {
38
77
  if (file.isNull()) {
39
78
  return;
@@ -83,45 +122,11 @@ module.exports = exports = options => {
83
122
  return createTransform(file => lintFile(eslintInfo, file, quiet, warnIgnored));
84
123
  };
85
124
 
86
- exports.result = action => {
87
- action = wrapAction(action);
88
- return createTransform(
89
- async file => {
90
- const { eslint } = file;
91
- if (eslint) {
92
- await action(eslint);
93
- }
94
- }
95
- );
96
- };
125
+ exports.result = createResultStream;
97
126
 
98
- exports.results = action => {
99
- action = wrapAction(action);
100
- const results = [];
101
- results.errorCount = 0;
102
- results.warningCount = 0;
103
- results.fixableErrorCount = 0;
104
- results.fixableWarningCount = 0;
105
- results.fatalErrorCount = 0;
106
- return createTransform(
107
- ({ eslint }) => {
108
- if (eslint) {
109
- results.push(eslint);
110
- // Collect total error/warning count.
111
- results.errorCount += eslint.errorCount;
112
- results.warningCount += eslint.warningCount;
113
- results.fixableErrorCount += eslint.fixableErrorCount;
114
- results.fixableWarningCount += eslint.fixableWarningCount;
115
- results.fatalErrorCount += eslint.fatalErrorCount;
116
- }
117
- },
118
- async () => {
119
- await action(results);
120
- }
121
- );
122
- };
127
+ exports.results = createResultsStream;
123
128
 
124
- exports.failOnError = () => exports.result(result => {
129
+ function failOnErrorAction(result) {
125
130
  const { messages } = result;
126
131
  if (messages) {
127
132
  const error = messages.find(isErrorMessage);
@@ -134,30 +139,46 @@ exports.failOnError = () => exports.result(result => {
134
139
  });
135
140
  }
136
141
  }
137
- });
142
+ }
138
143
 
139
- exports.failAfterError = () => exports.results(({ errorCount }) => {
144
+ exports.failOnError = () => createResultStream(failOnErrorAction);
145
+
146
+ function failAfterErrorAction({ errorCount }) {
140
147
  if (errorCount) {
141
148
  throw createPluginError({
142
149
  name: 'ESLintError',
143
150
  message: `Failed with ${errorCount} ${errorCount === 1 ? 'error' : 'errors'}`
144
151
  });
145
152
  }
146
- });
153
+ }
154
+
155
+ exports.failAfterError = () => createResultsStream(failAfterErrorAction);
147
156
 
148
157
  exports.formatEach = (formatter, writer) => {
149
158
  writer = resolveWriter(writer);
159
+ const eslintToFormatterMap = new Map();
150
160
  return createTransform(
151
161
  async file => {
152
- const { eslint } = file;
153
- if (eslint) {
162
+ const result = file.eslint;
163
+ if (result) {
154
164
  const eslintInfo = getESLintInfo(file);
155
- await writeResults([eslint], eslintInfo, formatter, writer);
165
+ const { eslint } = eslintInfo;
166
+ let formatterObj = eslintToFormatterMap.get(eslint);
167
+ if (!formatterObj) {
168
+ formatterObj = await resolveFormatter(eslintInfo, formatter);
169
+ eslintToFormatterMap.set(eslint, formatterObj);
170
+ }
171
+ await writeResults([result], formatterObj, writer);
156
172
  }
157
173
  }
158
174
  );
159
175
  };
160
176
 
177
+ const ERROR_MULTIPLE_ESLINT_INSTANCES = {
178
+ name: 'ESLintError',
179
+ message: 'The files in the stream were not processed by the same instance of ESLint'
180
+ };
181
+
161
182
  exports.format = (formatter, writer) => {
162
183
  writer = resolveWriter(writer);
163
184
  const results = [];
@@ -171,11 +192,7 @@ exports.format = (formatter, writer) => {
171
192
  commonInfo = eslintInfo;
172
193
  } else {
173
194
  if (eslintInfo !== commonInfo) {
174
- throw createPluginError({
175
- name: 'ESLintError',
176
- message: 'The files in the stream were not processed by the same '
177
- + 'instance of ESLint'
178
- });
195
+ throw createPluginError(ERROR_MULTIPLE_ESLINT_INSTANCES);
179
196
  }
180
197
  }
181
198
  results.push(eslint);
@@ -183,7 +200,8 @@ exports.format = (formatter, writer) => {
183
200
  },
184
201
  async () => {
185
202
  if (results.length) {
186
- await writeResults(results, commonInfo, formatter, writer);
203
+ const formatterObj = await resolveFormatter(commonInfo, formatter);
204
+ await writeResults(results, formatterObj, writer);
187
205
  }
188
206
  }
189
207
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gulp-eslint-new",
3
- "version": "1.3.0",
3
+ "version": "1.4.2",
4
4
  "description": "A gulp plugin to lint code with ESLint 8",
5
5
  "keywords": [
6
6
  "gulpplugin",
@@ -35,25 +35,27 @@
35
35
  "build": "npm install && gulp",
36
36
  "coverage": "c8 --reporter=html --reporter=text-summary npm test",
37
37
  "lint": "eslint .",
38
- "test": "mocha --check-leaks test/*.spec.js"
38
+ "test": "mocha --check-leaks test/*.spec.js",
39
+ "ts-test": "tsc --noEmit --strict test/ts-defs-test.ts"
39
40
  },
40
41
  "dependencies": {
41
42
  "@types/eslint": "^8.4.1",
42
- "@types/node": "^17.0.15",
43
- "eslint": "^8.8.0",
43
+ "@types/node": "^17.0.21",
44
+ "eslint": "^8.10.0",
44
45
  "fancy-log": "^2.0.0",
45
46
  "plugin-error": "^1.0.1",
46
47
  "ternary-stream": "^3.0.0",
47
48
  "vinyl-fs": "^3.0.3"
48
49
  },
49
50
  "devDependencies": {
50
- "@typescript-eslint/eslint-plugin": "^5.10.2",
51
- "@typescript-eslint/parser": "^5.10.2",
51
+ "@typescript-eslint/eslint-plugin": "^5.12.1",
52
+ "@typescript-eslint/parser": "^5.12.1",
52
53
  "c8": "^7.11.0",
53
54
  "eslint-plugin-eslint-comments": "^3.2.0",
55
+ "eslint-plugin-tsdoc": "^0.2.14",
54
56
  "gulp": "^4.0.2",
55
- "mocha": "^9.1.4",
56
- "typescript": "^4.5.4",
57
+ "mocha": "^9.2.1",
58
+ "typescript": "^4.5.5",
57
59
  "vinyl": "^2.2.1"
58
60
  },
59
61
  "engines": {
package/util.js CHANGED
@@ -1,13 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * @typedef {import('eslint').ESLint} ESLint
5
- * @typedef {import('eslint').ESLint.Formatter} ESLint.Formatter
6
- * @typedef {import('eslint').ESLint.LintResult} ESLint.LintResult
7
- * @typedef {ESLint.Formatter['format']} FormatterFunction
8
- * @typedef {import('.').GulpESLintWriter} GulpESLintWriter
9
- * @typedef {import('eslint').Linter} Linter
10
- * @typedef {import('eslint').Linter.LintMessage} Linter.LintMessage
4
+ * @typedef {import('eslint').ESLint} ESLint
5
+ * @typedef {import('eslint').ESLint.Formatter} ESLint.Formatter
6
+ * @typedef {import('eslint').ESLint.LintResult} ESLint.LintResult
7
+ * @typedef {import('.').GulpESLintWriter} GulpESLintWriter
8
+ * @typedef {import('eslint').Linter} Linter
9
+ * @typedef {import('eslint').Linter.LintMessage} Linter.LintMessage
11
10
  */
12
11
 
13
12
  const fancyLog = require('fancy-log');
@@ -71,7 +70,7 @@ function isWarningMessage({ severity }) {
71
70
  * @param {{ cwd: string, eslint: ESLint }} eslintInfo
72
71
  * Current directory and instance of ESLint used to load and configure the formatter.
73
72
  *
74
- * @param {string|ESLint.Formatter|FormatterFunction} [formatter]
73
+ * @param {string|ESLint.Formatter|Function} [formatter]
75
74
  * A name or path of a formatter, a formatter object or a formatter function.
76
75
  *
77
76
  * @returns {Promise<ESLint.Formatter>} An ESLint formatter.
@@ -286,9 +285,9 @@ function throwInvalidOptionError(message) {
286
285
  /**
287
286
  * Convert a string array to a boolean map.
288
287
  *
289
- * @param {string[]|null} keys The keys to assign true.
290
- * @param {boolean} defaultValue The default value for each property.
291
- * @param {string} displayName The property name which is used in error message.
288
+ * @param {string[]|null} keys - The keys to assign true.
289
+ * @param {boolean} defaultValue - The default value for each property.
290
+ * @param {string} displayName - The property name which is used in error message.
292
291
  * @returns {Record<string,boolean>} The boolean map.
293
292
  */
294
293
  function toBooleanMap(keys, defaultValue, displayName) {
@@ -357,6 +356,7 @@ exports.migrateOptions = (options = { }) => {
357
356
  }
358
357
  }
359
358
  migrateOption('envs', 'env', envs => toBooleanMap(envs, true, 'envs'));
359
+ migrateOption('extends');
360
360
  migrateOption('globals', undefined, globals => toBooleanMap(globals, false, 'globals'));
361
361
  migrateOption('ignorePattern', 'ignorePatterns');
362
362
  migrateOption('parser');
@@ -395,17 +395,13 @@ exports.resolveWriter = (writer = fancyLog) => {
395
395
  * @param {ESLint.LintResult[]} results
396
396
  * A list of ESLint results.
397
397
  *
398
- * @param {{ cwd: string, eslint: ESLint }} eslintInfo
399
- * Current directory and instance of ESLint used to load and configure the formatter.
400
- *
401
- * @param {string|ESLint.Formatter|FormatterFunction} [formatter]
402
- * A name or path of a formatter, a formatter object or a formatter function.
398
+ * @param {ESLint.Formatter} formatterObj
399
+ * A formatter object.
403
400
  *
404
401
  * @param {GulpESLintWriter} [writer]
405
402
  * A function used to write formatted ESLint messages.
406
403
  */
407
- exports.writeResults = async (results, eslintInfo, formatter, writer) => {
408
- const formatterObj = await resolveFormatter(eslintInfo, formatter);
404
+ exports.writeResults = async (results, formatterObj, writer) => {
409
405
  const message = await formatterObj.format(results);
410
406
  if (writer && message != null && message !== '') {
411
407
  await writer(message);