Allow users to configure ESLint's rulesCustomizations
settings (#11135)
https://github.com/zed-industries/zed/assets/2072378/18f0bb28-0546-4234-a11f-39af6c9fcc12 `rulesCustomizations` is an array of rule severity overrides. Globs can be used to apply default severities for multiple rules. See [docs](553e632fb4/README.md (L312-L333)
) & [type definitions](553e632fb4/%24shared/settings.ts (L168)
) Example Zed `settings.json` to override all eslint errors to warnings: ```jsonc { "lsp": { "eslint": { "settings": { "rulesCustomizations": [ // set all eslint errors/warnings to show as warnings { "rule": "*", "severity": "warn" } ] } } } } ``` Release Notes: - Added support for configuring ESLint's `rulesCustomizations` settings, ie. `{"lsp": {"eslint": {"settings": {"rulesCustomizations": [{"rule": "*", "severity": "warn"}]}}}}`
This commit is contained in:
parent
f72cf2afe3
commit
ca187c8386
2 changed files with 25 additions and 1 deletions
|
@ -286,6 +286,11 @@ impl LspAdapter for EsLintLspAdapter {
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(|| json!({}));
|
.unwrap_or_else(|| json!({}));
|
||||||
|
|
||||||
|
let rules_customizations = eslint_user_settings
|
||||||
|
.get("rulesCustomizations")
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_else(|| json!([]));
|
||||||
|
|
||||||
let node_path = eslint_user_settings.get("nodePath").unwrap_or(&Value::Null);
|
let node_path = eslint_user_settings.get("nodePath").unwrap_or(&Value::Null);
|
||||||
let use_flat_config = Self::FLAT_CONFIG_FILE_NAMES
|
let use_flat_config = Self::FLAT_CONFIG_FILE_NAMES
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -294,7 +299,7 @@ impl LspAdapter for EsLintLspAdapter {
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"": {
|
"": {
|
||||||
"validate": "on",
|
"validate": "on",
|
||||||
"rulesCustomizations": [],
|
"rulesCustomizations": rules_customizations,
|
||||||
"run": "onType",
|
"run": "onType",
|
||||||
"nodePath": node_path,
|
"nodePath": node_path,
|
||||||
"workingDirectory": {"mode": "auto"},
|
"workingDirectory": {"mode": "auto"},
|
||||||
|
|
|
@ -121,3 +121,22 @@ For example, here's how to set `problems.shortenToSingleLine`:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Configure ESLint's `rulesCustomizations`:
|
||||||
|
|
||||||
|
You can configure ESLint's `rulesCustomizations` setting:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"lsp": {
|
||||||
|
"eslint": {
|
||||||
|
"settings": {
|
||||||
|
"rulesCustomizations": [
|
||||||
|
// set all eslint errors/warnings to show as warnings
|
||||||
|
{ "rule": "*", "severity": "warn" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue