microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.69k stars 323 forks source link

why is the exlint:source-code-fxer shouldFix parameter false #1846

Open dagda1 opened 2 weeks ago

dagda1 commented 2 weeks ago

I am using eslint v8.57.0 and I use eslint-config-prettier with my prettier rules in my eslint config.

I have pasted my eslint settings from my vscode settings at the end of this post.

Formatting on save has suddenly stopped working and I have no idea why.

I did notice this entry in the eslint output of vscode.

eslint:source-code-fixer shouldFix parameter was false, not attempting fixes

I can see this in the eslint source code here.

And it appears to be an option that is somehow passed in as option here.

Can I set this value on the extension so that it starts formatting on save again?

  "eslint.debug": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },
  "eslint.codeActionsOnSave.mode": "all",
  "eslint.timeBudget.onFixes": {
    "warn": 300000,
    "error": 600000
  },
  "eslint.onIgnoredFiles": "warn",
  "editor.formatOnSave": false,
  "eslint.lintTask.enable": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ],
  "[javascript]": {
    "editor.formatOnSave": false,
  },
  "[javascriptreact]": {
    "editor.formatOnSave": false
  },
  "[typescript]": {
    "editor.formatOnSave": false
  },
  "[typescriptreact]": {
    "editor.formatOnSave": false
  },
dagda1 commented 2 weeks ago

rolling back @typescript-eslint/eslint-plugin to 7.7.0 fixed my problem but I am still curious to know how that fix parameter can be set.....if indeed it can be set externally,

dbaeumer commented 2 weeks ago

You can pass options to the linter using eslint.options settings. The option structure is decribed here: https://eslint.org/docs/latest/integrate/nodejs-api#-new-eslintoptions

dbaeumer commented 2 weeks ago

Let me know how it goes.

Derasm commented 1 week ago

@dbaeumer can this option be set in the eslint.config.js file? It seems like VsCode autosets the "source.fixAll.eslint" to "explicit" now, as it doesn't support boolean values anymore.

dbaeumer commented 1 week ago

@Derasm yes that is correct. But the extension / VS Code handles them equally so things should work the same way. Do you see it not working with the explicity value?

dagda1 commented 1 week ago

@dbaeumer I console logged the fix value in the source code of eslint in node_modules here and it was false until I rolled back @typescript-eslint/eslint-plugin to 7.7.0

dbaeumer commented 1 week ago

The options literal passed to the linter is the one from eslint.options. I don't set any fix property on it to ensure the default is taken. So I am a little bit lost why this is false for you.