Skip to content

Commit

Permalink
fix(linter): ban --fix for variety files(vue, astro, svelte) (#2189)
Browse files Browse the repository at this point in the history
closes: #2122
  • Loading branch information
mysteryven committed Jan 28, 2024
1 parent 1de3518 commit f039ad6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/oxc_linter/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ impl Runtime {
}
};

let sources = PartialLoader::parse(ext, &source_text)
.unwrap_or_else(|| vec![JavaScriptSource::new(&source_text, source_type, 0)]);
let sources = PartialLoader::parse(ext, &source_text);
let is_processed_by_partial_loader = sources.is_some();
let sources =
sources.unwrap_or_else(|| vec![JavaScriptSource::new(&source_text, source_type, 0)]);

if sources.is_empty() {
return;
Expand All @@ -187,7 +189,8 @@ impl Runtime {
let mut messages =
self.process_source(path, &allocator, source_text, source_type, true, tx_error);

if self.linter.options().fix {
// TODO: Span is wrong, ban this feature for file process by `PartialLoader`.
if !is_processed_by_partial_loader && self.linter.options().fix {
let fix_result = Fixer::new(source_text, messages).fix();
fs::write(path, fix_result.fixed_code.as_bytes()).unwrap();
messages = fix_result.messages;
Expand Down

0 comments on commit f039ad6

Please sign in to comment.