Skip to content

Auto Fix on Save does not fix unused disable directives unless there are other lint problems #1585

Closed
@shawnmcknight

Description

@shawnmcknight

In my eslint config, I've got the following activated:

reportUnusedDisableDirectives: true,

This causes eslint to emit a warning for unused disable directives and it properly shows as a warning in vscode:
image

In my vscode settings I've got code actions on save enabled:

"editor.codeActionsOnSave": {
  "source.fixAll": true
},

However, upon save, this warning is not autofixed. Additionally, there is no "quick fix" shown in vscode as there would be for other fixable errors.

This warning is autofixable at command line by eslint using the --fix flag.

I have found that if there are other errors in the file then upon save both the other error as well as the unused directive will be autofixed. Additionally, if I choose the quick fix "Fix all auto-fixable problems" for the other error, it will automatically fix the unused directive. It appears that automatic fixing will only not occur if this is the only problem in the file.

It's possible I'm missing a configuration somewhere that would allow this to be fixed and if that is the case would appreciate guidance on how to configure it. If that is not the case then please consider a feature request to the extension to treat this as a fixable error.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions