eslint 9.28.0 → 9.29.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 +1 -1
- package/conf/ecma-version.js +1 -1
- package/conf/globals.js +10 -0
- package/lib/cli.js +6 -11
- package/lib/eslint/eslint.js +13 -17
- package/lib/languages/js/source-code/source-code.js +74 -27
- package/lib/linter/apply-disable-directives.js +2 -4
- package/lib/linter/code-path-analysis/code-path-analyzer.js +8 -9
- package/lib/linter/linter.js +4 -4
- package/lib/linter/source-code-traverser.js +64 -49
- package/lib/linter/source-code-visitor.js +81 -0
- package/lib/rules/class-methods-use-this.js +7 -0
- package/lib/rules/no-promise-executor-return.js +4 -35
- package/lib/rules/no-restricted-globals.js +35 -2
- package/lib/rules/no-restricted-properties.js +24 -10
- package/lib/rules/no-setter-return.js +13 -48
- package/lib/rules/no-use-before-define.js +2 -0
- package/lib/rules/no-var.js +14 -2
- package/lib/rules/prefer-regex-literals.js +1 -18
- package/lib/services/suppressions-service.js +8 -0
- package/lib/shared/naming.js +109 -0
- package/lib/shared/relative-module-resolver.js +28 -0
- package/lib/types/index.d.ts +8 -2
- package/lib/types/rules.d.ts +5 -0
- package/package.json +7 -7
- package/lib/linter/safe-emitter.js +0 -52
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* Utility for resolving a module relative to another module
|
3
|
+
* @author Teddy Katz
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const Module = require("node:module");
|
9
|
+
|
10
|
+
/*
|
11
|
+
* `Module.createRequire` is added in v12.2.0. It supports URL as well.
|
12
|
+
* We only support the case where the argument is a filepath, not a URL.
|
13
|
+
*/
|
14
|
+
const createRequire = Module.createRequire;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Resolves a Node module relative to another module
|
18
|
+
* @param {string} moduleName The name of a Node module, or a path to a Node module.
|
19
|
+
* @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
|
20
|
+
* a file rather than a directory, but the file need not actually exist.
|
21
|
+
* @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
|
22
|
+
* @throws {Error} When the module cannot be resolved.
|
23
|
+
*/
|
24
|
+
function resolve(moduleName, relativeToPath) {
|
25
|
+
return createRequire(relativeToPath).resolve(moduleName);
|
26
|
+
}
|
27
|
+
|
28
|
+
exports.resolve = resolve;
|
package/lib/types/index.d.ts
CHANGED
@@ -289,6 +289,8 @@ export class SourceCode
|
|
289
289
|
second: ESTree.Node | AST.Token,
|
290
290
|
): boolean;
|
291
291
|
|
292
|
+
isGlobalReference(node: ESTree.Identifier): boolean;
|
293
|
+
|
292
294
|
markVariableAsUsed(name: string, refNode?: ESTree.Node): boolean;
|
293
295
|
|
294
296
|
traverse(): Iterable<TraversalStep>;
|
@@ -1414,6 +1416,7 @@ export namespace Linter {
|
|
1414
1416
|
| 14
|
1415
1417
|
| 15
|
1416
1418
|
| 16
|
1419
|
+
| 17
|
1417
1420
|
| 2015
|
1418
1421
|
| 2016
|
1419
1422
|
| 2017
|
@@ -1425,6 +1428,7 @@ export namespace Linter {
|
|
1425
1428
|
| 2023
|
1426
1429
|
| 2024
|
1427
1430
|
| 2025
|
1431
|
+
| 2026
|
1428
1432
|
| "latest";
|
1429
1433
|
|
1430
1434
|
/**
|
@@ -1624,7 +1628,9 @@ export namespace Linter {
|
|
1624
1628
|
postprocess?:
|
1625
1629
|
| ((problemLists: LintMessage[][]) => LintMessage[])
|
1626
1630
|
| undefined;
|
1627
|
-
filterCodeBlock?:
|
1631
|
+
filterCodeBlock?:
|
1632
|
+
| ((filename: string, text: string) => boolean)
|
1633
|
+
| undefined;
|
1628
1634
|
disableFixes?: boolean | undefined;
|
1629
1635
|
allowInlineConfig?: boolean | undefined;
|
1630
1636
|
reportUnusedDisableDirectives?: boolean | undefined;
|
@@ -1829,7 +1835,7 @@ export namespace Linter {
|
|
1829
1835
|
}
|
1830
1836
|
|
1831
1837
|
/** @deprecated Use `Config` instead of `FlatConfig` */
|
1832
|
-
type FlatConfig = Config
|
1838
|
+
type FlatConfig<Rules extends RulesRecord = RulesRecord> = Config<Rules>;
|
1833
1839
|
|
1834
1840
|
type GlobalConf =
|
1835
1841
|
| boolean
|
package/lib/types/rules.d.ts
CHANGED
@@ -3470,6 +3470,11 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
3470
3470
|
allowObjects?: string[];
|
3471
3471
|
message?: string | undefined;
|
3472
3472
|
}
|
3473
|
+
| {
|
3474
|
+
object: string;
|
3475
|
+
allowProperties?: string[];
|
3476
|
+
message?: string | undefined;
|
3477
|
+
}
|
3473
3478
|
>,
|
3474
3479
|
]
|
3475
3480
|
>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.29.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"type": "commonjs",
|
@@ -106,11 +106,11 @@
|
|
106
106
|
"dependencies": {
|
107
107
|
"@eslint-community/eslint-utils": "^4.2.0",
|
108
108
|
"@eslint-community/regexpp": "^4.12.1",
|
109
|
-
"@eslint/config-array": "^0.20.
|
109
|
+
"@eslint/config-array": "^0.20.1",
|
110
110
|
"@eslint/config-helpers": "^0.2.1",
|
111
111
|
"@eslint/core": "^0.14.0",
|
112
112
|
"@eslint/eslintrc": "^3.3.1",
|
113
|
-
"@eslint/js": "9.
|
113
|
+
"@eslint/js": "9.29.0",
|
114
114
|
"@eslint/plugin-kit": "^0.3.1",
|
115
115
|
"@humanfs/node": "^0.16.6",
|
116
116
|
"@humanwhocodes/module-importer": "^1.0.1",
|
@@ -122,9 +122,9 @@
|
|
122
122
|
"cross-spawn": "^7.0.6",
|
123
123
|
"debug": "^4.3.2",
|
124
124
|
"escape-string-regexp": "^4.0.0",
|
125
|
-
"eslint-scope": "^8.
|
126
|
-
"eslint-visitor-keys": "^4.2.
|
127
|
-
"espree": "^10.
|
125
|
+
"eslint-scope": "^8.4.0",
|
126
|
+
"eslint-visitor-keys": "^4.2.1",
|
127
|
+
"espree": "^10.4.0",
|
128
128
|
"esquery": "^1.5.0",
|
129
129
|
"esutils": "^2.0.2",
|
130
130
|
"fast-deep-equal": "^3.1.3",
|
@@ -176,7 +176,7 @@
|
|
176
176
|
"jiti": "^2.2.0",
|
177
177
|
"jiti-v2.0": "npm:jiti@2.0.x",
|
178
178
|
"jiti-v2.1": "npm:jiti@2.1.x",
|
179
|
-
"knip": "^5.
|
179
|
+
"knip": "^5.60.2",
|
180
180
|
"lint-staged": "^11.0.0",
|
181
181
|
"load-perf": "^0.2.0",
|
182
182
|
"markdown-it": "^12.2.0",
|
@@ -1,52 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview A variant of EventEmitter which does not give listeners information about each other
|
3
|
-
* @author Teddy Katz
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
//------------------------------------------------------------------------------
|
9
|
-
// Typedefs
|
10
|
-
//------------------------------------------------------------------------------
|
11
|
-
|
12
|
-
/**
|
13
|
-
* An event emitter
|
14
|
-
* @typedef {Object} SafeEmitter
|
15
|
-
* @property {(eventName: string, listenerFunc: Function) => void} on Adds a listener for a given event name
|
16
|
-
* @property {(eventName: string, arg1?: any, arg2?: any, arg3?: any) => void} emit Emits an event with a given name.
|
17
|
-
* This calls all the listeners that were listening for that name, with `arg1`, `arg2`, and `arg3` as arguments.
|
18
|
-
* @property {function(): string[]} eventNames Gets the list of event names that have registered listeners.
|
19
|
-
*/
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Creates an object which can listen for and emit events.
|
23
|
-
* This is similar to the EventEmitter API in Node's standard library, but it has a few differences.
|
24
|
-
* The goal is to allow multiple modules to attach arbitrary listeners to the same emitter, without
|
25
|
-
* letting the modules know about each other at all.
|
26
|
-
* 1. It has no special keys like `error` and `newListener`, which would allow modules to detect when
|
27
|
-
* another module throws an error or registers a listener.
|
28
|
-
* 2. It calls listener functions without any `this` value. (`EventEmitter` calls listeners with a
|
29
|
-
* `this` value of the emitter instance, which would give listeners access to other listeners.)
|
30
|
-
* @returns {SafeEmitter} An emitter
|
31
|
-
*/
|
32
|
-
module.exports = () => {
|
33
|
-
const listeners = Object.create(null);
|
34
|
-
|
35
|
-
return Object.freeze({
|
36
|
-
on(eventName, listener) {
|
37
|
-
if (eventName in listeners) {
|
38
|
-
listeners[eventName].push(listener);
|
39
|
-
} else {
|
40
|
-
listeners[eventName] = [listener];
|
41
|
-
}
|
42
|
-
},
|
43
|
-
emit(eventName, ...args) {
|
44
|
-
if (eventName in listeners) {
|
45
|
-
listeners[eventName].forEach(listener => listener(...args));
|
46
|
-
}
|
47
|
-
},
|
48
|
-
eventNames() {
|
49
|
-
return Object.keys(listeners);
|
50
|
-
},
|
51
|
-
});
|
52
|
-
};
|