summaryrefslogtreecommitdiff
path: root/cli/tools/lint.rs
diff options
context:
space:
mode:
authorZheyu Zhang <zheyuzhang03@gmail.com>2021-10-30 15:59:53 +0800
committerGitHub <noreply@github.com>2021-10-30 09:59:53 +0200
commit85a2943435d645c0b45e27e4f0312b5434e1fb65 (patch)
treee395e0ee42f1e8ce9a2fe0ab7b3727798c33bbdf /cli/tools/lint.rs
parentd44011a69e0674acfa9c59bd7ad7f0523eb61d42 (diff)
fix(cli): lint/format all discoverd files on each change (#12518)
Diffstat (limited to 'cli/tools/lint.rs')
-rw-r--r--cli/tools/lint.rs37
1 files changed, 19 insertions, 18 deletions
diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs
index 6948d2a1f..1f85e8b02 100644
--- a/cli/tools/lint.rs
+++ b/cli/tools/lint.rs
@@ -105,26 +105,27 @@ pub async fn lint(
let resolver = |changed: Option<Vec<PathBuf>>| {
let files_changed = changed.is_some();
- let result = collect_files(
- &*include_files.clone(),
- &*exclude_files.clone(),
- is_supported_ext,
- )
- .map(|files| {
- if let Some(paths) = changed {
- files
- .into_iter()
- .filter(|path| paths.contains(path))
- .collect::<Vec<_>>()
- } else {
- files
+ let collect_files =
+ collect_files(&include_files, &exclude_files, is_supported_ext);
+
+ let paths_to_watch = include_files.clone();
+
+ let (result, should_relint) = match collect_files {
+ Ok(value) => {
+ if let Some(paths) = changed {
+ (
+ Ok(value.clone()),
+ Some(value.iter().any(|path| paths.contains(path))),
+ )
+ } else {
+ (Ok(value), None)
+ }
}
- });
- let paths_to_watch = args.clone();
+ Err(e) => (Err(e), None),
+ };
+
async move {
- if (files_changed || !watch)
- && matches!(result, Ok(ref files) if files.is_empty())
- {
+ if files_changed && matches!(should_relint, Some(false)) {
ResolutionResult::Ignore
} else {
ResolutionResult::Restart {