refactor(linter): clean up the runtime after the module record change (#7557)

This commit is contained in:
Boshen 2024-12-01 05:32:41 +00:00
parent 823353a6fc
commit 839217770c

View file

@ -211,22 +211,13 @@ impl Runtime {
}; };
}; };
// Build the module record to unblock other threads from waiting for too long. let module_record = Arc::new(ModuleRecord::new(path, &ret.module_record));
// The semantic model is not built at this stage.
let semantic_builder = SemanticBuilder::new()
.with_cfg(true)
.with_scope_tree_child_ids(true)
.with_build_jsdoc(true)
.with_check_syntax_error(check_syntax_errors);
let mut module_record = ModuleRecord::new(path, &ret.module_record);
module_record.resolved_absolute_path = path.to_path_buf();
let module_record = Arc::new(module_record);
// If import plugin is enabled.
if self.resolver.is_some() { if self.resolver.is_some() {
self.modules.add_resolved_module(path, Arc::clone(&module_record)); self.modules.add_resolved_module(path, Arc::clone(&module_record));
// Retrieve all dependency modules from this module. // Retrieve all dependent modules from this module.
let dir = path.parent().unwrap(); let dir = path.parent().unwrap();
module_record module_record
.requested_modules .requested_modules
@ -291,7 +282,12 @@ impl Runtime {
} }
} }
let semantic_ret = semantic_builder.build(&ret.program); let semantic_ret = SemanticBuilder::new()
.with_cfg(true)
.with_scope_tree_child_ids(true)
.with_build_jsdoc(true)
.with_check_syntax_error(check_syntax_errors)
.build(&ret.program);
if !semantic_ret.errors.is_empty() { if !semantic_ret.errors.is_empty() {
return semantic_ret.errors.into_iter().map(|err| Message::new(err, None)).collect(); return semantic_ret.errors.into_iter().map(|err| Message::new(err, None)).collect();