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
Extension not auto-fixing on Save #833
Comments
Same happening here.
|
Same happening here.
|
Same thing |
same issue in react project before(worked these days) {
"editor.formatOnSave": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "typescript",
"autoFix": true
},
{
"language": "typescriptreact",
"autoFix": true
}
],
} now(not work) {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
} |
Not working with vue files. "editor.codeActionsOnSaveTimeout": 1200 |
me too. |
Also experiencing this with .vue files. @AliasT solution works, but it is not optimal. |
The correct settings are:
to enable autofix on save. To compute all possible fixes (see the lengthy discussion in #154 why this is complicated in ESLint) I needed to change the way how these fixes are computed resulting in a more complex algorithm. Hence it takes more time and might run out of the given time budget for large files. So you might need to adjust the time budget using the If this doesn't work for all of you can the once still seeing problem provide me with a GitHub repository I can clone that demos this? |
I feel this issue is due to format order: This results in a wrong format if the This is a real issue. I have two kinds of projects: ones with ESLint, others without ESLint. With ESLint:
Without ESLint:
Theses format settings are differents and needs to be. It used to work well, yet, from the new Here is a part of my
|
@pistou I see the issue but this is unfortunately not under my control. I have no influence on the order of the requests sent by VS Code itself. And converting to the code action on save infrastructure was necessary since otherwise there is no control over the time budget causing another set of problems. All I can recommend for now is the following: in the case where you use ESLint to fix on save adding |
Can confirm that it isn't working with Vue files. My relevant settings look as follows:
Solution would be highly appreciated. |
I found the solution for react users. |
@FaridSaleh which formatter are you using? |
Can confirm adding I also created a new vue project with the Vue CLI, selected "ESLint + Prettier" linter / formatter and "Lint on save" options, and auto-fix works without having to change any settings or configuration. But for some reason I had to add Here is my project configuration that is now working:
Thanks for the fast responses! |
@dbaeumer I tried out that "editor.codeActionsOnSaveTimeout" setting and that fixed the issue for me. I bumped it up to 1500 ms (default is 750 ms) and now my files are auto-fixing on save. I also tried the |
@dracozombie19 As you can see, this issue is occurring to many people, so just because you got it fixed, doesn't mean that everyone else had it fixed. Closing this issue was a mistake. |
I guess I'll leave it to @dbaeumer and how he wants to manage this. I was the one who opened the issue and my problem has been resolved. If the resolution that worked for me doesn't work for you, it may be worth opening a new issue since it may have a different root cause. |
In general I am in line with @dracozombie19 opinion that separate issues are better. However if someone can provide me with a GitHub repository I can clone that demos the issue they are seeing here then I am happy to reopen the issue. |
@dbaeumer Thanks for the replies. I think that in general the community is used to formatting happening immediately onSave. I bumped up the timeout to 1500ms and sometimes it still wasn't triggered. When I was formatting with Prettier before these changes the formatting happened instantly from what I can tell. I am pretty sure it will depend on the developer machine as well. So I could give you a project and on your machine it might run fine :) |
I'm using only eslint formatter |
@Alonski the problem with the old fix code was that it didn't fix all fixable problems due to the nature how ESLint computes them. So I change the way which made it more complex and hence more expensive. Positive is that now all fixable problems will be addressed. |
my setting worked fine before, but now visual studio code tips |
@dbaeumer on a 279 line file (is that large?) I had to bump Here is an example of a format that is not fixed: It looks like the formatting takes around 50 - 80 ms.
|
why close the issues??? how to resolve it?? |
@dbaeumer running |
I had a similar issue, but found out that organize import conflicts with the fix-all. It seems that "editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
},
"editor.formatOnSave": false, Will format to the following line: export { Id, Project, ProjectEx, ProjectInput, ProjectMember, ProjectRole, Role, User, UserEx, UserInput } from './schema'; And setting export {
Id,
Project,
ProjectEx,
ProjectInput,
ProjectMember,
ProjectRole,
Role,
User,
UserEx,
UserInput,
} from './schema'; I don't have any timeout set. |
Pls see #859 for the performance discussion. |
This combination worked for me 🎉 : "editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": false, Maybe it'll work for someone else. |
@leonardorb thanks. I added that to the readme today (e.g. to not enable both formatOnSave and code action on save. |
Still not getting auto save even with that combo, here's my config: {
"sync.gist": "",
"sync.autoDownload": true,
"sync.autoUpload": true,
"sync.quietSync": true,
"terminal.external.osxExec": "iTerm.app",
"window.zoomLevel": 0,
"git.enableSmartCommit": true,
"explorer.confirmDelete": false,
"workbench.iconTheme": "vscode-icons",
"editor.fontSize": 14,
"vsicons.dontShowNewVersionMessage": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"explorer.confirmDragAndDrop": false,
"aws.profile": "",
"sync.forceUpload": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.renderControlCharacters": false,
"phpcs.standard": "psr2",
"javascript.updateImportsOnFileMove.enabled": "always",
"workbench.colorTheme": "One Dark Pro",
"prettier.singleQuote": true,
"prettier.tabWidth": 4,
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"sql-formatter.linesBetweenQueries": 1,
"sql-formatter.uppercase": true,
"extensions.ignoreRecommendations": false,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.printWidth": 160,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.trace.server": "messages",
"editor.formatOnSave": false,
"debug.inlineValues": true,
"debug.openExplorerOnEnd": true,
"debug.toolBarLocation": "docked"
} Output on save:
Output on fix (which works):
|
@claylevering looking at your trace you need to increase the timeout using the setting |
The timeout is by default 750ms but it took 973ms to comupte the fixes. |
did someone find the proper fix for this issue? :-( |
This is crippling prettier and autoformat for us across all projects. I tried various solutions as proposed here but without success. It either:
|
This is my current configuration and i think it's working well. hope it helps. {
//"editor.formatOnSave": true, //set as false and allow scoping of setting per-language basis
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
//"prettier.eslintIntegration": true,
"css.lint.unknownProperties": "ignore", //ignore composes error unknown property for css composition
"[javascript]": {
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.formatOnSave": true
}
} |
Fixed it via this config (had another problem where the settings API change also caused files with CSS-in-JS to not autofix):
Problem is, like people said, that it's a terrible dev experience compared to what we had (almost instant autofix in some cases). Now I have to wait 1.5 seconds regardless of the file. |
same here. I have to add |
Some updates:
Both will be in the next version 2.0.12. |
I'm still having this issue - eslint not auto fixing problems - on 2.0.13. I've tried the above solutions which worked for others. Here are my pertinent editor and eslint settings:
|
@rtmalone can you provide me with a GitHub repository I can clone that demos what you are seeing. |
Please, I need support on this too. |
@dbaeumer further investigating seems like my issue is limited to a specific workspace. So probably not the extension's problem. |
Same problem with version 2.0.13 |
it works for me well ! if you change the vsc settings.json, please restart your vsc. if your eslint cannot work , please click eslint at vsc status bar to find the reason. |
@dbaeumer Do you know if setting I noticed 1-2 second pauses before prettier finished formatting (in a company repository; sorry :( ), and the performance of eslint didn't seem to be the cause:
(Prettier also wasn't an issue; it ran in <50ms.) However, it did look like VS Code took some time to actually send requests to ESLint's LSP server, which I found curious. I say "look like" because the timestamp advanced by a second, but I can't confirm if that's because it took a second to send or because the request was sent at 900 ms past the second. If the timestamps had a finer granularity, I'd be more certain. :) I discovered that Flow also responds to code actions in that same file for those same edits, and was quite slow:
Whenever saving felt slow, I noticed that VS Code canceled some code actions sent to Flow's language server:
I found that I could fix the performance issue by either:
That is, with Flow enabled and ESLint fixups disabled, Prettier auto-formats on save with acceptable performance. Flow is still slow at sending code action requests, but they don't seem to be blocking saving. Now, this is all informed speculation based on logs, and I don't think I can confirm further unless I understand how VS Code code actions work. I think this code is responsible for determining what code actions block saving, but there's a lot going on with few comments. So, to come back to my earlier point: Is it possible that setting |
@jvilk-stripe actually there is a bug in VS Code that request to many code actions and drops them later on if not needed (see microsoft/vscode#84602) which should be fixed with the next insider build. You could try to set |
and great analysis! |
I just tried the latest insiders build:
Unfortunately, the problem still exists. It takes ~1-2 seconds commonly for the document to finish saving/formatting with ESLint + Prettier. Disabling (Explicitly setting |
@jvilk-stripe thanks for getting back. Can you please open a new issue in the VS Code repository since this from your great analysis is not related to the eslint extension. Looks more like a problem in VS Code itself and needs to be addressed there. I thought it will be addressed by microsoft/vscode#84602 |
Done: |
I got the upgrade to 2.0.4 (and subsequently to 2.0.5 a little bit ago) and I'm having trouble configuring ESLint to auto-fix issues on Save. Previously we had the "eslint.autoFixOnSave" setting, but it looks like this was replaced by the "editor.codeActionsOnSave" setting. I'm trying this configuration, but nothing is happening on Save:
I've tried different combinations of "editor.formatOnSave" and "editor.codeActionsOnSave," but none of them seem to work for me.
The text was updated successfully, but these errors were encountered: