From 9afd78b35e01b3959ad1c57af9a0974e7ef35afa Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Mon, 11 Mar 2024 10:30:25 +0100 Subject: [PATCH] Add ESLint information to JavaScript docs (#9158) Release Notes: - N/A --- docs/src/languages/javascript.md | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/docs/src/languages/javascript.md b/docs/src/languages/javascript.md index 26f9a5ebac..a5d8fa0971 100644 --- a/docs/src/languages/javascript.md +++ b/docs/src/languages/javascript.md @@ -23,3 +23,65 @@ For example, if you have Prettier installed and on your `PATH`, you can use it t } } ``` + +### ESLint + +You can configure Zed to format code using `eslint --fix` by running the ESLint +code action when formatting (requires Zed `0.125.0`): + +```json +{ + "languages": { + "JavaScript": { + "code_actions_on_format": { + "source.fixAll.eslint": true + } + } + } +} +``` + +You can also only execute a single ESLint rule when using `fixAll`: + +```json +{ + "languages": { + "JavaScript": { + "code_actions_on_format": { + "source.fixAll.eslint": true + } + } + }, + "lsp": { + "eslint": { + "settings": { + "codeActionOnSave": { + "rules": ["import/order"] + } + } + } + } +} +``` + +**Note:** the other formatter you have configured will still run, after ESLint. +So if your language server or prettier configuration don't format according to +ESLint's rules, then they will overwrite what ESLint fixed and you end up with +errors. + +#### Configure ESLint's `nodePath`: + +You can configure ESLint's `nodePath` setting (requires Zed `0.127.0`): + +```json + +{ + "lsp": { + "eslint": { + "settings": { + "nodePath": ".yarn/sdks" + } + } + } +} +```