diff --git a/apps/oxlint/test/fixtures/sourceCode_scope_methods/output.snap.md b/apps/oxlint/test/fixtures/sourceCode_scope_methods/output.snap.md index 60d61164649bc..b26fccc79d30b 100644 --- a/apps/oxlint/test/fixtures/sourceCode_scope_methods/output.snap.md +++ b/apps/oxlint/test/fixtures/sourceCode_scope_methods/output.snap.md @@ -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; diff --git a/patches/@typescript-eslint__scope-manager.patch b/patches/@typescript-eslint__scope-manager.patch new file mode 100644 index 0000000000000..a5f7822980909 --- /dev/null +++ b/patches/@typescript-eslint__scope-manager.patch @@ -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); + } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a0145dfb3521..78d0c27c75304 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,6 +28,11 @@ catalogs: specifier: 4.0.6 version: 4.0.6 +patchedDependencies: + '@typescript-eslint/scope-manager': + hash: 08ab34b5f27480602bc518186b717a8915aa4d6b2b5df1adc747320ba25b1f8b + path: patches/@typescript-eslint__scope-manager.patch + importers: .: @@ -92,7 +97,7 @@ importers: version: 1.0.8 '@typescript-eslint/scope-manager': specifier: ^8.46.2 - version: 8.46.2 + version: 8.46.2(patch_hash=08ab34b5f27480602bc518186b717a8915aa4d6b2b5df1adc747320ba25b1f8b) eslint: specifier: ^9.36.0 version: 9.38.0(jiti@2.6.1) @@ -5704,7 +5709,7 @@ snapshots: '@types/vscode@1.93.0': {} - '@typescript-eslint/scope-manager@8.46.2': + '@typescript-eslint/scope-manager@8.46.2(patch_hash=08ab34b5f27480602bc518186b717a8915aa4d6b2b5df1adc747320ba25b1f8b)': dependencies: '@typescript-eslint/types': 8.46.2 '@typescript-eslint/visitor-keys': 8.46.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index ff6d4e5bc9b93..0296afea6f58d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -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