-
Notifications
You must be signed in to change notification settings - Fork 336
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
Better handle eslint-disable comments when "eslint.codeActionsOnSave.rules" are used. #1938
Comments
@pfoedermayr could you please provide me with a GitHub repository I can clone. That ensure we are using the identical setup when I try to reproduce this. |
Hope this helps, let me know if I should change something or if you need anything else |
Thanks for the repository. What is strange is that if you remove
everything works as expected. |
This is a setup issue that is hard to fix (e.g. I don't have an idea how). The problem is as follows:
tells ESLint to only fix the "quotes" rule. When computing the fixes the console.log is not detected as a problem hence the disable directive is unnecessary and is fixed by removing it. The unnecessary directive detection can't be customized per rule. I could disable it in your case but then all unnecessary directives would stay. All I can recommend is to turn the |
Can you explain why you customize the eslint.codeActionsOnSave.rules in that way? |
It's basically a list of rules that we came up with over time.
Will definitely have a look at that, but in my head I would still have the same problem when an error is detected for the expensive rules right? |
Thanks for explaining why this is happening, it definitely makes a lot more sense now. As a workaround we set |
Makes sense. As said I have no better solution right now either. |
I have a similar use case at my company. I can't run my full ESLint config on save because it's too expensive. (It includes a number of @typescript-eslint rules that need type information and are therefore quite slow.) I want to use In the CLI I can customize this using https://eslint.org/docs/latest/use/command-line-interface#--fix-type. But I don't see a way to configure this in the VSCode extension. Could we add an extension option that allows us to forward |
The setting is And the |
What I'd love to have is |
|
I can give it a try if you can point me to where to start. |
Great. Here are some pointers: On the client side we need to add a setting Then we need to have the setting in TypeScript here: https://github.com/microsoft/vscode-eslint/blob/main/%24shared/settings.ts#L67 and fill in the value here: https://github.com/microsoft/vscode-eslint/blob/main/client/src/client.ts#L715 On the server side the save rule config is computed here: https://github.com/microsoft/vscode-eslint/blob/main/server/src/eslint.ts#L485 We should add the options to the |
When a file with one or more
eslint-disable
comments is saved while there are other lint errors present the comments are automatically removed.I was able to reproduce it with a fresh project with just eslint and a javascript file.
Only the extension
dbaeumer.vscode-eslint
in version3.0.10
being enabled in VSCode.eslint.config.mjs
.vscode/settings.json
When I save a file that looks like this for example
it results in:
Running just
ESLint: Fix all auto-fixable Problems
does fix the lint error in line 4 and keeps theeslint-disable
comment in line 1.The text was updated successfully, but these errors were encountered: