Skip to content

Commit

Permalink
[Refactor] namespace, no-deprecated: update declaredScope to us…
Browse files Browse the repository at this point in the history
…e new `getScope` when possible
  • Loading branch information
G-Rath authored and ljharb committed Sep 6, 2024
1 parent 107e30d commit a9018a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"debug": "^3.2.7",
"doctrine": "^2.1.0",
"eslint-import-resolver-node": "^0.3.9",
"eslint-module-utils": "^2.10.0",
"eslint-module-utils": "^2.11.0",
"hasown": "^2.0.2",
"is-core-module": "^2.15.1",
"is-glob": "^4.0.3",
Expand Down
4 changes: 2 additions & 2 deletions src/rules/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {
MemberExpression(dereference) {
if (dereference.object.type !== 'Identifier') { return; }
if (!namespaces.has(dereference.object.name)) { return; }
if (declaredScope(context, dereference.object.name) !== 'module') { return; }
if (declaredScope(context, dereference.object.name, dereference) !== 'module') { return; }

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

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

// DFS traverse child namespaces
function testKey(pattern, namespace, path = [init.name]) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {

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

if (declaredScope(context, node.name) !== 'module') { return; }
if (declaredScope(context, node.name, node) !== 'module') { return; }
context.report({
node,
message: message(deprecated.get(node.name)),
Expand All @@ -109,7 +109,7 @@ module.exports = {
if (dereference.object.type !== 'Identifier') { return; }
if (!namespaces.has(dereference.object.name)) { return; }

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

// go deep
let namespace = namespaces.get(dereference.object.name);
Expand Down

0 comments on commit a9018a8

Please sign in to comment.