Skip to content

Commit

Permalink
refactor(linter): clean up the runtime after the module record change (
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 1, 2024
1 parent 823353a commit 8392177
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions crates/oxc_linter/src/service/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,22 +211,13 @@ impl Runtime {
};
};

// Build the module record to unblock other threads from waiting for too long.
// 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);
let module_record = Arc::new(ModuleRecord::new(path, &ret.module_record));

// If import plugin is enabled.
if self.resolver.is_some() {
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();
module_record
.requested_modules
Expand Down Expand Up @@ -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() {
return semantic_ret.errors.into_iter().map(|err| Message::new(err, None)).collect();
Expand Down

0 comments on commit 8392177

Please sign in to comment.