vscode-standard: autoFixOnSave not working!

  • StandardJS version? 12.0.1

  • VSCode version? 1.32.1

  • StandardJS configuration? image

  • What do you have in the OUTPUT panel? image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 25 (3 by maintainers)

Most upvoted comments

Hi. If you use VSCode, you should check the following steps:

  1. Install the StandardJS in VSCode Extensions Market.

  2. Install standard: npm install -g standard/semistandard

  3. Configure your VSCode settings like that:

    { “editor.formatOnSave”: true, “javascript.validate.enable”: false, “standard.autoFixOnSave”: true }

  4. Restart your VSCode

Make sure in your settings.json, you DO NOT auto-run onSave and auto-fix onSave like this:

"standard.autoFixOnSave": true,
"standard.run": "onSave",

instead, simply use:

"standard.autoFixOnSave": true,
"standard.run": "onType",

Having them both enabled on save will conflict with one another, preventing the auto-fix to work after you save the file. So, just set the auto-fix true and set the auto-run onType.

Make sure in your settings.json, you DO NOT auto-run onSave and auto-fix onSave like this:

That was it for me, thank you! Auto fixing works for me with only this in my workspaces .vscode/settings.json:

{
  "standard.enable": true,
  "standard.autoFixOnSave": true,
}

Looks like right now adding only this:

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

solves the issue

Building on @mesqueeb’s suggestion, this is what I did to get this working:

  1. Uninstall this plugin
  2. Install the eslint plugin – https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
  3. In my project: npm install --save-dev eslint eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node (ugh, just “standard” was so much nicer)
  4. Add { "extends": "standard" } in a .eslintrc to my project
  5. In my vscode settings.json:
    "[javascript]": {
        "editor.defaultFormatter": "dbaeumer.vscode-eslint",
        "editor.codeActionsOnSave": {
          "source.fixAll.eslint": true
        }
      }
    

The only thing that worked for me was using regular ESLint, and just use the standard config for that. Then I had to set my VSCode settings to this:

  "javascript.validate.enable": false,
  "typescript.format.enable": false,
  "vetur.validation.style": false,
  "vetur.validation.template": false,
  "editor.insertSpaces": true,
  "editor.tabSize": 2,
  "editor.formatOnSave": false,
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    {
      "language": "vue",
      "autoFix": true
    },
  ],

that was the only setup that worked for me which actually auto fixes my formatting on save! good luck!! 😉

I believe if this package ever works, it might make the setup easier & usable without requiring an eslint setup?