Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
8 | };
`----

x scope-plugin(scope): isGlobalReference(Math): false
x scope-plugin(scope): isGlobalReference(Math): true
,-[files/index.js:7:28]
6 | return function innerFunction() {
7 | return localConstant + Math.PI;
Expand Down
52 changes: 52 additions & 0 deletions patches/@typescript-eslint__scope-manager.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/dist/scope/ScopeBase.js b/dist/scope/ScopeBase.js
index 5e07a7c3fb4670b2ce4fa405798d2f27c0084fef..b773c16431a860580dd9408c6127b06256c41c3b 100644
--- a/dist/scope/ScopeBase.js
+++ b/dist/scope/ScopeBase.js
@@ -8,6 +8,7 @@ const ID_1 = require("../ID");
const Reference_1 = require("../referencer/Reference");
const variable_1 = require("../variable");
const ScopeType_1 = require("./ScopeType");
+const ImplicitLibVariable_1 = require("../variable/ImplicitLibVariable");
/**
* Test if scope is strict
*/
@@ -254,6 +255,10 @@ class ScopeBase {
return false;
}
// variable exists on the scope
+ // implicit lib variables should always be resolved statically
+ if (variable instanceof ImplicitLibVariable_1.ImplicitLibVariable) {
+ return true;
+ }
// in module mode, we can statically resolve everything, regardless of its decl type
if (scopeManager.isModule()) {
return true;
@@ -306,6 +311,11 @@ class ScopeBase {
set.set(name, variable);
variables.push(variable);
}
+ else if (variable instanceof ImplicitLibVariable_1.ImplicitLibVariable &&
+ nameOrVariable instanceof ImplicitLibVariable_1.ImplicitLibVariable) {
+ variable.isTypeVariable ||= nameOrVariable.isTypeVariable;
+ variable.isValueVariable ||= nameOrVariable.isValueVariable;
+ }
if (def) {
variable.defs.push(def);
this.addDeclaredVariablesOfNode(variable, def.node);
diff --git a/dist/variable/ImplicitLibVariable.d.ts b/dist/variable/ImplicitLibVariable.d.ts
index 6c967519e4bf1ce20c0fc5dd60e5bde2e3ae9ef2..2c4ef8ffb2aba72467d6e7679f042cffabdb03ab 100644
--- a/dist/variable/ImplicitLibVariable.d.ts
+++ b/dist/variable/ImplicitLibVariable.d.ts
@@ -18,10 +18,10 @@ export declare class ImplicitLibVariable extends ESLintScopeVariable implements
/**
* `true` if the variable is valid in a type context, false otherwise
*/
- readonly isTypeVariable: boolean;
+ isTypeVariable: boolean;
/**
* `true` if the variable is valid in a value context, false otherwise
*/
- readonly isValueVariable: boolean;
+ isValueVariable: boolean;
constructor(scope: Scope, name: string, { eslintImplicitGlobalSetting, isTypeVariable, isValueVariable, writeable, }: ImplicitLibVariableOptions);
}
9 changes: 7 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ onlyBuiltDependencies:
- '@vscode/vsce-sign@2.0.8'
- esbuild@0.25.11

patchedDependencies:
'@typescript-eslint/scope-manager': patches/@typescript-eslint__scope-manager.patch

verifyDepsBeforeRun: install
Loading