mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
parent
b268cb2545
commit
d5b378a891
2 changed files with 19 additions and 9 deletions
|
|
@ -47,11 +47,12 @@ enum Run {
|
||||||
struct Options {
|
struct Options {
|
||||||
run: Run,
|
run: Run,
|
||||||
enable: bool,
|
enable: bool,
|
||||||
|
config_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Options {
|
impl Default for Options {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { enable: true, run: Run::default() }
|
Self { enable: true, run: Run::default(), config_path: ".eslintrc".into() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,6 +67,13 @@ impl Options {
|
||||||
SyntheticRunLevel::Disable
|
SyntheticRunLevel::Disable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn get_config_path(&self) -> Option<PathBuf> {
|
||||||
|
if self.config_path.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(PathBuf::from(&self.config_path))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
|
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
|
||||||
|
|
@ -329,13 +337,9 @@ impl Backend {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let mut config_path = None;
|
let mut config_path = None;
|
||||||
let rc_config = root_path.join(".eslintrc");
|
let config = root_path.join(self.options.lock().await.get_config_path().unwrap());
|
||||||
if rc_config.exists() {
|
if config.exists() {
|
||||||
config_path = Some(rc_config);
|
config_path = Some(config);
|
||||||
}
|
|
||||||
let rc_json_config = root_path.join(".eslintrc.json");
|
|
||||||
if rc_json_config.exists() {
|
|
||||||
config_path = Some(rc_json_config);
|
|
||||||
}
|
}
|
||||||
if let Some(config_path) = config_path {
|
if let Some(config_path) = config_path {
|
||||||
let mut linter = self.server_linter.write().await;
|
let mut linter = self.server_linter.write().await;
|
||||||
|
|
@ -343,7 +347,7 @@ impl Backend {
|
||||||
Linter::from_options(
|
Linter::from_options(
|
||||||
LintOptions::default().with_fix(true).with_config_path(Some(config_path)),
|
LintOptions::default().with_fix(true).with_config_path(Some(config_path)),
|
||||||
)
|
)
|
||||||
.expect("should initialized linter with new options"),
|
.expect("should have initialized linter with new options"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,12 @@
|
||||||
],
|
],
|
||||||
"default": "off",
|
"default": "off",
|
||||||
"description": "Traces the communication between VS Code and the language server."
|
"description": "Traces the communication between VS Code and the language server."
|
||||||
|
},
|
||||||
|
"oxc_language_server.configPath": {
|
||||||
|
"type": "string",
|
||||||
|
"scope": "window",
|
||||||
|
"default": ".eslintrc",
|
||||||
|
"description": "Path to ESlint configuration."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue