fix(lint): give access to SourceCode in 'deno test' (#28278)

Closes https://github.com/denoland/deno/issues/28273
This commit is contained in:
Bartek Iwańczuk 2025-02-24 17:21:16 +01:00 committed by GitHub
parent 0fbab02d0f
commit 93a1bb738a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 1 deletions

View file

@ -17,6 +17,7 @@ const {
} = core.ops;
let doReport = op_lint_report;
let doGetSource = op_lint_get_source;
// Keep these in sync with Rust
const AST_IDX_INVALID = 0;
@ -264,7 +265,7 @@ export class SourceCode {
*/
#getSource() {
if (this.#source === null) {
this.#source = op_lint_get_source();
this.#source = doGetSource();
}
return /** @type {string} */ (this.#source);
}
@ -1365,6 +1366,9 @@ function runLintPlugin(plugin, fileName, sourceText) {
fix,
});
};
doGetSource = () => {
return sourceText;
};
try {
const serializedAst = op_lint_create_serialized_ast(fileName, sourceText);
@ -1373,6 +1377,7 @@ function runLintPlugin(plugin, fileName, sourceText) {
resetState();
}
doReport = op_lint_report;
doGetSource = op_lint_get_source;
return diagnostics;
}