mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
parent
7d61832284
commit
fa116448c9
6 changed files with 12 additions and 9 deletions
|
|
@ -305,7 +305,7 @@ impl IsolatedLintHandler {
|
|||
|
||||
let lint_ctx = LintContext::new(
|
||||
path.to_path_buf().into_boxed_path(),
|
||||
&Rc::new(semantic_ret.semantic),
|
||||
Rc::new(semantic_ret.semantic),
|
||||
);
|
||||
|
||||
let result = linter.run(lint_ctx);
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ pub struct LintContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> LintContext<'a> {
|
||||
pub fn new(file_path: Box<Path>, semantic: &Rc<Semantic<'a>>) -> Self {
|
||||
pub fn new(file_path: Box<Path>, semantic: Rc<Semantic<'a>>) -> Self {
|
||||
let disable_directives =
|
||||
DisableDirectivesBuilder::new(semantic.source_text(), semantic.trivias()).build();
|
||||
Self {
|
||||
semantic: Rc::clone(semantic),
|
||||
semantic,
|
||||
diagnostics: RefCell::new(vec![]),
|
||||
disable_directives: Rc::new(disable_directives),
|
||||
fix: false,
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ impl Runtime {
|
|||
};
|
||||
|
||||
let lint_ctx =
|
||||
LintContext::new(path.to_path_buf().into_boxed_path(), &Rc::new(semantic_ret.semantic));
|
||||
LintContext::new(path.to_path_buf().into_boxed_path(), Rc::new(semantic_ret.semantic));
|
||||
self.linter.run(lint_ctx)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -317,15 +317,15 @@ mod test {
|
|||
let semantic_ret = Rc::new(semantic_ret);
|
||||
|
||||
let path = Path::new("foo.js");
|
||||
let ctx = LintContext::new(Box::from(path), &semantic_ret);
|
||||
let ctx = LintContext::new(Box::from(path), Rc::clone(&semantic_ret));
|
||||
assert!(!super::is_jest_file(&ctx));
|
||||
|
||||
let path = Path::new("foo.test.js");
|
||||
let ctx = LintContext::new(Box::from(path), &semantic_ret);
|
||||
let ctx = LintContext::new(Box::from(path), Rc::clone(&semantic_ret));
|
||||
assert!(super::is_jest_file(&ctx));
|
||||
|
||||
let path = Path::new("__tests__/foo/test.spec.js");
|
||||
let ctx = LintContext::new(Box::from(path), &semantic_ret);
|
||||
let ctx = LintContext::new(Box::from(path), semantic_ret);
|
||||
assert!(super::is_jest_file(&ctx));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ impl Oxc {
|
|||
let semantic = Rc::new(semantic_ret.semantic);
|
||||
// Only lint if there are not syntax errors
|
||||
if run_options.lint() && self.diagnostics.borrow().is_empty() {
|
||||
let lint_ctx = LintContext::new(path.clone().into_boxed_path(), &semantic);
|
||||
let lint_ctx = LintContext::new(path.clone().into_boxed_path(), Rc::clone(&semantic));
|
||||
let linter_ret = Linter::default().run(lint_ctx);
|
||||
let diagnostics = linter_ret.into_iter().map(|e| Error::from(e.error)).collect();
|
||||
self.save_diagnostics(diagnostics);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ fn bench_linter(criterion: &mut Criterion) {
|
|||
let linter = Linter::from_options(lint_options).unwrap();
|
||||
let semantic = Rc::new(semantic_ret.semantic);
|
||||
b.iter(|| {
|
||||
linter.run(LintContext::new(PathBuf::from("").into_boxed_path(), &semantic))
|
||||
linter.run(LintContext::new(
|
||||
PathBuf::from("").into_boxed_path(),
|
||||
Rc::clone(&semantic),
|
||||
))
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue