@@ -13,55 +13,56 @@ const ReferenceTrackerESM: unique symbol = eslintUtils.ReferenceTracker.ESM;
13
13
interface ReferenceTracker {
14
14
/**
15
15
* Iterate the references that the given `traceMap` determined.
16
- * This method starts to search from global variables .
16
+ * This method starts to search from `require()` expression .
17
17
*
18
- * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateglobalreferences }
18
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iteratecjsreferences }
19
19
*/
20
- iterateGlobalReferences < T > (
20
+ iterateCjsReferences < T > (
21
21
traceMap : ReferenceTracker . TraceMap < T > ,
22
22
) : IterableIterator < ReferenceTracker . FoundReference < T > > ;
23
23
24
24
/**
25
25
* Iterate the references that the given `traceMap` determined.
26
- * This method starts to search from `require()` expression .
26
+ * This method starts to search from `import`/`export` declarations .
27
27
*
28
- * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iteratecjsreferences }
28
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateesmreferences }
29
29
*/
30
- iterateCjsReferences < T > (
30
+ iterateEsmReferences < T > (
31
31
traceMap : ReferenceTracker . TraceMap < T > ,
32
32
) : IterableIterator < ReferenceTracker . FoundReference < T > > ;
33
33
34
34
/**
35
35
* Iterate the references that the given `traceMap` determined.
36
- * This method starts to search from `import`/`export` declarations .
36
+ * This method starts to search from global variables .
37
37
*
38
- * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateesmreferences }
38
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateglobalreferences }
39
39
*/
40
- iterateEsmReferences < T > (
40
+ iterateGlobalReferences < T > (
41
41
traceMap : ReferenceTracker . TraceMap < T > ,
42
42
) : IterableIterator < ReferenceTracker . FoundReference < T > > ;
43
43
}
44
44
interface ReferenceTrackerStatic {
45
+ readonly CALL : typeof ReferenceTrackerCALL ;
46
+ readonly CONSTRUCT : typeof ReferenceTrackerCONSTRUCT ;
47
+ readonly ESM : typeof ReferenceTrackerESM ;
48
+
45
49
new (
46
50
globalScope : TSESLint . Scope . Scope ,
47
51
options ?: {
52
+ /**
53
+ * The name list of Global Object. Optional. Default is `["global", "globalThis", "self", "window"]`.
54
+ */
55
+ globalObjectNames ?: readonly string [ ] ;
48
56
/**
49
57
* The mode which determines how the `tracker.iterateEsmReferences()` method scans CommonJS modules.
50
58
* If this is `"strict"`, the method binds CommonJS modules to the default export. Otherwise, the method binds
51
59
* CommonJS modules to both the default export and named exports. Optional. Default is `"strict"`.
52
60
*/
53
61
mode ?: 'legacy' | 'strict' ;
54
- /**
55
- * The name list of Global Object. Optional. Default is `["global", "globalThis", "self", "window"]`.
56
- */
57
- globalObjectNames ?: readonly string [ ] ;
58
62
} ,
59
63
) : ReferenceTracker ;
60
64
61
65
readonly READ : typeof ReferenceTrackerREAD ;
62
- readonly CALL : typeof ReferenceTrackerCALL ;
63
- readonly CONSTRUCT : typeof ReferenceTrackerCONSTRUCT ;
64
- readonly ESM : typeof ReferenceTrackerESM ;
65
66
}
66
67
67
68
namespace ReferenceTracker {
@@ -73,18 +74,18 @@ namespace ReferenceTracker {
73
74
// eslint-disable-next-line @typescript-eslint/no-explicit-any
74
75
export type TraceMap < T = any > = Record < string , TraceMapElement < T > > ;
75
76
export interface TraceMapElement < T > {
76
- [ ReferenceTrackerREAD ] ?: T ;
77
+ [ key : string ] : TraceMapElement < T > ;
77
78
[ ReferenceTrackerCALL ] ?: T ;
78
79
[ ReferenceTrackerCONSTRUCT ] ?: T ;
79
80
[ ReferenceTrackerESM ] ?: true ;
80
- [ key : string ] : TraceMapElement < T > ;
81
+ [ ReferenceTrackerREAD ] ?: T ;
81
82
}
82
83
// eslint-disable-next-line @typescript-eslint/no-explicit-any
83
84
export interface FoundReference < T = any > {
85
+ info : T ;
84
86
node : TSESTree . Node ;
85
87
path : readonly string [ ] ;
86
88
type : ReferenceType ;
87
- info : T ;
88
89
}
89
90
}
90
91
0 commit comments