mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(lint): give access to SourceCode in 'deno test' (#28278)
Closes https://github.com/denoland/deno/issues/28273
This commit is contained in:
parent
0fbab02d0f
commit
93a1bb738a
4 changed files with 38 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue