microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.74k stars 335 forks source link

eslint.autoFixOnSave conflicting with editor.formatOnSave #380

Closed dusty closed 6 years ago

dusty commented 6 years ago

Using vscode 1.19.1, with the most recent eslint plugin, I am having issues with autoFixOnSave not firing.

I've narrowed it down to the following settings.

autoFix does not fire.

{
  "files.autoSave": "off",
  "eslint.autoFixOnSave": true,
  "editor.formatOnSave": true,
  "javascript.format.enable": false
}

autoFix works, but I can't autoFormat any other document types

{
  "files.autoSave": "off",
  "eslint.autoFixOnSave": true,
  "editor.formatOnSave": false,
  "javascript.format.enable": false
}

autoFix works, but now my eslint/prettier configuration conflicts with vscode's javascript formatter. I often have to save several times until the right format lands.

{
  "files.autoSave": "off",
  "eslint.autoFixOnSave": true,
  "editor.formatOnSave": true,
  "javascript.format.enable": true
}

Any ideas? My goal is to bypass VSCode's javascript formatting, but enable formatting on all other document types, and have eslint autoFix to fire.

Thanks

andyczerwonka commented 6 years ago

I can't seem to get autoFixOnSave to work at all - don't really understand what combination of editor and eslint settings will get my editor to autoformat of save according to the eslint rules.

IanSavchenko commented 6 years ago

Seeing the same problem as @dusty. VS Code 1.19.1, plugin 1.4.3.

KJlmfe commented 6 years ago

Same problem +1

I want to execute "editor.formatOnSave": true before executing "eslint.autoFixOnSave": true

dbaeumer commented 6 years ago

You can disable format on save for JavaScript files using the following setting:

        "editor.formatOnSave": true,
    "[javascript]": {
        "editor.formatOnSave": false
    }

The on save only the ESLint autofix will be triggered.

VS Code offers no API to control the order of a save participants (e.g. first formant then auto fix). So I will close the issue since ESLint can't control this. Please file a issue against VS Code if @KJlmfe feels strong about it.