gulp-eslint-new 2.5.0 → 2.6.1

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  # gulp-eslint-new · [![npm version][npm badge]][npm URL]
2
2
 
3
- > A [gulp](https://gulpjs.com/) plugin to lint code with [ESLint](https://eslint.org/) 8 and 9.
3
+ > A [gulp](https://gulpjs.com/) plugin to lint code with [ESLint](https://eslint.org/) 8, 9, and 10.
4
4
 
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/v9.x/use/getting-started#prerequisites).
8
+ See prerequisites for [ESLint 8](https://eslint.org/docs/v8.x/use/getting-started#prerequisites), [ESLint 9](https://eslint.org/docs/v9.x/use/getting-started#prerequisites), or [ESLint 10](https://eslint.org/docs/v10.x/use/getting-started#prerequisites).
9
9
  For TypeScript support, you need TypeScript 4.8 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):
@@ -14,12 +14,12 @@ To install gulp-eslint-new, [use](https://docs.npmjs.com/cli/install) [npm](http
14
14
  npm i -D gulp-eslint-new
15
15
  ```
16
16
 
17
- gulp-eslint-new will also install the latest version of ESLint 9, unless another one is found.
17
+ gulp-eslint-new will also install the latest version of ESLint 10, unless another one is found.
18
18
  To use a particular version of ESLint, install it by yourself.
19
- For example, to use ESLint 8.8.0:
19
+ For example, to use ESLint 8.57.1:
20
20
 
21
21
  ```console
22
- npm i -D gulp-eslint-new eslint@8.8.0
22
+ npm i -D gulp-eslint-new eslint@8.57.1
23
23
  ```
24
24
 
25
25
  ## Migrating
@@ -27,11 +27,12 @@ npm i -D gulp-eslint-new eslint@8.8.0
27
27
  If you are migrating from [gulp-eslint][gulp-eslint], you probably won't need to make any substantial changes to your gulp task, as the API is widely compatible.
28
28
  Note though that many options have changed: the current options are documented in the [`gulpESLintNew(options)`](#gulpeslintnewoptions) section.
29
29
 
30
- Also note that gulp-eslint-new is designed to work with ESLint 8 or 9, whereas the latest release of gulp-eslint only supports ESLint 6: you will need to update your project to address breaking changes in ESLint.
30
+ Also note that gulp-eslint-new is designed to work with ESLint 8, 9 or 10, whereas the latest release of gulp-eslint only supports ESLint 6: you will need to update your project to address breaking changes in ESLint.
31
31
  You can follow the links below for more information.
32
32
  * [Breaking changes for users from ESLint 6 to ESLint 7](https://eslint.org/docs/user-guide/migrating-to-7.0.0#breaking-changes-for-users)
33
33
  * [Breaking changes for users from ESLint 7 to ESLint 8](https://eslint.org/docs/user-guide/migrate-to-8.0.0#breaking-changes-for-users)
34
34
  * [Breaking changes for users from ESLint 8 to ESLint 9](https://eslint.org/docs/user-guide/migrate-to-9.0.0#breaking-changes-for-users)
35
+ * [Breaking changes for users from ESLint 9 to ESLint 10](https://eslint.org/docs/user-guide/migrate-to-10.0.0#breaking-changes-for-users)
35
36
 
36
37
 
37
38
  ## Usage
@@ -149,15 +150,13 @@ See the linked content for details about each option.
149
150
 
150
151
  Type: `"eslintrc" | "flat" | null`
151
152
 
152
- ESLint supports two types of configuration: a [new config](https://eslint.org/docs/user-guide/configure/configuration-files) type, aka flat config, based on file `eslint.config.*`, and a [legacy config](https://eslint.org/docs/user-guide/configure/configuration-files-deprecated) type, or eslintrc config, based on file `.eslintrc`.
153
+ ESLint supports two configuration formats: a [new config](https://eslint.org/docs/user-guide/configure/configuration-files) type, aka flat config, based on file `eslint.config.*`, and a [legacy config](https://eslint.org/docs/v9.x/use/configure/configuration-files-deprecated) type, or eslintrc config, based on file `.eslintrc`.
153
154
 
154
- In ESLint 8, the default config type is the legacy config, and the new config is partly supported depending on the version of ESLint used.
155
- To use the the new config with ESLint 8 in gulp-eslint-new, set the option `configType` to `"flat"`.
155
+ * **ESLint 8**: Uses the legacy config by default. Flat config is partially supported depending on the version. In gulp-eslint-new, set `configType: "flat"` to enable flat config.
156
+ * **ESLint 9**: Uses flat config by default. To use legacy config in gulp-eslint-new, set `configType: "eslintrc"`.
157
+ * **ESLint 10**: Only supports flat config. Setting `configType: "eslintrc"` in gulp-eslint-new will result in an error.
156
158
 
157
- ESLint 9 uses the new config type by default.
158
- To use the legacy config with ESLint 9 in gulp-eslint-new, set the option `configType` to `"eslintrc"`.
159
-
160
- The new and legacy config types differ significantly in the available options and their usage.
159
+ The new and legacy config formats differ significantly in the available options and their usage.
161
160
  Refer to the respective documentation in ESLint for the specifics of each options.
162
161
 
163
162
  ##### `options.cwd`
package/lib/eslint.d.ts CHANGED
@@ -1,6 +1,40 @@
1
1
  import type { ESLint, Linter } from 'eslint';
2
2
 
3
- type ESLintrcOptions = ESLint.LegacyOptions;
3
+ interface ESLintrcOptions
4
+ {
5
+ // File enumeration
6
+ cwd?: string | undefined;
7
+ errorOnUnmatchedPattern?: boolean | undefined;
8
+ extensions?: string[] | undefined;
9
+ globInputPaths?: boolean | undefined;
10
+ ignore?: boolean | undefined;
11
+ ignorePath?: string | undefined;
12
+
13
+ // Linting
14
+ allowInlineConfig?: boolean | undefined;
15
+ baseConfig?: Linter.LegacyConfig | undefined;
16
+ overrideConfig?: Linter.LegacyConfig | undefined;
17
+ overrideConfigFile?: string | undefined;
18
+ plugins?: Record<string, ESLint.Plugin> | undefined;
19
+ reportUnusedDisableDirectives?: Linter.StringSeverity | undefined;
20
+ resolvePluginsRelativeTo?: string | undefined;
21
+ rulePaths?: string[] | undefined;
22
+ useEslintrc?: boolean | undefined;
23
+
24
+ // Autofix
25
+ fix?:
26
+ boolean | ((message: Linter.LintMessage) => boolean) | undefined;
27
+ fixTypes?: FixType[] | null | undefined;
28
+
29
+ // Caching
30
+ cache?: boolean | undefined;
31
+ cacheLocation?: string | undefined;
32
+ cacheStrategy?: ESLint.CacheStrategy | undefined;
33
+
34
+ // Unused
35
+ flags?: string[] | undefined;
36
+ }
37
+
4
38
  type FlatESLintOptions = ESLint.Options;
5
39
  type FormatterFunction = ESLint.FormatterFunction;
6
40
  type LintMessage = Linter.LintMessage;
@@ -92,7 +92,7 @@ declare namespace gulpESLintNew
92
92
  formatEach
93
93
  (
94
94
  formatter?: string | LoadedFormatter | FormatterFunction,
95
- writer?: Writer | NodeJS.WritableStream
95
+ writer?: Writer | NodeJS.WritableStream,
96
96
  ):
97
97
  NodeJS.ReadWriteStream;
98
98
 
@@ -111,7 +111,7 @@ declare namespace gulpESLintNew
111
111
  format
112
112
  (
113
113
  formatter?: string | LoadedFormatter | FormatterFunction,
114
- writer?: Writer | NodeJS.WritableStream
114
+ writer?: Writer | NodeJS.WritableStream,
115
115
  ):
116
116
  NodeJS.ReadWriteStream;
117
117
 
package/lib/util.js CHANGED
@@ -259,6 +259,8 @@ exports.hasOwn = hasOwn;
259
259
 
260
260
  exports.isErrorMessage = isErrorMessage;
261
261
 
262
+ exports.isEslintrcESLintConstructor = isEslintrcESLintConstructor;
263
+
262
264
  exports.isWarningMessage = isWarningMessage;
263
265
 
264
266
  const makeNPMLink =
@@ -286,21 +288,35 @@ const FORBIDDEN_OPTIONS =
286
288
 
287
289
  const requireESLint = eslintPkg => require(eslintPkg).ESLint;
288
290
 
291
+ function requireEslintrcESLint(eslintPkg)
292
+ {
293
+ const { LegacyESLint } = require(`${eslintPkg}/use-at-your-own-risk`);
294
+ if (LegacyESLint) return LegacyESLint;
295
+
296
+ const { satisfies } = require('semver');
297
+ const { ESLint } = require(eslintPkg);
298
+ if (satisfies(ESLint.version, '8')) return ESLint;
299
+
300
+ const message =
301
+ 'The version of ESLint you are using does not support eslintrc config. ' +
302
+ 'Eslintrc config is not available in ESLint 10.';
303
+ throw Error(message);
304
+ }
305
+
289
306
  function requireFlatESLint(eslintPkg)
290
307
  {
291
308
  const { FlatESLint } = require(`${eslintPkg}/use-at-your-own-risk`);
292
- if (FlatESLint == null)
293
- {
294
- const message =
295
- 'The version of ESLint you are using does not support flat config. ' +
296
- 'To use flat config, upgrade to ESLint 8.21 or later.';
297
- throw Error(message);
298
- }
299
- return FlatESLint;
300
- }
309
+ if (FlatESLint) return FlatESLint;
301
310
 
302
- const requireEslintrcESLint =
303
- eslintPkg => require(`${eslintPkg}/use-at-your-own-risk`).LegacyESLint || require(eslintPkg).ESLint;
311
+ const { satisfies } = require('semver');
312
+ const { ESLint } = require(eslintPkg);
313
+ if (!satisfies(ESLint.version, '8')) return ESLint;
314
+
315
+ const message =
316
+ 'The version of ESLint you are using does not support flat config. ' +
317
+ 'Flat config is available in ESLint 8.21 or later.';
318
+ throw Error(message);
319
+ }
304
320
 
305
321
  /**
306
322
  * Throws an error about invalid options passed to gulp-eslint-new.
@@ -402,15 +418,23 @@ async ({ cwd, eslint }, formatter) =>
402
418
  if (formatter === undefined)
403
419
  {
404
420
  const { format } = await eslint.loadFormatter();
405
- return {
406
- format: results =>
407
- format(results)
408
- .replace
409
- (
410
- / with the `--fix` option\.(?=(\u001b\[\d+m|\n)+$)/,
411
- ` - see ${makeNPMLink('autofix')}`,
412
- ),
421
+ const formatterObj =
422
+ {
423
+ format:
424
+ results =>
425
+ {
426
+ const stylishText = format(results);
427
+ const text =
428
+ stylishText
429
+ .replace
430
+ (
431
+ / with the `--fix` option\.(?=(\u001b\[\d+m|\n)+$)/,
432
+ ` - see ${makeNPMLink('autofix')}`,
433
+ );
434
+ return text;
435
+ },
413
436
  };
437
+ return formatterObj;
414
438
  }
415
439
  if (isObject(formatter) && typeof formatter.format === 'function')
416
440
  return formatter;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gulp-eslint-new",
3
- "version": "2.5.0",
4
- "description": "A gulp plugin to lint code with ESLint 8 and 9.",
3
+ "version": "2.6.1",
4
+ "description": "A gulp plugin to lint code with ESLint 8, 9 and 10.",
5
5
  "keywords": [
6
6
  "gulpplugin",
7
7
  "eslint",
@@ -42,18 +42,19 @@
42
42
  "ts-test": "tsc --project test/tsconfig.json"
43
43
  },
44
44
  "dependencies": {
45
- "eslint": "8 || 9",
45
+ "eslint": "8 || 9 || 10",
46
46
  "fancy-log": "^2.0.0",
47
47
  "plugin-error": "^2.0.1",
48
- "semver": "^7.7.2",
48
+ "semver": "^7.7.3",
49
49
  "ternary-stream": "^3.0.0",
50
50
  "vinyl-fs": "^4.0.2"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@eslint/js": "^8.57.1",
54
- "@origin-1/eslint-config": "^1.12.1",
54
+ "@origin-1/eslint-config": "^1.14.0",
55
55
  "@types/eslint__js": "^8.42.3",
56
56
  "c8js": "^0.8.1",
57
+ "eslint-10.0": "npm:eslint@10.0.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",
@@ -61,14 +62,14 @@
61
62
  "eslint-9.x": "npm:eslint@9.x",
62
63
  "eslint-config-~shareable": "file:test/config",
63
64
  "eslint-formatter-~formatter": "file:test/formatter",
64
- "eslint-formatter-compact": "^8.40.0",
65
- "eslint-plugin-tsdoc": "^0.4.0",
66
- "globals": "^16.3.0",
65
+ "eslint-formatter-compact": "^9.0.1",
66
+ "eslint-plugin-tsdoc": "^0.5.0",
67
+ "globals": "^17.3.0",
67
68
  "gulp": "^5.0.1",
68
- "jiti": "^2.5.1",
69
+ "jiti": "^2.6.1",
69
70
  "mocha": "^9.2.2",
70
- "resolve": "^1.22.10",
71
- "typescript": "~5.9.2",
71
+ "resolve": "^1.22.11",
72
+ "typescript": "~5.9.3",
72
73
  "typescript_4.8": "npm:typescript@4.8",
73
74
  "typescript_5": "npm:typescript@5",
74
75
  "vinyl": "^3.0.1"