From be8f23612067453e5ef9a9f38a84e205af56b285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E7=84=B6?= Date: Wed, 6 Dec 2023 10:45:50 +0800 Subject: [PATCH] fix: do not use `context.getScope()` --- lib/util/check-prefer-global.js | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/util/check-prefer-global.js b/lib/util/check-prefer-global.js index d2a75cc1..ff6e8c51 100644 --- a/lib/util/check-prefer-global.js +++ b/lib/util/check-prefer-global.js @@ -55,7 +55,10 @@ class Verifier { */ verifyToPreferModules() { const { context, trackMap } = this - const tracker = new ReferenceTracker(context.getScope()) + const sourceCode = context.sourceCode ?? context.getSourceCode() + const scope = + sourceCode.getScope?.(context.sourceCode.ast) ?? context.getScope() + const tracker = new ReferenceTracker(scope) for (const { node } of tracker.iterateGlobalReferences( trackMap.globals diff --git a/package.json b/package.json index d63ce26b..641e25ea 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "builtins": "^5.0.1", - "eslint-plugin-es-x": "^7.1.0", + "eslint-plugin-es-x": "^7.5.0", "get-tsconfig": "^4.7.0", "ignore": "^5.2.4", "is-builtin-module": "^3.2.1",