Skip to content

Commit

Permalink
Merge pull request #3938 from gunadhya/docs_update
Browse files Browse the repository at this point in the history
Add codeActionsOnSave to docs
  • Loading branch information
Greg Van Liew authored Aug 14, 2020
2 parents ebd49dc + 9ba3b64 commit 4c4b2a3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/languages/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions docs/languages/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4c4b2a3

Please sign in to comment.