gulp-eslint-new 2.1.0 → 2.3.0
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 +35 -11
- package/lib/eslint.d.ts +3 -42
- package/lib/gulp-eslint-new.d.ts +49 -65
- package/lib/util.js +9 -16
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -53,21 +53,41 @@ src(['scripts/*.js']) // Read files.
|
|
|
53
53
|
Or use the plugin API to do things like:
|
|
54
54
|
|
|
55
55
|
```javascript
|
|
56
|
-
|
|
56
|
+
// gulpfile.mjs
|
|
57
|
+
import js from '@eslint/js';
|
|
58
|
+
import jquery from 'eslint-plugin-jquery';
|
|
59
|
+
import globals from 'globals';
|
|
60
|
+
import gulp from 'gulp';
|
|
61
|
+
import gulpESLintNew from 'gulp-eslint-new';
|
|
62
|
+
|
|
63
|
+
export default
|
|
64
|
+
() =>
|
|
65
|
+
gulp.src(['**/*.{js,mjs}', '!node_modules/**'])
|
|
57
66
|
.pipe
|
|
58
67
|
(
|
|
59
68
|
gulpESLintNew
|
|
60
69
|
(
|
|
61
70
|
{
|
|
71
|
+
configType: 'flat',
|
|
62
72
|
overrideConfig:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
[
|
|
74
|
+
js.configs.recommended,
|
|
75
|
+
jquery.configs.slim,
|
|
76
|
+
{
|
|
77
|
+
languageOptions:
|
|
78
|
+
{
|
|
79
|
+
globals:
|
|
80
|
+
{
|
|
81
|
+
...globals.browser,
|
|
82
|
+
...globals.jquery,
|
|
83
|
+
chrome: 'readonly',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
rules: { 'strict': 'error' },
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
plugins: { jquery },
|
|
90
|
+
warnIgnored: true,
|
|
71
91
|
},
|
|
72
92
|
),
|
|
73
93
|
)
|
|
@@ -80,7 +100,7 @@ For additional examples, look through the [example directory](https://github.com
|
|
|
80
100
|
|
|
81
101
|
### `gulpESLintNew()`
|
|
82
102
|
|
|
83
|
-
Run ESLint with default settings. A [configuration file](https://eslint.org/docs/user-guide/configure/configuration-files)
|
|
103
|
+
Run ESLint with default settings. A [configuration file](https://eslint.org/docs/user-guide/configure/configuration-files) will be resolved depending on the version of ESLint used.
|
|
84
104
|
|
|
85
105
|
### `gulpESLintNew(options)`
|
|
86
106
|
|
|
@@ -120,6 +140,9 @@ See the linked content for details about each option.
|
|
|
120
140
|
* [`quiet`](#optionsquiet)
|
|
121
141
|
* [`warnIgnored`](#optionswarnignored)
|
|
122
142
|
|
|
143
|
+
**Other options**
|
|
144
|
+
* [`flags`][other options]
|
|
145
|
+
|
|
123
146
|
#### General Options
|
|
124
147
|
|
|
125
148
|
##### `options.configType`
|
|
@@ -431,5 +454,6 @@ The functions [`gulpESLintNew.result`](#gulpeslintnewresultaction) and [`gulpESL
|
|
|
431
454
|
[gulp-eslint]: https://github.com/adametry/gulp-eslint
|
|
432
455
|
[legacy linting options]: https://eslint.org/docs/v8.x/integrate/nodejs-api#linting
|
|
433
456
|
[linting options]: https://eslint.org/docs/latest/integrate/nodejs-api#linting
|
|
434
|
-
[npm badge]: https://img.shields.io/npm/v/gulp-eslint-new?logo=npm
|
|
435
457
|
[npm URL]: https://www.npmjs.com/package/gulp-eslint-new
|
|
458
|
+
[npm badge]: https://img.shields.io/npm/v/gulp-eslint-new?logo=npm
|
|
459
|
+
[other options]: https://eslint.org/docs/latest/integrate/nodejs-api#other-options
|
package/lib/eslint.d.ts
CHANGED
|
@@ -1,51 +1,14 @@
|
|
|
1
|
-
import type { ESLint, Linter
|
|
1
|
+
import type { ESLint, Linter } from 'eslint';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type ESLintrcOptions = ESLint.LegacyOptions;
|
|
4
4
|
|
|
5
|
-
type
|
|
6
|
-
Omit<
|
|
7
|
-
ESLint.Options,
|
|
8
|
-
| 'baseConfig'
|
|
9
|
-
| 'fixTypes'
|
|
10
|
-
| 'overrideConfig'
|
|
11
|
-
| 'overrideConfigFile'
|
|
12
|
-
| 'plugins'
|
|
13
|
-
| 'reportUnusedDisableDirectives'
|
|
14
|
-
| 'resolvePluginsRelativeTo'
|
|
15
|
-
> &
|
|
16
|
-
{
|
|
17
|
-
baseConfig?: Linter.Config | null | undefined;
|
|
18
|
-
fixTypes?: Rule.RuleMetaData['type'][] | null | undefined;
|
|
19
|
-
overrideConfig?: Linter.Config | null | undefined;
|
|
20
|
-
overrideConfigFile?: string | null | undefined;
|
|
21
|
-
plugins?: Record<string, ESLint.Plugin> | null | undefined;
|
|
22
|
-
reportUnusedDisableDirectives?: Linter.StringSeverity | null | undefined;
|
|
23
|
-
resolvePluginsRelativeTo?: string | null | undefined;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type FlatConfig =
|
|
27
|
-
Omit<Linter.FlatConfig, 'languageOptions'> &
|
|
28
|
-
{
|
|
29
|
-
languageOptions?: LanguageOptions;
|
|
30
|
-
name?: string;
|
|
31
|
-
};
|
|
5
|
+
type FlatESLintOptions = ESLint.Options;
|
|
32
6
|
|
|
33
7
|
type FormatterContext = ESLint.LintResultData & ResultsMeta;
|
|
34
8
|
|
|
35
9
|
type FormatterFunction =
|
|
36
10
|
(results: ESLint.LintResult[], context?: FormatterContext) => string | Promise<string>;
|
|
37
11
|
|
|
38
|
-
type GlobalConf = boolean | 'off' | 'readable' | 'readonly' | 'writable' | 'writeable';
|
|
39
|
-
|
|
40
|
-
interface LanguageOptions
|
|
41
|
-
{
|
|
42
|
-
ecmaVersion?: number | 'latest';
|
|
43
|
-
globals?: Record<string, GlobalConf>;
|
|
44
|
-
parser?: Linter.ParserModule;
|
|
45
|
-
parserOptions?: Linter.ParserOptions;
|
|
46
|
-
sourceType?: 'script' | 'module' | 'commonjs';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
12
|
type LintMessage = Linter.LintMessage;
|
|
50
13
|
|
|
51
14
|
type LintResult = ESLint.LintResult;
|
|
@@ -61,5 +24,3 @@ interface ResultsMeta
|
|
|
61
24
|
maxWarnings: number;
|
|
62
25
|
};
|
|
63
26
|
}
|
|
64
|
-
|
|
65
|
-
type Severity = Linter.Severity;
|
package/lib/gulp-eslint-new.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import 'node';
|
|
|
4
4
|
|
|
5
5
|
type Awaitable<T = unknown> = T | Promise<T>;
|
|
6
6
|
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
type LintMessage
|
|
7
|
+
type ESLintrcOptions = eslint.ESLintrcOptions;
|
|
8
|
+
type FlatESLintOptions = eslint.FlatESLintOptions;
|
|
9
|
+
type LintMessage = eslint.LintMessage;
|
|
10
10
|
|
|
11
11
|
type LintResultStreamFunction<Type> =
|
|
12
12
|
((action: (value: Type, callback: TransformCallback) => void) => NodeJS.ReadWriteStream) &
|
|
@@ -14,6 +14,16 @@ type LintResultStreamFunction<Type> =
|
|
|
14
14
|
|
|
15
15
|
declare namespace gulpESLintNew
|
|
16
16
|
{
|
|
17
|
+
interface AdditionalOptions
|
|
18
|
+
{
|
|
19
|
+
quiet?:
|
|
20
|
+
| boolean
|
|
21
|
+
| ((message: LintMessage, index: number, list: LintMessage[]) => unknown)
|
|
22
|
+
| undefined;
|
|
23
|
+
|
|
24
|
+
warnIgnored?: boolean | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
type FormatterContext = eslint.FormatterContext;
|
|
18
28
|
|
|
19
29
|
type FormatterFunction = eslint.FormatterFunction;
|
|
@@ -26,7 +36,7 @@ declare namespace gulpESLintNew
|
|
|
26
36
|
* @param options - Options for gulp-eslint-new.
|
|
27
37
|
* @returns gulp file stream.
|
|
28
38
|
*/
|
|
29
|
-
(options?:
|
|
39
|
+
(options?: GulpESLintNewOptions): NodeJS.ReadWriteStream;
|
|
30
40
|
|
|
31
41
|
/**
|
|
32
42
|
* Append ESLint result to each file.
|
|
@@ -42,7 +52,7 @@ declare namespace gulpESLintNew
|
|
|
42
52
|
* @param action - A function to handle each ESLint result.
|
|
43
53
|
* @returns gulp file stream.
|
|
44
54
|
*/
|
|
45
|
-
result: LintResultStreamFunction<
|
|
55
|
+
result: LintResultStreamFunction<LintResult>;
|
|
46
56
|
|
|
47
57
|
/**
|
|
48
58
|
* Handle all ESLint results at the end of the stream.
|
|
@@ -50,7 +60,7 @@ declare namespace gulpESLintNew
|
|
|
50
60
|
* @param action - A function to handle all ESLint results.
|
|
51
61
|
* @returns gulp file stream.
|
|
52
62
|
*/
|
|
53
|
-
results: LintResultStreamFunction<
|
|
63
|
+
results: LintResultStreamFunction<LintResults>;
|
|
54
64
|
|
|
55
65
|
/**
|
|
56
66
|
* Fail when an ESLint error is found in an ESLint result.
|
|
@@ -81,7 +91,7 @@ declare namespace gulpESLintNew
|
|
|
81
91
|
formatEach
|
|
82
92
|
(
|
|
83
93
|
formatter?: string | LoadedFormatter | FormatterFunction,
|
|
84
|
-
writer?:
|
|
94
|
+
writer?: Writer | NodeJS.WritableStream
|
|
85
95
|
):
|
|
86
96
|
NodeJS.ReadWriteStream;
|
|
87
97
|
|
|
@@ -100,7 +110,7 @@ declare namespace gulpESLintNew
|
|
|
100
110
|
format
|
|
101
111
|
(
|
|
102
112
|
formatter?: string | LoadedFormatter | FormatterFunction,
|
|
103
|
-
writer?:
|
|
113
|
+
writer?: Writer | NodeJS.WritableStream
|
|
104
114
|
):
|
|
105
115
|
NodeJS.ReadWriteStream;
|
|
106
116
|
|
|
@@ -112,82 +122,56 @@ declare namespace gulpESLintNew
|
|
|
112
122
|
fix(): NodeJS.ReadWriteStream;
|
|
113
123
|
}
|
|
114
124
|
|
|
115
|
-
type
|
|
116
|
-
(GulpESLintrcOptions & { configType?: 'eslintrc' | null | undefined; }) |
|
|
117
|
-
(GulpFlatESLintOptions & { configType: 'flat'; });
|
|
118
|
-
|
|
119
|
-
type GulpESLintResult = eslint.LintResult;
|
|
120
|
-
|
|
121
|
-
type GulpESLintResults
|
|
122
|
-
=
|
|
123
|
-
GulpESLintResult[] &
|
|
124
|
-
{
|
|
125
|
-
errorCount: number;
|
|
126
|
-
fatalErrorCount: number;
|
|
127
|
-
warningCount: number;
|
|
128
|
-
fixableErrorCount: number;
|
|
129
|
-
fixableWarningCount: number;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
type GulpESLintWriter = (str: string) => Awaitable;
|
|
133
|
-
|
|
134
|
-
type GulpESLintrcOptions
|
|
125
|
+
type GulpESLintNewEslintrcOptions
|
|
135
126
|
=
|
|
136
127
|
Omit<
|
|
137
|
-
|
|
128
|
+
ESLintrcOptions,
|
|
138
129
|
| 'cache'
|
|
139
130
|
| 'cacheLocation'
|
|
140
131
|
| 'cacheStrategy'
|
|
141
132
|
| 'errorOnUnmatchedPattern'
|
|
142
133
|
| 'extensions'
|
|
143
134
|
| 'globInputPaths'
|
|
144
|
-
>
|
|
145
|
-
|
|
146
|
-
quiet?:
|
|
147
|
-
| boolean
|
|
148
|
-
| ((message: LintMessage, index: number, list: LintMessage[]) => unknown)
|
|
149
|
-
| undefined;
|
|
135
|
+
>
|
|
136
|
+
& AdditionalOptions;
|
|
150
137
|
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
type GulpFlatESLintOptions
|
|
138
|
+
type GulpESLintNewFlatOptions
|
|
155
139
|
=
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
| '
|
|
159
|
-
| '
|
|
160
|
-
| '
|
|
161
|
-
| '
|
|
162
|
-
| '
|
|
163
|
-
| '
|
|
164
|
-
>
|
|
165
|
-
|
|
166
|
-
baseConfig?: FlatConfig | (string | FlatConfig)[] | null | undefined;
|
|
167
|
-
|
|
168
|
-
ignorePatterns?: string[] | null | undefined;
|
|
169
|
-
|
|
170
|
-
overrideConfig?: FlatConfig | (string | FlatConfig)[] | null | undefined;
|
|
171
|
-
|
|
172
|
-
overrideConfigFile?: string | true | null | undefined;
|
|
173
|
-
|
|
174
|
-
quiet?:
|
|
175
|
-
| boolean
|
|
176
|
-
| ((message: LintMessage, index: number, list: LintMessage[]) => unknown)
|
|
177
|
-
| undefined;
|
|
140
|
+
Omit<
|
|
141
|
+
FlatESLintOptions,
|
|
142
|
+
| 'cache'
|
|
143
|
+
| 'cacheLocation'
|
|
144
|
+
| 'cacheStrategy'
|
|
145
|
+
| 'errorOnUnmatchedPattern'
|
|
146
|
+
| 'globInputPaths'
|
|
147
|
+
| 'passOnNoPatterns'
|
|
148
|
+
>
|
|
149
|
+
& AdditionalOptions;
|
|
178
150
|
|
|
179
|
-
|
|
151
|
+
type GulpESLintNewOptions =
|
|
152
|
+
|
|
|
153
|
+
((GulpESLintNewEslintrcOptions | GulpESLintNewFlatOptions) & { configType?: null | undefined; })
|
|
154
|
+
| (GulpESLintNewEslintrcOptions & { configType: 'eslintrc'; })
|
|
155
|
+
| (GulpESLintNewFlatOptions & { configType: 'flat'; });
|
|
180
156
|
|
|
181
|
-
|
|
157
|
+
type LintResult = eslint.LintResult;
|
|
182
158
|
|
|
183
|
-
|
|
159
|
+
type LintResults
|
|
160
|
+
=
|
|
161
|
+
LintResult[] &
|
|
162
|
+
{
|
|
163
|
+
errorCount: number;
|
|
164
|
+
fatalErrorCount: number;
|
|
165
|
+
warningCount: number;
|
|
166
|
+
fixableErrorCount: number;
|
|
167
|
+
fixableWarningCount: number;
|
|
184
168
|
};
|
|
185
169
|
|
|
186
170
|
type LoadedFormatter = eslint.LoadedFormatter;
|
|
187
171
|
|
|
188
172
|
type ResultsMeta = eslint.ResultsMeta;
|
|
189
173
|
|
|
190
|
-
type
|
|
174
|
+
type Writer = (str: string) => Awaitable;
|
|
191
175
|
}
|
|
192
176
|
|
|
193
177
|
declare const gulpESLintNew: gulpESLintNew.GulpESLintNew;
|
package/lib/util.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {import('eslint').ESLint}
|
|
5
|
-
* @typedef {import('./
|
|
6
|
-
* @typedef {import('./eslint').LintMessage}
|
|
7
|
-
* @typedef {import('./eslint').LintResult}
|
|
8
|
-
* @typedef {import('./eslint').
|
|
9
|
-
* @typedef {import('./eslint').
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @callback FormatterFunction
|
|
14
|
-
* @param {LintResult[]} results
|
|
15
|
-
* @param {LintResultData} [data]
|
|
16
|
-
* @returns {string | Promise<string>}
|
|
4
|
+
* @typedef {import('eslint').ESLint} ESLint
|
|
5
|
+
* @typedef {import('./eslint').FormatterFunction} FormatterFunction
|
|
6
|
+
* @typedef {import('./eslint').LintMessage} LintMessage
|
|
7
|
+
* @typedef {import('./eslint').LintResult} LintResult
|
|
8
|
+
* @typedef {import('./eslint').LoadedFormatter} LoadedFormatter
|
|
9
|
+
* @typedef {import('./gulp-eslint-new').Writer} Writer
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
12
|
const { normalize, relative } = require('path');
|
|
@@ -449,9 +442,9 @@ async ({ cwd, eslint }, formatter) =>
|
|
|
449
442
|
/**
|
|
450
443
|
* Resolve a writer function used to write formatted ESLint messages.
|
|
451
444
|
*
|
|
452
|
-
* @param {
|
|
445
|
+
* @param {Writer | NodeJS.WritableStream} [writer=require('fancy-log')]
|
|
453
446
|
* A stream or function to resolve as a format writer.
|
|
454
|
-
* @returns {
|
|
447
|
+
* @returns {Writer} A function that writes formatted messages.
|
|
455
448
|
*/
|
|
456
449
|
exports.resolveWriter =
|
|
457
450
|
(writer = require('fancy-log')) =>
|
|
@@ -474,7 +467,7 @@ exports.resolveWriter =
|
|
|
474
467
|
* @param {LoadedFormatter} formatterObj
|
|
475
468
|
* A formatter object.
|
|
476
469
|
*
|
|
477
|
-
* @param {
|
|
470
|
+
* @param {Writer} [writer]
|
|
478
471
|
* A function used to write formatted ESLint messages.
|
|
479
472
|
*/
|
|
480
473
|
exports.writeResults =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-eslint-new",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A gulp plugin to lint code with ESLint 8 and 9.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gulpplugin",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"lib"
|
|
25
25
|
],
|
|
26
|
+
"main": "lib/gulp-eslint-new.js",
|
|
26
27
|
"directories": {
|
|
27
28
|
"example": "example",
|
|
28
29
|
"lib": "lib",
|
|
@@ -41,19 +42,19 @@
|
|
|
41
42
|
"ts-test": "tsc --project test/tsconfig.json"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@types/eslint": "^
|
|
45
|
+
"@types/eslint": "^9.6.0",
|
|
45
46
|
"@types/node": ">=12",
|
|
46
47
|
"eslint": "8 || 9",
|
|
47
48
|
"fancy-log": "^2.0.0",
|
|
48
49
|
"plugin-error": "^2.0.1",
|
|
49
|
-
"semver": "^7.6.
|
|
50
|
+
"semver": "^7.6.3",
|
|
50
51
|
"ternary-stream": "^3.0.0",
|
|
51
52
|
"vinyl-fs": "^4.0.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@eslint/js": "^8.57.0",
|
|
55
|
-
"@origin-1/eslint-config": "^1.
|
|
56
|
-
"c8js": "^0.
|
|
56
|
+
"@origin-1/eslint-config": "^1.6.1",
|
|
57
|
+
"c8js": "^0.8.0",
|
|
57
58
|
"eslint-8.0": "npm:eslint@8.0",
|
|
58
59
|
"eslint-8.21": "npm:eslint@8.21",
|
|
59
60
|
"eslint-8.x": "npm:eslint@8.x",
|
|
@@ -62,10 +63,11 @@
|
|
|
62
63
|
"eslint-formatter-~formatter": "file:test/formatter",
|
|
63
64
|
"eslint-formatter-compact": "^8.40.0",
|
|
64
65
|
"eslint-plugin-tsdoc": "^0.3.0",
|
|
65
|
-
"globals": "^15.
|
|
66
|
+
"globals": "^15.9.0",
|
|
66
67
|
"gulp": "^5.0.0",
|
|
67
68
|
"mocha": "^9.2.2",
|
|
68
|
-
"
|
|
69
|
+
"resolve": "^1.22.8",
|
|
70
|
+
"typescript": "~5.5.4",
|
|
69
71
|
"typescript_4.6": "npm:typescript@4.6",
|
|
70
72
|
"typescript_5": "npm:typescript@5",
|
|
71
73
|
"vinyl": "^3.0.0"
|