diff --git a/apps/oxlint/src-js/plugins/lint.ts b/apps/oxlint/src-js/plugins/lint.ts index 36ef7df042618..517d3cf6d2196 100644 --- a/apps/oxlint/src-js/plugins/lint.ts +++ b/apps/oxlint/src-js/plugins/lint.ts @@ -1,6 +1,6 @@ import { diagnostics, setupContextForFile } from './context.js'; import { registeredRules } from './load.js'; -import { ast, initAst, resetSource, setupSourceForFile } from './source_code.js'; +import { ast, initAst, resetSourceAndAst, setupSourceForFile } from './source_code.js'; import { assertIs, getErrorMessage } from './utils.js'; import { addVisitorToCompiled, compiledVisitor, finalizeCompiledVisitor, initCompiledVisitor } from './visitor.js'; @@ -160,6 +160,6 @@ function lintFileImpl(filePath: string, bufferId: number, buffer: Uint8Array | n afterHooks.length = 0; } - // Reset source, to free memory - resetSource(); + // Reset source and AST, to free memory + resetSourceAndAst(); } diff --git a/apps/oxlint/src-js/plugins/source_code.ts b/apps/oxlint/src-js/plugins/source_code.ts index 3e27e50725bba..65e24a84ea4b7 100644 --- a/apps/oxlint/src-js/plugins/source_code.ts +++ b/apps/oxlint/src-js/plugins/source_code.ts @@ -65,7 +65,7 @@ export function initAst(): void { } /** - * Reset source after file has been linted, to free memory. + * Reset source and AST after file has been linted, to free memory. * * Setting `buffer` to `null` also prevents AST being deserialized after linting, * at which point the buffer may be being reused for another file. @@ -74,7 +74,7 @@ export function initAst(): void { * With `buffer` set to `null`, accessing `SOURCE_CODE.ast` will still throw, but the error message will be clearer, * and no danger of an infinite loop due to a circular AST (unlikely but possible). */ -export function resetSource(): void { +export function resetSourceAndAst(): void { buffer = null; sourceText = null; ast = null;