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.
Files changed (5) hide show
  1. package/README.md +15 -21
  2. package/index.d.ts +163 -157
  3. package/index.js +161 -162
  4. package/package.json +73 -67
  5. 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
- () => src(['scripts/*.js'])
32
- // gulpESLintNew() attaches the lint output to the "eslint" property of the
33
- // file object so it can be used by other modules.
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
- plugins: ['json'],
50
- extends: ['plugin:json/recommended'],
51
- rules: {
52
- 'my-custom-rule': 1,
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
- jQuery: 'readonly',
57
- $: 'readonly'
50
+ chrome: 'readonly'
58
51
  },
59
- env: {
60
- 'browser': true
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`. In contrast, `plugins` as an object that maps strings to plugin implementations has different semantics and is not migrated. |
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
- (results: ESLint.LintResult[], data?: ESLint.LintResultData) => string | Promise<string>;
5
+ type FormatterFunction
6
+ = (results: ESLint.LintResult[], data?: ESLint.LintResultData) => string | Promise<string>;
7
7
 
8
8
  type LintResultStreamFunction<Type>
9
- = ((action: (value: Type, callback: TransformCallback) => void) => NodeJS.ReadWriteStream)
10
- & ((action: (value: Type) => unknown | Promise<unknown>) => NodeJS.ReadWriteStream);
11
-
12
- export type GulpESLintOptions =
13
- Omit<
14
- ESLint.Options,
15
- | 'cache'
16
- | 'cacheLocation'
17
- | 'cacheStrategy'
18
- | 'errorOnUnmatchedPattern'
19
- | 'extensions'
20
- | 'globInputPaths'
21
- | 'plugins'
22
- >
23
- & {
24
- /** @deprecated Use `overrideConfigFile` instead. */
25
- configFile?: ESLint.Options['overrideConfigFile'];
26
-
27
- /**
28
- * @deprecated
29
- * Use `overrideConfig.env` or `baseConfig.env` instead.
30
- * Note the different option name and format.
31
- */
32
- envs?: string[] | undefined;
33
-
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
- */
41
- globals?: string[] | undefined;
42
-
43
- /**
44
- * @deprecated
45
- * Use `overrideConfig.ignorePatterns` or `baseConfig.ignorePatterns` instead.
46
- * Note the different option name.
47
- */
48
- ignorePattern?: Linter.Config['ignorePatterns'];
49
-
50
- /** @deprecated Use `overrideConfig.parser` or `baseConfig.parser` instead. */
51
- parser?: Linter.Config['parser'];
52
-
53
- /** @deprecated Use `overrideConfig.parserOptions` or `baseConfig.parserOptions` instead. */
54
- parserOptions?: Linter.ParserOptions | undefined;
55
-
56
- plugins?: ESLint.Options['plugins'] | Linter.Config['plugins'];
57
-
58
- quiet?:
59
- | boolean
60
- | ((message: Linter.LintMessage, index: number, list: Linter.LintMessage[]) => unknown)
61
- | undefined;
62
-
63
- /** @deprecated Use `overrideConfig.rules` or `baseConfig.rules` instead. */
64
- rules?: Linter.Config['rules'];
65
-
66
- /** @deprecated Use `warnIgnored` instead. */
67
- warnFileIgnored?: boolean | undefined;
68
-
69
- warnIgnored?: boolean | undefined;
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
- GulpESLintResult[] &
76
- {
77
- errorCount: number;
78
- fatalErrorCount: number;
79
- warningCount: number;
80
- fixableErrorCount: number;
81
- fixableWarningCount: number;
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
- * Append ESLint result to each file.
89
- *
90
- * @param options - Options for gulp-eslint-new.
91
- * @returns gulp file stream.
92
- */
93
- (options?: GulpESLintOptions): NodeJS.ReadWriteStream;
94
-
95
- /**
96
- * Append ESLint result to each file.
97
- *
98
- * @param overrideConfigFile - The path to a configuration file.
99
- * @returns gulp file stream.
100
- */
101
- (overrideConfigFile?: string): NodeJS.ReadWriteStream;
102
-
103
- /**
104
- * Handle each ESLint result as it passes through the stream.
105
- *
106
- * @param action - A function to handle each ESLint result.
107
- * @returns gulp file stream.
108
- */
109
- result: LintResultStreamFunction<GulpESLintResult>;
110
-
111
- /**
112
- * Handle all ESLint results at the end of the stream.
113
- *
114
- * @param action - A function to handle all ESLint results.
115
- * @returns gulp file stream.
116
- */
117
- results: LintResultStreamFunction<GulpESLintResults>;
118
-
119
- /**
120
- * Fail when an ESLint error is found in an ESLint result.
121
- *
122
- * @returns gulp file stream.
123
- */
124
- failOnError(): NodeJS.ReadWriteStream;
125
-
126
- /**
127
- * Fail when the stream ends if any ESLint error(s) occurred.
128
- *
129
- * @returns gulp file stream.
130
- */
131
- failAfterError(): NodeJS.ReadWriteStream;
132
-
133
- /**
134
- * Format the results of each file individually.
135
- *
136
- * @param formatter -
137
- * A name or path of a formatter, a formatter object or a formatter function.
138
- * Defaults to the [stylish](https://eslint.org/docs/user-guide/formatters/#stylish) formatter.
139
- * @param writer -
140
- * A funtion or stream to write the formatted ESLint results.
141
- * Defaults to gulp's [fancy-log](https://github.com/gulpjs/fancy-log#readme).
142
- * @returns gulp file stream.
143
- */
144
- formatEach(
145
- formatter?: string | ESLint.Formatter | FormatterFunction,
146
- writer?: GulpESLintWriter | NodeJS.WritableStream
147
- ): NodeJS.ReadWriteStream;
148
-
149
- /**
150
- * Wait until all files have been linted and format all results at once.
151
- *
152
- * @param formatter -
153
- * A name or path of a formatter, a formatter object or a formatter function.
154
- * Defaults to the [stylish](https://eslint.org/docs/user-guide/formatters/#stylish) formatter.
155
- * @param writer -
156
- * A funtion or stream to write the formatted ESLint results.
157
- * Defaults to gulp's [fancy-log](https://github.com/gulpjs/fancy-log#readme).
158
- * @returns gulp file stream.
159
- */
160
- format(
161
- formatter?: string | ESLint.Formatter | FormatterFunction,
162
- writer?: GulpESLintWriter | NodeJS.WritableStream
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;
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;