eslint-plugin-n 16.3.0 → 16.4.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 +4 -0
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/exports-style.js +8 -8
- package/lib/rules/file-extension-in-import.js +1 -1
- package/lib/rules/global-require.js +8 -3
- package/lib/rules/handle-callback-err.js +2 -1
- package/lib/rules/no-deprecated-api.js +5 -2
- package/lib/rules/no-exports-assign.js +4 -1
- package/lib/rules/no-extraneous-import.js +1 -1
- package/lib/rules/no-extraneous-require.js +1 -1
- package/lib/rules/no-hide-core-modules.js +3 -2
- package/lib/rules/no-missing-import.js +1 -1
- package/lib/rules/no-missing-require.js +1 -1
- package/lib/rules/no-path-concat.js +4 -2
- package/lib/rules/no-unpublished-bin.js +1 -1
- package/lib/rules/no-unpublished-import.js +1 -1
- package/lib/rules/no-unpublished-require.js +1 -1
- package/lib/rules/no-unsupported-features/es-syntax.js +3 -1
- package/lib/rules/no-unsupported-features/node-builtins.js +1 -1
- package/lib/rules/no-unsupported-features.js +10 -5
- package/lib/rules/prefer-promises/dns.js +3 -2
- package/lib/rules/prefer-promises/fs.js +3 -2
- package/lib/rules/shebang.js +2 -2
- package/lib/util/check-prefer-global.js +8 -2
- package/lib/util/check-unsupported-builtins.js +3 -1
- package/lib/util/get-configured-node-version.js +1 -1
- package/lib/util/get-typescript-extension-map.js +6 -10
- package/lib/util/import-target.js +1 -1
- package/lib/util/is-typescript.js +3 -1
- package/lib/util/visit-import.js +3 -1
- package/lib/util/visit-require.js +8 -3
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
Additional ESLint rules for Node.js
|
|
10
10
|
|
|
11
|
+
## 🎨 Playground
|
|
12
|
+
|
|
13
|
+
[online-playground](https://eslint-online-playground.netlify.app/#eNp1jzEOwjAMRa9SeWFpYS8rOwtiIQxRalWBxIniFIFQ747bCASV2BK/Lz//J3AyG7xrHx2uLwwtWB9DytXKW2ZLfVP+q60iqGGN7CzlZCQbSNJPRVWlAO8ZqWMFbXWS3xxqE5rgvcyxU1BLKrqht9TS5oec67Kj0PcO+gI6MaZ9zDYUPEtnrfH6iIkFTHMFTmfkLLZ3gsOQDB4eEUvAh25w8p74qGiUTlGbq+6n9t+NOrztME4nkrG40M79/hgLbEqbZnHXRzu+APYwfks=)
|
|
14
|
+
|
|
11
15
|
## 💿 Install & Usage
|
|
12
16
|
|
|
13
17
|
```sh
|
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
|
26
26
|
|
|
27
27
|
create(context) {
|
|
28
28
|
const callbacks = context.options[0] || ["callback", "cb", "next"]
|
|
29
|
-
const sourceCode = context.getSourceCode()
|
|
29
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Find the closest parent matching a list of types.
|
|
@@ -258,7 +258,7 @@ module.exports = {
|
|
|
258
258
|
const batchAssignAllowed = Boolean(
|
|
259
259
|
context.options[1] != null && context.options[1].allowBatchAssign
|
|
260
260
|
)
|
|
261
|
-
const sourceCode = context.getSourceCode()
|
|
261
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Gets the location info of reports.
|
|
@@ -286,8 +286,7 @@ module.exports = {
|
|
|
286
286
|
*
|
|
287
287
|
* @returns {void}
|
|
288
288
|
*/
|
|
289
|
-
function enforceModuleExports() {
|
|
290
|
-
const globalScope = context.getScope()
|
|
289
|
+
function enforceModuleExports(globalScope) {
|
|
291
290
|
const exportsNodes = getExportsNodes(globalScope)
|
|
292
291
|
const assignList = batchAssignAllowed
|
|
293
292
|
? createAssignmentList(getModuleExportsNodes(globalScope))
|
|
@@ -317,8 +316,7 @@ module.exports = {
|
|
|
317
316
|
*
|
|
318
317
|
* @returns {void}
|
|
319
318
|
*/
|
|
320
|
-
function enforceExports() {
|
|
321
|
-
const globalScope = context.getScope()
|
|
319
|
+
function enforceExports(globalScope) {
|
|
322
320
|
const exportsNodes = getExportsNodes(globalScope)
|
|
323
321
|
const moduleExportsNodes = getModuleExportsNodes(globalScope)
|
|
324
322
|
const assignList = batchAssignAllowed
|
|
@@ -370,13 +368,15 @@ module.exports = {
|
|
|
370
368
|
}
|
|
371
369
|
|
|
372
370
|
return {
|
|
373
|
-
"Program:exit"() {
|
|
371
|
+
"Program:exit"(node) {
|
|
372
|
+
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
373
|
+
|
|
374
374
|
switch (mode) {
|
|
375
375
|
case "module.exports":
|
|
376
|
-
enforceModuleExports()
|
|
376
|
+
enforceModuleExports(scope)
|
|
377
377
|
break
|
|
378
378
|
case "exports":
|
|
379
|
-
enforceExports()
|
|
379
|
+
enforceExports(scope)
|
|
380
380
|
break
|
|
381
381
|
|
|
382
382
|
// no default
|
|
@@ -64,16 +64,21 @@ module.exports = {
|
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
create(context) {
|
|
67
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
68
|
+
|
|
67
69
|
return {
|
|
68
70
|
CallExpression(node) {
|
|
69
|
-
const currentScope =
|
|
71
|
+
const currentScope =
|
|
72
|
+
sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
70
73
|
|
|
71
74
|
if (
|
|
72
75
|
node.callee.name === "require" &&
|
|
73
76
|
!isShadowed(currentScope, node.callee)
|
|
74
77
|
) {
|
|
75
|
-
const isGoodRequire =
|
|
76
|
-
.getAncestors()
|
|
78
|
+
const isGoodRequire = (
|
|
79
|
+
sourceCode.getAncestors?.(node) ??
|
|
80
|
+
context.getAncestors()
|
|
81
|
+
) // TODO: remove context.getAncestors() when dropping support for ESLint < v9
|
|
77
82
|
.every(
|
|
78
83
|
parent =>
|
|
79
84
|
ACCEPTABLE_PARENTS.indexOf(parent.type) > -1
|
|
@@ -24,6 +24,7 @@ module.exports = {
|
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
create(context) {
|
|
27
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
27
28
|
const errorArgument = context.options[0] || "err"
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -69,7 +70,7 @@ module.exports = {
|
|
|
69
70
|
* @returns {void}
|
|
70
71
|
*/
|
|
71
72
|
function checkForError(node) {
|
|
72
|
-
const scope = context.getScope()
|
|
73
|
+
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
73
74
|
const parameters = getParameters(scope)
|
|
74
75
|
const firstParameter = parameters[0]
|
|
75
76
|
|
|
@@ -756,9 +756,12 @@ module.exports = {
|
|
|
756
756
|
})
|
|
757
757
|
}
|
|
758
758
|
|
|
759
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
759
760
|
return {
|
|
760
|
-
"Program:exit"() {
|
|
761
|
-
const
|
|
761
|
+
"Program:exit"(node) {
|
|
762
|
+
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
763
|
+
|
|
764
|
+
const tracker = new ReferenceTracker(scope, {
|
|
762
765
|
mode: "legacy",
|
|
763
766
|
})
|
|
764
767
|
|
|
@@ -50,9 +50,12 @@ module.exports = {
|
|
|
50
50
|
type: "problem",
|
|
51
51
|
},
|
|
52
52
|
create(context) {
|
|
53
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
54
|
+
|
|
53
55
|
return {
|
|
54
56
|
AssignmentExpression(node) {
|
|
55
|
-
const scope = context.getScope()
|
|
57
|
+
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
58
|
+
|
|
56
59
|
if (
|
|
57
60
|
!isExports(node.left, scope) ||
|
|
58
61
|
// module.exports = exports = {}
|
|
@@ -85,10 +85,11 @@ module.exports = {
|
|
|
85
85
|
},
|
|
86
86
|
},
|
|
87
87
|
create(context) {
|
|
88
|
-
|
|
88
|
+
const filename = context.filename ?? context.getFilename()
|
|
89
|
+
if (filename === "<input>") {
|
|
89
90
|
return {}
|
|
90
91
|
}
|
|
91
|
-
const filePath = path.resolve(
|
|
92
|
+
const filePath = path.resolve(filename)
|
|
92
93
|
const dirPath = path.dirname(filePath)
|
|
93
94
|
const packageJson = getPackageJson(filePath)
|
|
94
95
|
const deps = new Set(
|
|
@@ -179,8 +179,10 @@ module.exports = {
|
|
|
179
179
|
|
|
180
180
|
create(context) {
|
|
181
181
|
return {
|
|
182
|
-
"Program:exit"() {
|
|
183
|
-
const
|
|
182
|
+
"Program:exit"(node) {
|
|
183
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
184
|
+
const globalScope =
|
|
185
|
+
sourceCode.getScope?.(node) ?? context.getScope()
|
|
184
186
|
const tracker = new ReferenceTracker(globalScope)
|
|
185
187
|
const sepNodes = new Set()
|
|
186
188
|
|
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
messages,
|
|
36
36
|
},
|
|
37
37
|
create(context) {
|
|
38
|
-
const filePath = context.getFilename()
|
|
38
|
+
const filePath = context.filename ?? context.getFilename()
|
|
39
39
|
const options = context.options[0] || {}
|
|
40
40
|
const ignoreTypeImport =
|
|
41
41
|
options.ignoreTypeImport === void 0
|
|
@@ -443,7 +443,9 @@ function normalizeScope(initialScope, node) {
|
|
|
443
443
|
function defineVisitor(context, options) {
|
|
444
444
|
const testInfoPrototype = {
|
|
445
445
|
get isStrict() {
|
|
446
|
-
|
|
446
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
447
|
+
const scope = sourceCode.getScope?.(this.node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
448
|
+
return normalizeScope(scope, this.node).isStrict
|
|
447
449
|
},
|
|
448
450
|
}
|
|
449
451
|
|
|
@@ -1085,10 +1085,10 @@ module.exports = {
|
|
|
1085
1085
|
},
|
|
1086
1086
|
},
|
|
1087
1087
|
create(context) {
|
|
1088
|
-
const sourceCode = context.getSourceCode()
|
|
1088
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
1089
1089
|
const supportInfo = parseOptions(
|
|
1090
1090
|
context.options[0],
|
|
1091
|
-
getDefaultVersion(context.getFilename())
|
|
1091
|
+
getDefaultVersion(context.filename ?? context.getFilename())
|
|
1092
1092
|
)
|
|
1093
1093
|
|
|
1094
1094
|
/**
|
|
@@ -1098,7 +1098,8 @@ module.exports = {
|
|
|
1098
1098
|
* @returns {void}
|
|
1099
1099
|
*/
|
|
1100
1100
|
function* getReferences(names) {
|
|
1101
|
-
const globalScope =
|
|
1101
|
+
const globalScope =
|
|
1102
|
+
sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
1102
1103
|
|
|
1103
1104
|
for (const name of names) {
|
|
1104
1105
|
const variable = globalScope.set.get(name)
|
|
@@ -1159,6 +1160,8 @@ module.exports = {
|
|
|
1159
1160
|
* @returns {void}
|
|
1160
1161
|
*/
|
|
1161
1162
|
function report(node, key) {
|
|
1163
|
+
const globalScope =
|
|
1164
|
+
sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
1162
1165
|
const version = supportInfo.version
|
|
1163
1166
|
const feature = supportInfo.features[key]
|
|
1164
1167
|
if (feature.supported) {
|
|
@@ -1175,7 +1178,7 @@ module.exports = {
|
|
|
1175
1178
|
version,
|
|
1176
1179
|
},
|
|
1177
1180
|
})
|
|
1178
|
-
} else if (!normalizeScope(
|
|
1181
|
+
} else if (!normalizeScope(globalScope, node).isStrict) {
|
|
1179
1182
|
context.report({
|
|
1180
1183
|
node,
|
|
1181
1184
|
messageId: "unsupported",
|
|
@@ -1331,7 +1334,9 @@ module.exports = {
|
|
|
1331
1334
|
},
|
|
1332
1335
|
|
|
1333
1336
|
FunctionDeclaration(node) {
|
|
1334
|
-
const scope =
|
|
1337
|
+
const scope = (
|
|
1338
|
+
sourceCode.getScope?.(node) ?? context.getScope()
|
|
1339
|
+
).upper //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
1335
1340
|
if (!TOPLEVEL_SCOPE_TYPE.test(scope.type)) {
|
|
1336
1341
|
report(node, "blockScopedFunctions")
|
|
1337
1342
|
}
|
|
@@ -52,8 +52,9 @@ module.exports = {
|
|
|
52
52
|
|
|
53
53
|
create(context) {
|
|
54
54
|
return {
|
|
55
|
-
"Program:exit"() {
|
|
56
|
-
const
|
|
55
|
+
"Program:exit"(node) {
|
|
56
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
57
|
+
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
57
58
|
const tracker = new ReferenceTracker(scope, { mode: "legacy" })
|
|
58
59
|
const references = [
|
|
59
60
|
...tracker.iterateCjsReferences(trackMap),
|
|
@@ -53,8 +53,9 @@ module.exports = {
|
|
|
53
53
|
|
|
54
54
|
create(context) {
|
|
55
55
|
return {
|
|
56
|
-
"Program:exit"() {
|
|
57
|
-
const
|
|
56
|
+
"Program:exit"(node) {
|
|
57
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
58
|
+
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
58
59
|
const tracker = new ReferenceTracker(scope, { mode: "legacy" })
|
|
59
60
|
const references = [
|
|
60
61
|
...tracker.iterateCjsReferences(trackMap),
|
package/lib/rules/shebang.js
CHANGED
|
@@ -94,8 +94,8 @@ module.exports = {
|
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
96
|
create(context) {
|
|
97
|
-
const sourceCode = context.getSourceCode()
|
|
98
|
-
let filePath = context.getFilename()
|
|
97
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
98
|
+
let filePath = context.filename ?? context.getFilename()
|
|
99
99
|
if (filePath === "<input>") {
|
|
100
100
|
return {}
|
|
101
101
|
}
|
|
@@ -31,7 +31,10 @@ class Verifier {
|
|
|
31
31
|
*/
|
|
32
32
|
verifyToPreferGlobals() {
|
|
33
33
|
const { context, trackMap } = this
|
|
34
|
-
const
|
|
34
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
35
|
+
const scope =
|
|
36
|
+
sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
37
|
+
const tracker = new ReferenceTracker(scope, {
|
|
35
38
|
mode: "legacy",
|
|
36
39
|
})
|
|
37
40
|
|
|
@@ -51,7 +54,10 @@ class Verifier {
|
|
|
51
54
|
*/
|
|
52
55
|
verifyToPreferModules() {
|
|
53
56
|
const { context, trackMap } = this
|
|
54
|
-
const
|
|
57
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
58
|
+
const scope =
|
|
59
|
+
sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
60
|
+
const tracker = new ReferenceTracker(scope)
|
|
55
61
|
|
|
56
62
|
for (const { node } of tracker.iterateGlobalReferences(
|
|
57
63
|
trackMap.globals
|
|
@@ -85,7 +85,9 @@ module.exports.checkUnsupportedBuiltins = function checkUnsupportedBuiltins(
|
|
|
85
85
|
trackMap
|
|
86
86
|
) {
|
|
87
87
|
const options = parseOptions(context)
|
|
88
|
-
const
|
|
88
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
89
|
+
const scope = sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
90
|
+
const tracker = new ReferenceTracker(scope, { mode: "legacy" })
|
|
89
91
|
const references = [
|
|
90
92
|
...tracker.iterateCjsReferences(trackMap.modules || {}),
|
|
91
93
|
...tracker.iterateEsmReferences(trackMap.modules || {}),
|
|
@@ -47,7 +47,7 @@ module.exports = function getConfiguredNodeVersion(context) {
|
|
|
47
47
|
const version =
|
|
48
48
|
get(context.options && context.options[0]) ||
|
|
49
49
|
get(context.settings && (context.settings.n || context.settings.node))
|
|
50
|
-
const filePath = context.getFilename()
|
|
50
|
+
const filePath = context.filename ?? context.getFilename()
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
53
|
getSemverRange(version) ||
|
|
@@ -112,19 +112,15 @@ function getFromTSConfigFromFile(filename) {
|
|
|
112
112
|
* @returns {string[]} A list of extensions.
|
|
113
113
|
*/
|
|
114
114
|
module.exports = function getTypescriptExtensionMap(context) {
|
|
115
|
+
const filename =
|
|
116
|
+
context.physicalFilename ??
|
|
117
|
+
context.getPhysicalFilename?.() ??
|
|
118
|
+
context.filename ??
|
|
119
|
+
context.getFilename?.() // TODO: remove context.get(PhysicalFilename|Filename) when dropping eslint < v10
|
|
115
120
|
return (
|
|
116
121
|
get(context.options?.[0]) ||
|
|
117
122
|
get(context.settings?.n ?? context.settings?.node) ||
|
|
118
|
-
getFromTSConfigFromFile(
|
|
119
|
-
// eslint ^8
|
|
120
|
-
context.physicalFilename ??
|
|
121
|
-
// eslint ^7.28 (deprecated ^8)
|
|
122
|
-
context.getPhysicalFilename?.() ??
|
|
123
|
-
// eslint ^8 (if physicalFilename undefined)
|
|
124
|
-
context.filename ??
|
|
125
|
-
// eslint ^7 (deprecated ^8)
|
|
126
|
-
context.getFilename?.()
|
|
127
|
-
) ||
|
|
123
|
+
getFromTSConfigFromFile(filename) ||
|
|
128
124
|
PRESERVE_MAPPING
|
|
129
125
|
)
|
|
130
126
|
}
|
|
@@ -11,6 +11,8 @@ const typescriptExtensions = [".ts", ".tsx", ".cts", ".mts"]
|
|
|
11
11
|
* @returns {boolean}
|
|
12
12
|
*/
|
|
13
13
|
module.exports = function isTypescript(context) {
|
|
14
|
-
const sourceFileExt = path.extname(
|
|
14
|
+
const sourceFileExt = path.extname(
|
|
15
|
+
context.physicalFilename ?? context.getPhysicalFilename()
|
|
16
|
+
)
|
|
15
17
|
return typescriptExtensions.includes(sourceFileExt)
|
|
16
18
|
}
|
package/lib/util/visit-import.js
CHANGED
|
@@ -30,7 +30,9 @@ module.exports = function visitImport(
|
|
|
30
30
|
callback
|
|
31
31
|
) {
|
|
32
32
|
const targets = []
|
|
33
|
-
const basedir = path.dirname(
|
|
33
|
+
const basedir = path.dirname(
|
|
34
|
+
path.resolve(context.filename ?? context.getFilename())
|
|
35
|
+
)
|
|
34
36
|
const paths = getResolvePaths(context, optionIndex)
|
|
35
37
|
const extensions = getTryExtensions(context, optionIndex)
|
|
36
38
|
const options = { basedir, paths, extensions }
|
|
@@ -33,14 +33,19 @@ module.exports = function visitRequire(
|
|
|
33
33
|
callback
|
|
34
34
|
) {
|
|
35
35
|
const targets = []
|
|
36
|
-
const basedir = path.dirname(
|
|
36
|
+
const basedir = path.dirname(
|
|
37
|
+
path.resolve(context.filename ?? context.getFilename())
|
|
38
|
+
)
|
|
37
39
|
const paths = getResolvePaths(context)
|
|
38
40
|
const extensions = getTryExtensions(context)
|
|
39
41
|
const options = { basedir, paths, extensions }
|
|
40
42
|
|
|
41
43
|
return {
|
|
42
|
-
"Program:exit"() {
|
|
43
|
-
const
|
|
44
|
+
"Program:exit"(node) {
|
|
45
|
+
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
|
|
46
|
+
const tracker = new ReferenceTracker(
|
|
47
|
+
sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
|
|
48
|
+
)
|
|
44
49
|
const references = tracker.iterateGlobalReferences({
|
|
45
50
|
require: {
|
|
46
51
|
[CALL]: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-n",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.4.0",
|
|
4
4
|
"description": "Additional ESLint's rules for Node.js",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@eslint-community/eslint-utils": "^4.4.0",
|
|
18
18
|
"builtins": "^5.0.1",
|
|
19
|
-
"eslint-plugin-es-x": "^7.
|
|
19
|
+
"eslint-plugin-es-x": "^7.5.0",
|
|
20
20
|
"get-tsconfig": "^4.7.0",
|
|
21
21
|
"ignore": "^5.2.4",
|
|
22
|
+
"is-builtin-module": "^3.2.1",
|
|
22
23
|
"is-core-module": "^2.12.1",
|
|
23
24
|
"minimatch": "^3.1.2",
|
|
24
25
|
"resolve": "^1.22.2",
|
|
@@ -26,10 +27,10 @@
|
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@eslint/js": "^8.43.0",
|
|
29
|
-
"@types/eslint": "^8.44.
|
|
30
|
+
"@types/eslint": "^8.44.6",
|
|
30
31
|
"@typescript-eslint/parser": "^5.60.0",
|
|
31
32
|
"esbuild": "^0.18.7",
|
|
32
|
-
"eslint": "^8.
|
|
33
|
+
"eslint": "^8.53.0",
|
|
33
34
|
"eslint-config-prettier": "^8.8.0",
|
|
34
35
|
"eslint-doc-generator": "^1.4.3",
|
|
35
36
|
"eslint-plugin-eslint-plugin": "^5.1.0",
|