-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Merge/remove "editor.formatOnSave" and "editor.codeActionsOnSave->"source.fixAll"" #87096
Comments
@jrieken FYI |
@dbaeumer This issue actually stemmed from your execellent update to the ESLint extension and the new settings one needed to set 🥇 (Just to be clear, your update was great!). |
I'd say 'as designed' - we differentiate between formatting and (source) code actions and while we are aware of the lines being blurry I'd say it still makes sense. Formatting is usually around inserting and removing whitespace while a source action is also about removing unnecessary imports, unused variables etc etc. |
@jrieken I agree but had to accept the different point of view ESLint for example has on this. |
Sure, but they are the outliner - I don't think their point of view is enough to change this for various languages that to make this difference - like TS, Java, etc |
It gets a bit confusing also with this definition by Prettier, which is widly used in addition to ESLint: https://prettier.io/docs/en/comparison.html. If you find a distinction between formatting and (source) code actions, could this at the minimum be explained in the VS Code settings docs? As is now, it is not even explained there, even though one of the biggest linters for VS Code, ESLint, uses the code actions part. |
I agree with @jrieken that the distinction between format and code actions makes sense. Also see #48547 for running organize imports as part of format @thernstig What would you expect the docs to say? |
I would expect As ESLint does formatting, from @jrieken's explanation it sounds like ESLint should not have its config under I am just confused since other formatters seems to rely on (I believe I am starting to repeat myself, and you are aware that the lines are blurry - but at least some other chap in the future can look at this thread for reference) |
We have a long-standing bug on the Prettier extension where the codeActionsOnSave and format on save causes some conflicts and undesirable flickers. It would be nice if there was some way to control this pipeline so that the file only appears to be modified once on save to avoid flickering. prettier/prettier-vscode#716 |
The problem with ESLint here is that it is not only touching white space it fixes a lot of non white space things as well (e.g. wrong quites, missing brackets, ...). This is why I think it should be treated as code actions on save. As @ntotten points out the problem is that users can enable both and the ESLint extension has no way to indicate that it does the formatter job during the code action on save hook as well. If I could when registering telling VS Code that it could skip the format call on save hence avoid the extra unnecessary work. I could in ESLint remember some document version for the last code action on save call and then skip the format call if the document version is sitll the same. However this requires that VS Code specs the call sequence. Otherwise I might make things worse. |
And from a user perspective who do not know the internals, from my side And then why isn't "editor.codeActionsOnSave": {
"source.format": true
}, |
I agree the boundary is fuzzy in cases where formatting problems (such as whitespace) are reported as errors. However in my option, there is still a important conceptual distinction:
I feel extensions themselves are probably in the best position to judge how to deal with this distinction. @dbaeumer Does eslint make this distinction today? Also, #67147 discussed unifying our on save functionality but has not seen much interest |
ESLint supports fix types however it is up to the user to specify them. I in the extension ask eslint to compute fixes on save and take the once the eslint npm module computes. I don't change them in any way. |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
Hello, I'd like some more guidance about the proper way to reconcile these different redundant settings. I have both What is the right way to
Does having:
then still work with both |
Oh no :( |
There are two references for this issue:
"editor.codeActionsOnSave": {},
has the option that it can be set like this:Then this exist:
I am not sure if this is a bug or not, but it is highly confusing what they both do, as their is no indication on the settings page what the first one does. Especially in comparison to the second one.
The text was updated successfully, but these errors were encountered: