Skip to content

Commit 45009d3

Browse files
committed
feat: better "TraceMap" types
1 parent b3fccf9 commit 45009d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+173
-173
lines changed

lib/rules/no-unsupported-features/es-builtins.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const {
1212
const enumeratePropertyNames = require("../../util/enumerate-property-names")
1313
const getConfiguredNodeVersion = require("../../util/get-configured-node-version")
1414

15-
/** @type {Record<'globals' | 'modules', import('../../unsupported-features/types.js').SupportVersionTree>} */
16-
const trackMap = {
15+
/** @type {Record<'globals' | 'modules', import('../../unsupported-features/types.js').SupportVersionTraceMap>} */
16+
const traceMap = {
1717
globals: {
1818
// Core js builtins
1919
AggregateError: {
@@ -640,7 +640,7 @@ module.exports = {
640640
type: "array",
641641
items: {
642642
enum: Array.from(
643-
enumeratePropertyNames(trackMap.globals)
643+
enumeratePropertyNames(traceMap.globals)
644644
),
645645
},
646646
uniqueItems: true,
@@ -654,7 +654,7 @@ module.exports = {
654654
create(context) {
655655
return {
656656
"Program:exit"() {
657-
checkUnsupportedBuiltins(context, trackMap)
657+
checkUnsupportedBuiltins(context, traceMap)
658658
},
659659
}
660660
},

lib/rules/no-unsupported-features/node-builtins.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const {
2121
* @property {import('@eslint-community/eslint-utils').TraceMap<boolean>} globals
2222
* @property {import('@eslint-community/eslint-utils').TraceMap<boolean>} modules
2323
*/
24-
const trackMap = {
24+
const traceMap = {
2525
globals: {
2626
queueMicrotask: {
2727
[READ]: { supported: ["12.0.0"], experimental: ["11.0.0"] },
@@ -34,26 +34,26 @@ const trackMap = {
3434
},
3535
modules: NodeBuiltinModules,
3636
}
37-
Object.assign(trackMap.globals, {
38-
Buffer: trackMap.modules.buffer.Buffer,
37+
Object.assign(traceMap.globals, {
38+
Buffer: traceMap.modules.buffer.Buffer,
3939
TextDecoder: {
40-
...trackMap.modules.util.TextDecoder,
40+
...traceMap.modules.util.TextDecoder,
4141
[READ]: { supported: ["11.0.0"] },
4242
},
4343
TextEncoder: {
44-
...trackMap.modules.util.TextEncoder,
44+
...traceMap.modules.util.TextEncoder,
4545
[READ]: { supported: ["11.0.0"] },
4646
},
4747
URL: {
48-
...trackMap.modules.url.URL,
48+
...traceMap.modules.url.URL,
4949
[READ]: { supported: ["10.0.0"] },
5050
},
5151
URLSearchParams: {
52-
...trackMap.modules.url.URLSearchParams,
52+
...traceMap.modules.url.URLSearchParams,
5353
[READ]: { supported: ["10.0.0"] },
5454
},
55-
console: trackMap.modules.console,
56-
process: trackMap.modules.process,
55+
console: traceMap.modules.console,
56+
process: traceMap.modules.process,
5757
})
5858

5959
/** @type {import('eslint').Rule.RuleModule} */
@@ -77,8 +77,8 @@ module.exports = {
7777
items: {
7878
enum: Array.from(
7979
new Set([
80-
...enumeratePropertyNames(trackMap.globals),
81-
...enumeratePropertyNames(trackMap.modules),
80+
...enumeratePropertyNames(traceMap.globals),
81+
...enumeratePropertyNames(traceMap.modules),
8282
])
8383
),
8484
},
@@ -93,7 +93,7 @@ module.exports = {
9393
create(context) {
9494
return {
9595
"Program:exit"() {
96-
checkUnsupportedBuiltins(context, trackMap)
96+
checkUnsupportedBuiltins(context, traceMap)
9797
},
9898
}
9999
},

lib/rules/prefer-global/buffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
Buffer: { [READ]: true },
1313
},
@@ -40,7 +40,7 @@ module.exports = {
4040
create(context) {
4141
return {
4242
"Program:exit"() {
43-
checkForPreferGlobal(context, trackMap)
43+
checkForPreferGlobal(context, traceMap)
4444
},
4545
}
4646
},

lib/rules/prefer-global/console.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
console: { [READ]: true },
1313
},
@@ -39,7 +39,7 @@ module.exports = {
3939
create(context) {
4040
return {
4141
"Program:exit"() {
42-
checkForPreferGlobal(context, trackMap)
42+
checkForPreferGlobal(context, traceMap)
4343
},
4444
}
4545
},

lib/rules/prefer-global/process.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
process: { [READ]: true },
1313
},
@@ -39,7 +39,7 @@ module.exports = {
3939
create(context) {
4040
return {
4141
"Program:exit"() {
42-
checkForPreferGlobal(context, trackMap)
42+
checkForPreferGlobal(context, traceMap)
4343
},
4444
}
4545
},

lib/rules/prefer-global/text-decoder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
TextDecoder: { [READ]: true },
1313
},
@@ -40,7 +40,7 @@ module.exports = {
4040
create(context) {
4141
return {
4242
"Program:exit"() {
43-
checkForPreferGlobal(context, trackMap)
43+
checkForPreferGlobal(context, traceMap)
4444
},
4545
}
4646
},

lib/rules/prefer-global/text-encoder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
TextEncoder: { [READ]: true },
1313
},
@@ -40,7 +40,7 @@ module.exports = {
4040
create(context) {
4141
return {
4242
"Program:exit"() {
43-
checkForPreferGlobal(context, trackMap)
43+
checkForPreferGlobal(context, traceMap)
4444
},
4545
}
4646
},

lib/rules/prefer-global/url-search-params.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
URLSearchParams: { [READ]: true },
1313
},
@@ -40,7 +40,7 @@ module.exports = {
4040
create(context) {
4141
return {
4242
"Program:exit"() {
43-
checkForPreferGlobal(context, trackMap)
43+
checkForPreferGlobal(context, traceMap)
4444
},
4545
}
4646
},

lib/rules/prefer-global/url.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { READ } = require("@eslint-community/eslint-utils")
88
const checkForPreferGlobal = require("../../util/check-prefer-global")
99

10-
const trackMap = {
10+
const traceMap = {
1111
globals: {
1212
URL: { [READ]: true },
1313
},
@@ -39,7 +39,7 @@ module.exports = {
3939
create(context) {
4040
return {
4141
"Program:exit"() {
42-
checkForPreferGlobal(context, trackMap)
42+
checkForPreferGlobal(context, traceMap)
4343
},
4444
}
4545
},

lib/rules/prefer-promises/dns.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const {
1111
} = require("@eslint-community/eslint-utils")
1212

1313
/** @type {import('@eslint-community/eslint-utils').TraceMap<boolean>} */
14-
const trackMap = {
14+
const traceMap = {
1515
dns: {
1616
lookup: { [CALL]: true },
1717
lookupService: { [CALL]: true },
@@ -33,7 +33,7 @@ const trackMap = {
3333
setServers: { [CALL]: true },
3434
},
3535
}
36-
trackMap["node:dns"] = trackMap.dns
36+
traceMap["node:dns"] = traceMap.dns
3737

3838
/** @type {import('eslint').Rule.RuleModule} */
3939
module.exports = {
@@ -59,8 +59,8 @@ module.exports = {
5959
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
6060
const tracker = new ReferenceTracker(scope, { mode: "legacy" })
6161
const references = [
62-
...tracker.iterateCjsReferences(trackMap),
63-
...tracker.iterateEsmReferences(trackMap),
62+
...tracker.iterateCjsReferences(traceMap),
63+
...tracker.iterateEsmReferences(traceMap),
6464
]
6565

6666
for (const { node, path } of references) {

lib/rules/prefer-promises/fs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
const { CALL, ReferenceTracker } = require("@eslint-community/eslint-utils")
88

99
/** @type {import('@eslint-community/eslint-utils').TraceMap<boolean>} */
10-
const trackMap = {
10+
const traceMap = {
1111
fs: {
1212
access: { [CALL]: true },
1313
copyFile: { [CALL]: true },
@@ -35,7 +35,7 @@ const trackMap = {
3535
readFile: { [CALL]: true },
3636
},
3737
}
38-
trackMap["node:fs"] = trackMap.fs
38+
traceMap["node:fs"] = traceMap.fs
3939

4040
/** @type {import('eslint').Rule.RuleModule} */
4141
module.exports = {
@@ -60,8 +60,8 @@ module.exports = {
6060
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
6161
const tracker = new ReferenceTracker(scope, { mode: "legacy" })
6262
const references = [
63-
...tracker.iterateCjsReferences(trackMap),
64-
...tracker.iterateEsmReferences(trackMap),
63+
...tracker.iterateCjsReferences(traceMap),
64+
...tracker.iterateEsmReferences(traceMap),
6565
]
6666

6767
for (const { node, path } of references) {

lib/unsupported-features/node-builtins-modules/assert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { READ } = require("@eslint-community/eslint-utils")
44

5-
/** @type {import('../types.js').SupportVersionTree} */
5+
/** @type {import('../types.js').SupportVersionTraceMap} */
66
const assert = {
77
assert: { [READ]: { supported: ["0.5.9"] } },
88
deepEqual: { [READ]: { supported: ["0.1.21"] } },
@@ -45,7 +45,7 @@ assert.strict = {
4545
[READ]: { supported: ["9.9.0", "8.13.0"] },
4646
}
4747

48-
/** @type {import('../types.js').SupportVersionTree} */
48+
/** @type {import('../types.js').SupportVersionTraceMap} */
4949
module.exports = {
5050
assert: {
5151
...assert,

lib/unsupported-features/node-builtins-modules/async_hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { READ } = require("@eslint-community/eslint-utils")
44

5-
/** @type {import('../types.js').SupportVersionTree} */
5+
/** @type {import('../types.js').SupportVersionTraceMap} */
66
const async_hooks = {
77
createHook: { [READ]: { experimental: ["8.1.0"] } },
88
executionAsyncResource: { [READ]: { experimental: ["13.9.0", "12.17.0"] } },
@@ -25,7 +25,7 @@ const async_hooks = {
2525
},
2626
}
2727

28-
/** @type {import('../types.js').SupportVersionTree} */
28+
/** @type {import('../types.js').SupportVersionTraceMap} */
2929
module.exports = {
3030
async_hooks: {
3131
[READ]: {

lib/unsupported-features/node-builtins-modules/buffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { READ } = require("@eslint-community/eslint-utils")
44

5-
/** @type {import('../types.js').SupportVersionTree} */
5+
/** @type {import('../types.js').SupportVersionTraceMap} */
66
const buffer = {
77
constants: { [READ]: { supported: ["8.2.0"] } },
88
INSPECT_MAX_BYTES: { [READ]: { supported: ["0.5.4"] } },
@@ -42,7 +42,7 @@ const buffer = {
4242
},
4343
}
4444

45-
/** @type {import('../types.js').SupportVersionTree} */
45+
/** @type {import('../types.js').SupportVersionTraceMap} */
4646
module.exports = {
4747
buffer: {
4848
[READ]: { supported: ["0.1.90"] },

lib/unsupported-features/node-builtins-modules/child_process.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { READ } = require("@eslint-community/eslint-utils")
44

5-
/** @type {import('../types.js').SupportVersionTree} */
5+
/** @type {import('../types.js').SupportVersionTraceMap} */
66
const child_process = {
77
exec: { [READ]: { supported: ["0.1.90"] } },
88
execFile: { [READ]: { supported: ["0.1.91"] } },
@@ -14,7 +14,7 @@ const child_process = {
1414
ChildProcess: { [READ]: { supported: ["2.2.0"] } },
1515
}
1616

17-
/** @type {import('../types.js').SupportVersionTree} */
17+
/** @type {import('../types.js').SupportVersionTraceMap} */
1818
module.exports = {
1919
child_process: {
2020
[READ]: { supported: ["0.1.90"] },

lib/unsupported-features/node-builtins-modules/cluster.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { READ } = require("@eslint-community/eslint-utils")
44

5-
/** @type {import('../types.js').SupportVersionTree} */
5+
/** @type {import('../types.js').SupportVersionTraceMap} */
66
const cluster = {
77
isMaster: { [READ]: { supported: ["0.8.1"], deprecated: ["16.0.0"] } },
88
isPrimary: { [READ]: { supported: ["16.0.0"] } },
@@ -18,7 +18,7 @@ const cluster = {
1818
Worker: { [READ]: { supported: ["0.7.0"] } },
1919
}
2020

21-
/** @type {import('../types.js').SupportVersionTree} */
21+
/** @type {import('../types.js').SupportVersionTraceMap} */
2222
module.exports = {
2323
cluster: {
2424
[READ]: { supported: ["0.7.0"] },

lib/unsupported-features/node-builtins-modules/console.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { READ } = require("@eslint-community/eslint-utils")
44

5-
/** @type {import('../types.js').SupportVersionTree} */
5+
/** @type {import('../types.js').SupportVersionTraceMap} */
66
const console = {
77
profile: { [READ]: { supported: ["8.0.0"] } },
88
profileEnd: { [READ]: { supported: ["8.0.0"] } },
@@ -34,7 +34,7 @@ const console = {
3434
// timelineEnd: { [READ]: { supported: ["8.0.0"] } },
3535
}
3636

37-
/** @type {import('../types.js').SupportVersionTree} */
37+
/** @type {import('../types.js').SupportVersionTraceMap} */
3838
module.exports = {
3939
console: {
4040
[READ]: { supported: ["0.1.100"] },

0 commit comments

Comments
 (0)