diff --git a/docs/languages/javascript.md b/docs/languages/javascript.md index 841f4fd47b..9fda15f40d 100644 --- a/docs/languages/javascript.md +++ b/docs/languages/javascript.md @@ -213,6 +213,27 @@ Organize imports can also be automatically when you save a JavaScript file by se "source.organizeImports": true } ``` +## Code Actions on Save + +The `editor.codeActionsOnSave` setting lets you configure a set of Code Actions that are run when a file is saved. For example, you can enable organize imports on save by setting: +```json +// On save, run both fixAll and organizeImports source actions +"editor.codeActionsOnSave": { + "source.fixAll": true, + "source.organizeImports": true, +} +``` +You can also set `editor.codeActionsOnSave` to an array of Code Actions to execute in order. + +Here are some source actions: + +* `"organizeImports"` - Enables organize imports on save. +* `"fixAll"` - Auto Fix on Save computes all possible fixes in one round (for all providers including ESLint). +* `"fixAll.eslint"` - Auto Fix only for ESLint. +* `"addMissingImports"` - Adds all missing imports on save. + +See [Node.js/JavaScript](/docs/nodejs/working-with-javascript) for more information. + ## Code suggestions diff --git a/docs/languages/typescript.md b/docs/languages/typescript.md index 6ce437961b..6d03234ef6 100644 --- a/docs/languages/typescript.md +++ b/docs/languages/typescript.md @@ -245,6 +245,27 @@ Organize imports can also be automatically when you save a TypeScript file by se "source.organizeImports": true } ``` +## Code Actions on Save + +The `editor.codeActionsOnSave` setting lets you configure a set of Code Actions that are run when a file is saved. For example, you can enable organize imports on save by setting: +```json +// On save, run both fixAll and organizeImports source actions +"editor.codeActionsOnSave": { + "source.fixAll": true, + "source.organizeImports": true, +} +``` +You can also set `editor.codeActionsOnSave` to an array of Code Actions to execute in order. + +Here are some source actions: + +* `"organizeImports"` - Enables organize imports on save. +* `"fixAll"` - Auto Fix on Save computes all possible fixes in one round (for all providers including ESLint). +* `"fixAll.eslint"` - Auto Fix only for ESLint. +* `"addMissingImports"` - Adds all missing imports on save. + +See [TypeScript](/docs/typescript/typescript-tutorial) for more information. + ## Code suggestions