zed/crates
Thorsten Ball a52177fd39
Allow users to configure ESLint codeActionOnSave settings (#8537)
This fixes #8533 by allowing users to specify the settings that are
passed to ESLint on workspace initialization.

Example Zed `settings.json` to enable `fixAll` for eslint when
saving/formatting, but only for the `import/order` rule:

```json
{
  "languages": {
    "JavaScript": {
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  },
  "lsp": {
    "eslint": {
      "settings": {
        "codeActionOnSave": {
          "rules": ["import/order"]
        }
      }
    },
  }
}
```

The possible settings are described in the README of `vscode-eslint`
here:
https://github.com/Microsoft/vscode-eslint?tab=readme-ov-file#settings-options

- `eslint.codeActionsOnSave.enable` (default: `true`, config key in Zed:
`lsp.eslint.settings.codeActionOnSave.enable`)
- `eslint.codeActionsOnSave.mode` (default: not set by Zed, config key
in Zed: `lsp.eslint.settings.codeActionOnSave.mode`)
- `eslint.codeActionsOnSave.rules` (default: `[]`, config key in Zed:
`lsp.eslint.settings.codeActionOnSave.rules`)

Yes, in the readme it's plural: `codeActionsOnSave`, but since
`eslint-vscode` we're using this old release:


https://github.com/microsoft/vscode-eslint/releases/tag/release%2F2.2.20-Insider

We use the singular version:
https://github.com/microsoft/vscode-eslint/blob/release/2.2.20-Insider/server/src/eslintServer.ts#L461

Our schema looks like this:

```json
{
  "lsp": {
    "eslint": {
      "settings": {
        "codeActionOnSave": {
          "enable": true,
          "rules": ["import/order"],
          "mode": "all"
        }
      }
    },
  }
}
```

We should probably fix this and upgrade to the newest version of ESLint.

Release Notes:

- Added ability for users to configure settings for ESLint's
`codeActionOnSave`, e.g. specifying `rules` that should be respected
when also using `"code_actions_on_format": {"source.fixAll.eslint":
true}`. These settings can be passed to ESLint as part of the `"lsp"`
part of the Zed settings. Example: `{"lsp": {"eslint": {"settings":
{"codeActionOnSave": { "rules": ["import/order"] }}}}}`
([#8533](https://github.com/zed-industries/zed/issues/8533)).

Demo:


https://github.com/zed-industries/zed/assets/1185253/5c0cf900-9acb-4a70-b89d-49b6eeb6f0e4
2024-02-28 17:04:36 +01:00
..
activity_indicator Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
ai Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
assets chore: Move workspace dependencies to workspace.dependencies (#7454) 2024-02-06 20:41:36 +01:00
assistant Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
audio Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
auto_update Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
breadcrumbs Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
call channel projects (#8456) 2024-02-26 22:15:11 -07:00
channel channel projects (#8456) 2024-02-26 22:15:11 -07:00
cli Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
client Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
clock Add SystemClock (#8239) 2024-02-22 22:28:08 -05:00
collab Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
collab_ui channel projects (#8456) 2024-02-26 22:15:11 -07:00
collections gpui: Add Global marker trait (#7095) 2024-01-30 14:08:20 -05:00
color Upgrade palette (#8506) 2024-02-27 14:29:27 -07:00
command_palette Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
command_palette_hooks Add command_palette_hooks crate (#8398) 2024-02-25 13:21:20 -05:00
copilot Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
copilot_ui Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
db Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
diagnostics Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
editor Allow users to configure ESLint codeActionOnSave settings (#8537) 2024-02-28 17:04:36 +01:00
extension Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
extensions_ui Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
feature_flags Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
feedback Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
file_finder Clean up deps for file_finder, language_selector, task, rpc, storybook (#8353) 2024-02-25 10:10:07 +02:00
fs linux: fix invalid cross-device link error (#8437) 2024-02-27 21:49:28 -08:00
fsevent Translate notify::Event to fsevent::Event on linux (#7545) 2024-02-08 08:35:37 -08:00
fuzzy chore: Move workspace dependencies to workspace.dependencies (#7454) 2024-02-06 20:41:36 +01:00
git Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
go_to_line Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
gpui Mention possible run options in the task modal placeholder (#8449) 2024-02-27 00:04:56 +02:00
gpui_macros Switch LSP prompts to use a non-blocking toast (#8312) 2024-02-23 15:18:32 -08:00
install_cli Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
journal Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
language chore: Move Location type to language (#8527) 2024-02-28 12:41:31 +01:00
language_selector Clean up deps for file_finder, language_selector, task, rpc, storybook (#8353) 2024-02-25 10:10:07 +02:00
language_tools Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
languages Allow users to configure ESLint codeActionOnSave settings (#8537) 2024-02-28 17:04:36 +01:00
live_kit_client Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
live_kit_server Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
lsp Clean up dependencies of call,lsp,project,settings,vim,welcome, and workspace (#8330) 2024-02-25 00:41:28 +02:00
markdown_preview Support rendering strikethrough text in markdown (#8287) 2024-02-26 21:04:48 +02:00
media Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
menu chore: Move workspace dependencies to workspace.dependencies (#7454) 2024-02-06 20:41:36 +01:00
multi_buffer Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
node_runtime Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
notifications Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
outline Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
picker Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
prettier Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
project Add ability to run ESLint (and other non-primary language server) code actions on format (#8496) 2024-02-28 13:55:20 +01:00
project_core Allow users to configure ESLint codeActionOnSave settings (#8537) 2024-02-28 17:04:36 +01:00
project_panel Add tests on inventory task sorting 2024-02-28 14:13:40 +02:00
project_symbols Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
quick_action_bar Hide Inline Assist button if assistant.button is disabled (#7932) 2024-02-18 08:14:08 +02:00
recent_projects Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
refineable Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
release_channel chore: Move workspace dependencies to workspace.dependencies (#7454) 2024-02-06 20:41:36 +01:00
rich_text Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
rope Add documentation to many core editor types (#7919) 2024-02-17 09:03:05 -07:00
rpc channel projects (#8456) 2024-02-26 22:15:11 -07:00
search Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
semantic_index Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
settings Clean up dependencies of call,lsp,project,settings,vim,welcome, and workspace (#8330) 2024-02-25 00:41:28 +02:00
snippet Clean up Cargo.toml files (#7044) 2024-01-29 23:47:20 -05:00
sqlez Use collections::{HashMap, HashSet} instead of its std:: counterpart (#7502) 2024-02-07 19:06:03 +02:00
sqlez_macros Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
story chore: Move workspace dependencies to workspace.dependencies (#7454) 2024-02-06 20:41:36 +01:00
storybook Clean up deps for file_finder, language_selector, task, rpc, storybook (#8353) 2024-02-25 10:10:07 +02:00
sum_tree Add documentation to many core editor types (#7919) 2024-02-17 09:03:05 -07:00
task Add tests on inventory task sorting 2024-02-28 14:13:40 +02:00
tasks_ui Sort tasks modal entries by last used time 2024-02-28 14:13:40 +02:00
telemetry_events Add telemetry events backend for collab (#8220) 2024-02-23 11:13:28 -05:00
terminal Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
terminal_view Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
text Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
theme Upgrade palette (#8506) 2024-02-27 14:29:27 -07:00
theme_importer Upgrade palette (#8506) 2024-02-27 14:29:27 -07:00
theme_selector Clean up many small dependencies (part 3) (#8425) 2024-02-26 11:08:57 +02:00
time_format Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
ui Cleanup dependencies (part 4) (#8468) 2024-02-27 20:41:49 +02:00
util Add tests on inventory task sorting 2024-02-28 14:13:40 +02:00
vcs_menu Allow using context in the placeholder_text method 2024-02-25 00:08:57 +02:00
vim fix vim repeat (#8513) 2024-02-27 21:36:12 -07:00
welcome Clean up dependencies of call,lsp,project,settings,vim,welcome, and workspace (#8330) 2024-02-25 00:41:28 +02:00
workspace Add :tabonly and :only vim commands (#8337) 2024-02-26 22:15:50 -07:00
zed linux: fix invalid cross-device link error (#8437) 2024-02-27 21:49:28 -08:00
zed_actions chore: Move workspace dependencies to workspace.dependencies (#7454) 2024-02-06 20:41:36 +01:00