gulp-eslint-new 2.0.0 → 2.2.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 +39 -15
- package/lib/eslint.d.ts +1 -0
- package/lib/gulp-eslint-new.d.ts +5 -3
- package/lib/util.js +34 -19
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
Make sure that you are using a version of Node.js supported by your version of ESLint.
|
|
8
|
-
See prerequisites for [ESLint 8](https://eslint.org/docs/v8.x/use/getting-started#prerequisites) and [ESLint 9](https://eslint.org/docs/
|
|
8
|
+
See prerequisites for [ESLint 8](https://eslint.org/docs/v8.x/use/getting-started#prerequisites) and [ESLint 9](https://eslint.org/docs/v9.x/use/getting-started#prerequisites).
|
|
9
9
|
For TypeScript support, you need TypeScript 4.6 or later.
|
|
10
10
|
|
|
11
11
|
To install gulp-eslint-new, [use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm):
|
|
@@ -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`
|
|
@@ -363,11 +386,11 @@ If this argument is `undefined`, a modified version of the ESLint "stylish" form
|
|
|
363
386
|
// Use the default gulp-eslint-new formatter.
|
|
364
387
|
gulpESLintNew.format()
|
|
365
388
|
|
|
366
|
-
// Use the "
|
|
367
|
-
gulpESLintNew.format('
|
|
389
|
+
// Use the "html" ESLint formatter.
|
|
390
|
+
gulpESLintNew.format('html')
|
|
368
391
|
|
|
369
392
|
// Use "eslint-formatter-pretty" as a formatter (must be installed with `npm`).
|
|
370
|
-
// See https://
|
|
393
|
+
// See https://www.npmjs.com/package/eslint-formatter-pretty.
|
|
371
394
|
gulpESLintNew.format('pretty')
|
|
372
395
|
```
|
|
373
396
|
|
|
@@ -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
|
@@ -16,6 +16,7 @@ Omit<
|
|
|
16
16
|
{
|
|
17
17
|
baseConfig?: Linter.Config | null | undefined;
|
|
18
18
|
fixTypes?: Rule.RuleMetaData['type'][] | null | undefined;
|
|
19
|
+
flags?: string[] | undefined;
|
|
19
20
|
overrideConfig?: Linter.Config | null | undefined;
|
|
20
21
|
overrideConfigFile?: string | null | undefined;
|
|
21
22
|
plugins?: Record<string, ESLint.Plugin> | null | undefined;
|
package/lib/gulp-eslint-new.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { TransformCallback } from 'node:stream';
|
|
1
2
|
import type * as eslint from './eslint';
|
|
2
3
|
import 'node';
|
|
3
|
-
import type { TransformCallback } from 'stream';
|
|
4
4
|
|
|
5
5
|
type Awaitable<T = unknown> = T | Promise<T>;
|
|
6
6
|
|
|
@@ -113,8 +113,9 @@ declare namespace gulpESLintNew
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
type GulpESLintOptions =
|
|
116
|
-
(GulpESLintrcOptions & { configType?:
|
|
117
|
-
(
|
|
116
|
+
| ((GulpESLintrcOptions | GulpFlatESLintOptions) & { configType?: null | undefined; })
|
|
117
|
+
| (GulpESLintrcOptions & { configType: 'eslintrc'; })
|
|
118
|
+
| (GulpFlatESLintOptions & { configType: 'flat'; });
|
|
118
119
|
|
|
119
120
|
type GulpESLintResult = eslint.LintResult;
|
|
120
121
|
|
|
@@ -159,6 +160,7 @@ declare namespace gulpESLintNew
|
|
|
159
160
|
| 'cwd'
|
|
160
161
|
| 'fix'
|
|
161
162
|
| 'fixTypes'
|
|
163
|
+
| 'flags'
|
|
162
164
|
| 'ignore'
|
|
163
165
|
| 'plugins'
|
|
164
166
|
> &
|
package/lib/util.js
CHANGED
|
@@ -122,29 +122,44 @@ exports.createIgnoreResult =
|
|
|
122
122
|
{
|
|
123
123
|
const { ltr } = require('semver');
|
|
124
124
|
let message;
|
|
125
|
-
const useEslintrcConfig = isEslintrcESLintConstructor(eslintConstructor);
|
|
126
125
|
const relativePath = relative(baseDir, filePath);
|
|
127
|
-
|
|
128
|
-
if (useEslintrcConfig && isHiddenRegExp.test(relativePath))
|
|
126
|
+
if (isEslintrcESLintConstructor(eslintConstructor))
|
|
129
127
|
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
128
|
+
if (isHiddenRegExp.test(relativePath))
|
|
129
|
+
{
|
|
130
|
+
message =
|
|
131
|
+
'File ignored by default. Use a negated ignore pattern (like ' +
|
|
132
|
+
'"!<relative/path/to/filename>") to override.';
|
|
133
|
+
}
|
|
134
|
+
else if (isInNodeModulesRegExp.test(relativePath))
|
|
135
|
+
{
|
|
136
|
+
message =
|
|
137
|
+
'File ignored by default. Use a negated ignore pattern like "!**/node_modules/*" to ' +
|
|
138
|
+
'override.';
|
|
139
|
+
}
|
|
140
|
+
else
|
|
141
|
+
{
|
|
142
|
+
message =
|
|
143
|
+
'File ignored because of a matching ignore pattern. Set "ignore" option to false to ' +
|
|
144
|
+
'override.';
|
|
145
|
+
}
|
|
142
146
|
}
|
|
143
147
|
else
|
|
144
148
|
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
if (relativePath.startsWith('..'))
|
|
150
|
+
message = 'File ignored because outside of base path.';
|
|
151
|
+
else if (isInNodeModulesRegExp.test(relativePath))
|
|
152
|
+
{
|
|
153
|
+
message =
|
|
154
|
+
'File ignored by default because it is located under the node_modules directory. Use ' +
|
|
155
|
+
'ignore pattern "!**/node_modules/**" to override.';
|
|
156
|
+
}
|
|
157
|
+
else
|
|
158
|
+
{
|
|
159
|
+
message =
|
|
160
|
+
'File ignored. If this file is matched by a global ignore pattern, it can be ' +
|
|
161
|
+
'unignored by setting the "ignore" option to false.';
|
|
162
|
+
}
|
|
148
163
|
}
|
|
149
164
|
const result =
|
|
150
165
|
{
|
|
@@ -156,7 +171,7 @@ exports.createIgnoreResult =
|
|
|
156
171
|
fixableWarningCount: 0,
|
|
157
172
|
fatalErrorCount: 0,
|
|
158
173
|
};
|
|
159
|
-
if (!ltr(
|
|
174
|
+
if (!ltr(eslintConstructor.version, '8.8'))
|
|
160
175
|
result.suppressedMessages = [];
|
|
161
176
|
return result;
|
|
162
177
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-eslint-new",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A gulp plugin to lint code with ESLint 8 and 9.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gulpplugin",
|
|
@@ -36,35 +36,36 @@
|
|
|
36
36
|
"build": "npm install && gulp",
|
|
37
37
|
"coverage": "gulp test",
|
|
38
38
|
"lint": "eslint . --format compact",
|
|
39
|
+
"release": "git add CHANGELOG.md && npm version -f",
|
|
39
40
|
"test": "mocha --check-leaks test/*.spec.js",
|
|
40
|
-
"ts-test": "tsc --project test/tsconfig.json"
|
|
41
|
-
"version": "git add CHANGELOG.md"
|
|
41
|
+
"ts-test": "tsc --project test/tsconfig.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@types/eslint": "^8.56.
|
|
44
|
+
"@types/eslint": "^8.56.10",
|
|
45
45
|
"@types/node": ">=12",
|
|
46
46
|
"eslint": "8 || 9",
|
|
47
47
|
"fancy-log": "^2.0.0",
|
|
48
48
|
"plugin-error": "^2.0.1",
|
|
49
|
-
"semver": "^7.6.
|
|
49
|
+
"semver": "^7.6.2",
|
|
50
50
|
"ternary-stream": "^3.0.0",
|
|
51
51
|
"vinyl-fs": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@eslint/js": "^8.57.0",
|
|
55
|
-
"@origin-1/eslint-config": "^
|
|
56
|
-
"c8js": "^0.
|
|
55
|
+
"@origin-1/eslint-config": "^1.4.0",
|
|
56
|
+
"c8js": "^0.7.0",
|
|
57
57
|
"eslint-8.0": "npm:eslint@8.0",
|
|
58
58
|
"eslint-8.21": "npm:eslint@8.21",
|
|
59
59
|
"eslint-8.x": "npm:eslint@8.x",
|
|
60
60
|
"eslint-9.x": "npm:eslint@9.x",
|
|
61
61
|
"eslint-config-~shareable": "file:test/config",
|
|
62
62
|
"eslint-formatter-~formatter": "file:test/formatter",
|
|
63
|
-
"eslint-
|
|
64
|
-
"
|
|
63
|
+
"eslint-formatter-compact": "^8.40.0",
|
|
64
|
+
"eslint-plugin-tsdoc": "^0.3.0",
|
|
65
|
+
"globals": "^15.8.0",
|
|
65
66
|
"gulp": "^5.0.0",
|
|
66
67
|
"mocha": "^9.2.2",
|
|
67
|
-
"typescript": "~5.
|
|
68
|
+
"typescript": "~5.5.3",
|
|
68
69
|
"typescript_4.6": "npm:typescript@4.6",
|
|
69
70
|
"typescript_5": "npm:typescript@5",
|
|
70
71
|
"vinyl": "^3.0.0"
|