Skip to content

Commit

Permalink
fix(linter): fix panic with strip_prefix (#1013)
Browse files Browse the repository at this point in the history
fixes #1011
  • Loading branch information
Boshen authored Oct 20, 2023
1 parent 46a5c42 commit c95f2e0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/oxc_linter/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dashmap::DashMap;
use std::{
collections::HashMap,
fs,
Expand All @@ -7,16 +6,18 @@ use std::{
sync::{Arc, Condvar, Mutex},
};

use dashmap::DashMap;
use rayon::{iter::ParallelBridge, prelude::ParallelIterator};
use rustc_hash::FxHashSet;

use oxc_allocator::Allocator;
use oxc_diagnostics::{DiagnosticSender, DiagnosticService};
use oxc_parser::Parser;
use oxc_resolver::{ResolveOptions, Resolver};
use oxc_semantic::{ModuleRecord, SemanticBuilder};
use oxc_span::{SourceType, VALID_EXTENSIONS};
use rustc_hash::FxHashSet;

use crate::{Fixer, LintContext, LintOptions, Linter, Message};
use rayon::{iter::ParallelBridge, prelude::ParallelIterator};

#[derive(Clone)]
pub struct LintService {
Expand Down Expand Up @@ -153,7 +154,7 @@ impl Runtime {

if !messages.is_empty() {
let errors = messages.into_iter().map(|m| m.error).collect();
let path = path.strip_prefix(&self.cwd).unwrap();
let path = path.strip_prefix(&self.cwd).unwrap_or(path);
let diagnostics = DiagnosticService::wrap_diagnostics(path, &source_text, errors);
tx_error.send(Some(diagnostics)).unwrap();
}
Expand Down

0 comments on commit c95f2e0

Please sign in to comment.