@@ -226,49 +226,3 @@ export function getScope(node: ESTree.Node): Scope {
226226
227227 return scopeManager . scopes [ 0 ] ;
228228}
229-
230- /**
231- * Mark a variable as used in the current scope
232- * @param name - The name of the variable to mark as used.
233- * @param refNode? - The closest node to the variable reference.
234- * @returns `true` if the variable was found and marked as used, `false` if not.
235- */
236- export function markVariableAsUsed ( name : string , refNode ?: ESTree . Node ) : boolean {
237- // ref: https://github.com/eslint/eslint/blob/e7cda3bdf1bdd664e6033503a3315ad81736b200/lib/languages/js/source-code/source-code.js#L991-L1023
238- const currentScope = getScope ( refNode ?? SOURCE_CODE . ast ) ;
239- let initialScope = currentScope ;
240-
241- /*
242- * When we are in an ESM or CommonJS module, we need to start searching
243- * from the top-level scope, not the global scope. For ESM the top-level
244- * scope is the module scope; for CommonJS the top-level scope is the
245- * outer function scope.
246- *
247- * Without this check, we might miss a variable declared with `var` at
248- * the top-level because it won't exist in the global scope.
249- */
250- if (
251- currentScope . type === 'global' &&
252- currentScope . childScopes . length > 0 &&
253- // top-level scopes refer to a `Program` node
254- currentScope . childScopes [ 0 ] . block === SOURCE_CODE . ast
255- ) {
256- initialScope = currentScope . childScopes [ 0 ] ;
257- }
258-
259- for ( let scope = initialScope ; scope ; scope = scope . upper ) {
260- const { variables } = scope ;
261- for ( let i = 0 ; i < variables . length ; i ++ ) {
262- const variable = variables [ i ] ;
263- if ( variable . name === name ) {
264- // This probably will not have the intended effect since mutation here does not
265- // have any bearing on the rust side analysis.
266- // @ts -expect-error - eslintUsed is not part of the public API.
267- variable . eslintUsed = true ;
268- return true ;
269- }
270- }
271- }
272-
273- return false ;
274- }
0 commit comments