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:
parent
e6d0a6fde1
commit
f6efc9f357
2 changed files with 24 additions and 24 deletions
|
@ -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(
|
pub fn run_plugins(
|
||||||
&self,
|
&self,
|
||||||
parsed_source: ParsedSource,
|
parsed_source: ParsedSource,
|
||||||
|
@ -131,7 +127,7 @@ impl CliLinter {
|
||||||
MediaType::from_specifier(&specifier)
|
MediaType::from_specifier(&specifier)
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.fix {
|
let result = if self.fix {
|
||||||
self.lint_file_and_fix(&specifier, media_type, source_code, file_path)
|
self.lint_file_and_fix(&specifier, media_type, source_code, file_path)
|
||||||
} else {
|
} else {
|
||||||
self
|
self
|
||||||
|
@ -143,6 +139,19 @@ impl CliLinter {
|
||||||
config: self.deno_lint_config.clone(),
|
config: self.deno_lint_config.clone(),
|
||||||
})
|
})
|
||||||
.map_err(AnyError::from)
|
.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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -341,27 +341,18 @@ impl WorkspaceLinter {
|
||||||
file_text,
|
file_text,
|
||||||
cli_options.ext_flag().as_deref(),
|
cli_options.ext_flag().as_deref(),
|
||||||
);
|
);
|
||||||
let r = match r {
|
if let Ok((file_source, file_diagnostics)) = &r {
|
||||||
Ok((file_source, mut file_diagnostics)) => {
|
if let Some(incremental_cache) = &maybe_incremental_cache_ {
|
||||||
// TODO(bartlomieju): now move it to `linter.lint_file()` and `linter.lint_with_ast()`.
|
if file_diagnostics.is_empty() {
|
||||||
let plugin_diagnostics =
|
// update the incremental cache if there were no diagnostics
|
||||||
linter.run_plugins(file_source.clone(), file_path.clone())?;
|
incremental_cache.update_file(
|
||||||
|
&file_path,
|
||||||
file_diagnostics.extend_from_slice(&plugin_diagnostics);
|
// ensure the returned text is used here as it may have been modified via --fix
|
||||||
if let Some(incremental_cache) = &maybe_incremental_cache_ {
|
file_source.text(),
|
||||||
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(
|
let success = handle_lint_result(
|
||||||
&file_path.to_string_lossy(),
|
&file_path.to_string_lossy(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue