0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00

plugins are run inside CliLinter now

This commit is contained in:
Bartek Iwańczuk 2024-12-24 10:52:36 +01:00
parent e6d0a6fde1
commit f6efc9f357
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 24 additions and 24 deletions

View file

@ -75,10 +75,6 @@ impl CliLinter {
}
}
pub fn get_plugin_runner(&self) -> Option<Arc<Mutex<PluginRunnerProxy>>> {
self.maybe_plugin_runner.clone()
}
pub fn run_plugins(
&self,
parsed_source: ParsedSource,
@ -131,7 +127,7 @@ impl CliLinter {
MediaType::from_specifier(&specifier)
};
if self.fix {
let result = if self.fix {
self.lint_file_and_fix(&specifier, media_type, source_code, file_path)
} else {
self
@ -143,6 +139,19 @@ impl CliLinter {
config: self.deno_lint_config.clone(),
})
.map_err(AnyError::from)
};
match result {
Ok((file_source, mut file_diagnostics)) => {
// TODO(bartlomieju): now add it to `linter.lint_with_ast()`.
// TODO(bartlomieju): plugins don't support fixing for now.
let plugin_diagnostics =
self.run_plugins(file_source.clone(), file_path.to_path_buf())?;
file_diagnostics.extend_from_slice(&plugin_diagnostics);
Ok((file_source, file_diagnostics))
}
Err(err) => Err(err),
}
}

View file

@ -341,27 +341,18 @@ impl WorkspaceLinter {
file_text,
cli_options.ext_flag().as_deref(),
);
let r = match r {
Ok((file_source, mut file_diagnostics)) => {
// TODO(bartlomieju): now move it to `linter.lint_file()` and `linter.lint_with_ast()`.
let plugin_diagnostics =
linter.run_plugins(file_source.clone(), file_path.clone())?;
file_diagnostics.extend_from_slice(&plugin_diagnostics);
if let Some(incremental_cache) = &maybe_incremental_cache_ {
if file_diagnostics.is_empty() {
// update the incremental cache if there were no diagnostics
incremental_cache.update_file(
&file_path,
// ensure the returned text is used here as it may have been modified via --fix
file_source.text(),
)
}
if let Ok((file_source, file_diagnostics)) = &r {
if let Some(incremental_cache) = &maybe_incremental_cache_ {
if file_diagnostics.is_empty() {
// update the incremental cache if there were no diagnostics
incremental_cache.update_file(
&file_path,
// ensure the returned text is used here as it may have been modified via --fix
file_source.text(),
)
}
Ok((file_source, file_diagnostics))
}
Err(err) => Err(err),
};
}
let success = handle_lint_result(
&file_path.to_string_lossy(),