Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codeActionsOnSave to docs #3938

Merged
merged 3 commits into from
Aug 14, 2020
Merged

Conversation

gunadhya
Copy link
Contributor

@ghost
Copy link

ghost commented Aug 12, 2020

CLA assistant check
All CLA requirements met.

@gunadhya gunadhya changed the title Add codeActionOnSave to docs Add codeActionsOnSave to docs Aug 12, 2020
@@ -213,6 +213,58 @@ 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content looks good but let's try to tighten it up. These documents quick overviews of features available for js/ts so we try to keep each section fairly small.

I’d say keep the first example and the list of available code actions. You can link to documentation on language specific settings and other more advanced features

"source.fixAll"
]
```
Note: `editor.codeActionsOnSave` supports both object and array configs in settings.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the documentation explaining the difference between array vs. object was important to understand... So the part above where you say that the array is used to execute in a specific order is the most important part. It seems that the explanation is redundant below (maybe‽)


The TSLint extension already uses `source.fixAll` Code Action kind to implement fix all and auto fix on save.

You can also set `editor.codeActionsOnSave` to an array of Code Actions to execute in order. You can use this to guarantee that a specific Code Action is always run before or after another one that may conflict with it.
Copy link

@Luxcium Luxcium Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove some parts, please make sure, if possible, to keep this one where you explain the reason why one would prefer to choose the array vs. the object syntax (to execute in order) I think this is important to understand...

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.

The TSLint extension already uses `source.fixAll` Code Action kind to implement fix all and auto fix on save.

You can also set `editor.codeActionsOnSave` to an array of Code Actions to execute in order. You can use this to guarantee that a specific Code Action is always run before or after another one that may conflict with it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you guys think it is possible to retain the part where you explain the reason why one should prefer using an array over an object ?? 

You can also set editor.codeActionsOnSave to an array of Code Actions to execute in order. You can use this to guarantee that a specific Code Action is always run before or after another one that may conflict with it.
The following editor.codeActionsOnSave will always run Organize Imports followed by Fix All once organize imports finishes:

"editor.codeActionsOnSave": [	
    "source.organizeImports",	
    "source.fixAll"	
]	


You can also set `editor.codeActionsOnSave` to an array of Code Actions to execute in order. You can use this to guarantee that a specific Code Action is always run before or after another one that may conflict with it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep this part (with or without the example‽) :

You can also set editor.codeActionsOnSave to an array of Code Actions to execute in order. You can use this to guarantee that a specific Code Action is always run before or after another one that may conflict with it.

@gunadhya
Copy link
Contributor Author

Hey, I added array part back. Can you please confirm if it looks good ?

]
```
Note: `editor.codeActionsOnSave` supports both object and array configs in settings.
See [TypeScript](/docs/typescript/typescript-tutorial) for more information.
Copy link

@Luxcium Luxcium Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you prefer to link to a subsection instead but I found the subsection links just in case:

https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings

For organizeImports specifically in TypeScript:
https://code.visualstudio.com/docs/languages/typescript#_organize-imports

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.

The TSLint extension already uses `source.fixAll` Code Action kind to implement fix all and auto fix on save.
See [Node.js/JavaScript](/docs/nodejs/working-with-javascript) for more information.
Copy link

@Luxcium Luxcium Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you prefer to link to a subsection instead but I found the subsection links just in case:

https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings

For organizeImports specifically in Node.js/JavaScript:
https://code.visualstudio.com/docs/languages/javascript#_organize-imports

Copy link

@Luxcium Luxcium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me I don't know what the man with the big lorgnette (@mjbvz) will think...

@gregvanl gregvanl merged commit 4c4b2a3 into microsoft:master Aug 14, 2020
@gregvanl
Copy link

@gunadhya Thanks for making the updates and thanks to @Luxcium for helping with the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I can't find the documentation about the codeActionsOnSave feature
4 participants