fix(linter): ban --fix for variety files(vue, astro, svelte) (#2189)

closes: #2122
This commit is contained in:
Wenzhe Wang 2024-01-28 13:46:39 +08:00 committed by GitHub
parent 1de3518046
commit f039ad6007
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
@ -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;