Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/oxlint/src/lsp/isolated_lint_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ impl IsolatedLintHandler {
);
}

// Clear any stale directives because they are no longer needed.
// This prevents using outdated directive spans if the new linting run fails.
self.runner.directives_coordinator().remove(path);

Ok(messages)
}

Expand Down
12 changes: 12 additions & 0 deletions crates/oxc_linter/src/lint_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ impl DirectivesStore {
pub fn clear(&self) {
self.map.lock().expect("DirectivesStore mutex poisoned in clear").clear();
}

/// Remove disable directives for a specific file
///
/// This should be called before re-linting a file to ensure stale directives
/// from previous linting runs are not used if the new linting run fails to
/// produce directives (e.g., due to parse errors).
///
/// # Panics
/// Panics if the mutex is poisoned.
pub fn remove(&self, path: &Path) {
self.map.lock().expect("DirectivesStore mutex poisoned in remove").remove(path);
}
}

impl Default for DirectivesStore {
Expand Down
Loading