Skip to content

Commit

Permalink
fix(linter): panic in disable-directives (#6677)
Browse files Browse the repository at this point in the history
closes #6670
  • Loading branch information
shulaoda authored Oct 19, 2024
1 parent 002289b commit ce25c45
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/oxc_linter/src/disable_directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ impl<'a> DisableDirectivesBuilder<'a> {
// `eslint-disable-line`
else if let Some(text) = text.strip_prefix("-line") {
// Get the span between the preceding newline to this comment
let start = source_text[..=comment.span.start as usize]
let start = source_text[..comment.span.start as usize]
.lines()
.next_back()
.map_or(0, |line| comment.span.start - (line.len() as u32 - 1));
.map_or(0, |line| comment.span.start - line.len() as u32);
let stop = comment.span.start;

// `eslint-disable-line`
Expand Down Expand Up @@ -430,7 +430,8 @@ fn test() {
format!("
/* {prefix}-disable , ,no-debugger, , */
debugger;
")
"),
format!("debugger;//…{prefix}-disable-line")
];

let fail = vec![
Expand Down

0 comments on commit ce25c45

Please sign in to comment.