vscode-eslint: Autofix lightbulb not shown in TypeScript

The fixes lightbulb with suppress options does not show up in TypeScript files. If I manually change the language mode of a file to JavaScript, it shows up, and then disappears again if I change it back to TypeScript. The error shows as expected and I have the following settings enabled:

    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
    ],

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 17
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Fixes are only automatically shown for JS right now. You can enable for TS using the following setting:

    "eslint.validate": [
        "javascript",
        "javascriptreact",
        { "language": "typescript", "autoFix": true }
        { "language": "typescriptreact", "autoFix": true }
    ],

Keeping the issue open to consider if we should auto enable TS.

@dbaeumer I vote for an automatic validation and auto fix enabling for TypeScript files because of this https://github.com/typescript-eslint/typescript-eslint. I’m currently using it in VS Code and it works perfectly. I even think TSLint after some time will be abandoned… Even TypeScript team will use ESLint for their own repo, you can read it here: https://github.com/Microsoft/TypeScript/issues/29288 and here https://eslint.org/blog/2019/01/future-typescript-eslint

This got improved and fixed for 2.x. The extension now auto detects TypeScript. No config necessary.

But I would be very happy with just this small change, of only requiring “typescript” in the settings instead of { “language”: “typescript”, “autoFix”: true }

This is actually easy and I can add this.

Fixes are only automatically shown for JS right now. You can enable for TS using the following setting:

    "eslint.validate": [
        "javascript",
        "javascriptreact",
        { "language": "typescript", "autoFix": true }
        { "language": "typescriptreact", "autoFix": true }
    ],

Keeping the issue open to consider if we should auto enable TS.

when config in project, it’s not work, but when i config it in user, it is ok

I’m not sure that it is really necessary to make sure the user has their ESlint configured correctly, so long as:

1. `typescript` and `typscriptreact` are not included in `eslint.validate` by default

2. And `eslint.autoFixOnSave` is `false` by default
  1. and 2. are actually the case but the requests ask to make this a better out of the box expierence. So include typescript and typscriptreact in the eslint.validate and even enable autofix. But this makes only sense when the linter is configured to lint TS files.

To me these settings are fine as-is. As I see it, this excellent plugin already has all the functionality it needs, it’s just that this one config setting is confusing. 😃

Specifically, as a user of the plugin, I expected that if I enter this in my settings…

    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact"
    ],

… that it would result in TypeScript and TSX getting the same level of functionality as JavaScript and JSX.

The ability for the plugin to auto-detect the TS configuration etc, would be nice. But I would be very happy with just this small change, of only requiring "typescript" in the settings instead of { "language": "typescript", "autoFix": true }

Could you use CLIEngine.getConfigForFile() to check for the presence of the @typescript-eslint plugin? https://github.com/eslint/eslint/blob/master/docs/developer-guide/nodejs-api.md#clienginegetconfigforfile

@agwells 1. and 2. are actually the case but the requests ask to make this a better out of the box expierence. So include typescript and typscriptreact in the eslint.validate and even enable autofix. But this makes only sense when the linter is configured to lint TS files.