diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 2 | ||||
-rw-r--r-- | cli/tools/lint/linter.rs | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index bb6508b55..e53979298 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -70,7 +70,7 @@ deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] deno_doc = { version = "0.146.0", features = ["html", "syntect"] } deno_emit = "=0.44.0" deno_graph = { version = "=0.81.2" } -deno_lint = { version = "=0.62.0", features = ["docs"] } +deno_lint = { version = "=0.63.1", features = ["docs"] } deno_lockfile.workspace = true deno_npm = "=0.21.4" deno_package_json.workspace = true diff --git a/cli/tools/lint/linter.rs b/cli/tools/lint/linter.rs index f6ea76c14..777fe4d09 100644 --- a/cli/tools/lint/linter.rs +++ b/cli/tools/lint/linter.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::collections::HashSet; use std::path::Path; use deno_ast::MediaType; @@ -225,14 +226,23 @@ fn apply_lint_fixes( if quick_fixes.is_empty() { return None; } + + let mut import_fixes = HashSet::new(); // remove any overlapping text changes, we'll circle // back for another pass to fix the remaining quick_fixes.sort_by_key(|change| change.range.start); for i in (1..quick_fixes.len()).rev() { let cur = &quick_fixes[i]; let previous = &quick_fixes[i - 1]; - let is_overlapping = cur.range.start < previous.range.end; - if is_overlapping { + // hack: deduplicate import fixes to avoid creating errors + if previous.new_text.trim_start().starts_with("import ") { + import_fixes.insert(previous.new_text.trim().to_string()); + } + let is_overlapping = cur.range.start <= previous.range.end; + if is_overlapping + || (cur.new_text.trim_start().starts_with("import ") + && import_fixes.contains(cur.new_text.trim())) + { quick_fixes.remove(i); } } |