Skip to content

Commit a9018a8

Browse files
G-Rathljharb
authored andcommitted
[Refactor] namespace, no-deprecated: update declaredScope to use new getScope when possible
1 parent 107e30d commit a9018a8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"debug": "^3.2.7",
118118
"doctrine": "^2.1.0",
119119
"eslint-import-resolver-node": "^0.3.9",
120-
"eslint-module-utils": "^2.10.0",
120+
"eslint-module-utils": "^2.11.0",
121121
"hasown": "^2.0.2",
122122
"is-core-module": "^2.15.1",
123123
"is-glob": "^4.0.3",

Diff for: src/rules/namespace.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = {
110110
MemberExpression(dereference) {
111111
if (dereference.object.type !== 'Identifier') { return; }
112112
if (!namespaces.has(dereference.object.name)) { return; }
113-
if (declaredScope(context, dereference.object.name) !== 'module') { return; }
113+
if (declaredScope(context, dereference.object.name, dereference) !== 'module') { return; }
114114

115115
if (dereference.parent.type === 'AssignmentExpression' && dereference.parent.left === dereference) {
116116
context.report(
@@ -158,7 +158,7 @@ module.exports = {
158158
if (!namespaces.has(init.name)) { return; }
159159

160160
// check for redefinition in intermediate scopes
161-
if (declaredScope(context, init.name) !== 'module') { return; }
161+
if (declaredScope(context, init.name, init) !== 'module') { return; }
162162

163163
// DFS traverse child namespaces
164164
function testKey(pattern, namespace, path = [init.name]) {

Diff for: src/rules/no-deprecated.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module.exports = {
9898

9999
if (!deprecated.has(node.name)) { return; }
100100

101-
if (declaredScope(context, node.name) !== 'module') { return; }
101+
if (declaredScope(context, node.name, node) !== 'module') { return; }
102102
context.report({
103103
node,
104104
message: message(deprecated.get(node.name)),
@@ -109,7 +109,7 @@ module.exports = {
109109
if (dereference.object.type !== 'Identifier') { return; }
110110
if (!namespaces.has(dereference.object.name)) { return; }
111111

112-
if (declaredScope(context, dereference.object.name) !== 'module') { return; }
112+
if (declaredScope(context, dereference.object.name, dereference) !== 'module') { return; }
113113

114114
// go deep
115115
let namespace = namespaces.get(dereference.object.name);

0 commit comments

Comments
 (0)