|
1 | 1 | mod linter;
|
2 | 2 |
|
3 |
| -use std::{fmt::Debug, path::PathBuf, str::FromStr}; |
| 3 | +use std::{env, fmt::Debug, path::PathBuf, str::FromStr}; |
4 | 4 |
|
5 | 5 | use dashmap::DashMap;
|
6 | 6 | use futures::future::join_all;
|
7 | 7 | use globset::Glob;
|
8 |
| -use ignore::gitignore::Gitignore; |
| 8 | +use ignore::gitignore::{Gitignore, GitignoreBuilder}; |
9 | 9 | use log::{debug, error, info};
|
10 | 10 | use oxc_linter::{FixKind, LinterBuilder, Oxlintrc};
|
11 | 11 | use serde::{Deserialize, Serialize};
|
@@ -353,16 +353,21 @@ impl Backend {
|
353 | 353 | }
|
354 | 354 | if let Some(config_path) = config_path {
|
355 | 355 | let mut linter = self.server_linter.write().await;
|
| 356 | + let oxlintrc = Oxlintrc::from_file(&config_path) |
| 357 | + .expect("should have initialized linter with new options"); |
| 358 | + let mut gitignore_builder = GitignoreBuilder::new(config_path.parent().unwrap()); |
| 359 | + for path in &oxlintrc.ignores { |
| 360 | + gitignore_builder |
| 361 | + .add_line(None, path) |
| 362 | + .expect("Invalid glob in config \"ignores\" property"); |
| 363 | + } |
| 364 | + self.gitignore_glob.lock().await.push(gitignore_builder.build().unwrap()); |
356 | 365 | *linter = ServerLinter::new_with_linter(
|
357 |
| - LinterBuilder::from_oxlintrc( |
358 |
| - true, |
359 |
| - Oxlintrc::from_file(&config_path) |
360 |
| - .expect("should have initialized linter with new options"), |
361 |
| - ) |
362 |
| - // FIXME: Handle this error more gracefully and report it properly |
363 |
| - .expect("failed to build linter from oxlint config") |
364 |
| - .with_fix(FixKind::SafeFix) |
365 |
| - .build(), |
| 366 | + LinterBuilder::from_oxlintrc(true, oxlintrc) |
| 367 | + // FIXME: Handle this error more gracefully and report it properly |
| 368 | + .expect("failed to build linter from oxlint config") |
| 369 | + .with_fix(FixKind::SafeFix) |
| 370 | + .build(), |
366 | 371 | );
|
367 | 372 | }
|
368 | 373 | }
|
|
0 commit comments