Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoFixOnSave not working! #83

Closed
huanghanyue opened this issue Mar 25, 2019 · 25 comments
Closed

autoFixOnSave not working! #83

huanghanyue opened this issue Mar 25, 2019 · 25 comments
Labels

Comments

@huanghanyue
Copy link

  • StandardJS version? 12.0.1

  • VSCode version? 1.32.1

  • StandardJS configuration?
    image

  • What do you have in the OUTPUT panel?
    image

@nitinja
Copy link

nitinja commented Mar 28, 2019

I experienced the same thing - autofix on save not working.

@ryanpcmcquen
Copy link

This one actually works: https://github.com/numso/prettier-standard-vscode

@jsumners
Copy link

@feross does the core team still maintain this plugin? It doesn't look like it has been touched in months and this issue has not received any acknowledgement.

@feross
Copy link
Member

feross commented Apr 21, 2019

Hi everyone, I'm not a user of Visual Studio Code so I don't know where to start to fix this, but if one of you wants to dig in and send a pull request, I'll be happy to merge it. (I'm not currently checking GitHub notifications regularly because I'm in graduate school so please email me if I don't see the PR)

@mesqueeb
Copy link

+1 for autofix on save not working on VSCode...

@liub1934
Copy link

升级版本后不管用了,目前版本vs版本:1.35

@feross
Copy link
Member

feross commented Aug 13, 2019

This issue is still open if someone wants to tackle it ;)

@feross feross added the bug label Aug 13, 2019
@jsumners
Copy link

I suspect no one commenting on this issue knows the code well enough to work on it. Personally, I don't have the time and I don't write TypeScript.

@ryanpcmcquen
Copy link

I have since switched to Sublime, the packages seem to be of a higher quality overall for Sublime and the editor is way snappier as well.

@mesqueeb
Copy link

mesqueeb commented Aug 14, 2019

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?

@wouterds
Copy link

wouterds commented Sep 9, 2019

Doesn't seem to do anything at all for me. No warnings, errors or auto fixing.

@mesqueeb
Copy link

@wouterds did you install the plugins? You'll need the eslint VSCode plugin and have the correct ESLint setup in your .eslintrc in the root folder of your project.

@DeckardCainCN
Copy link

DeckardCainCN commented Sep 21, 2019

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

@jsumners
Copy link

jsumners commented Dec 26, 2019

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
        }
      }

@jsumners
Copy link

Further follow-up:

It seems all that is required for step 3 is npm install --save-dev standard. This will cause the configuration in steps 4 and 5 to work correctly in conjunction with one another.

@matt6frey
Copy link

matt6frey commented Jan 13, 2020

I am not sure if anybody has tried this in 2020 yet, but I recently installed VSCode and started a Vue project, using eslint & prettier.

I have the eslint extension for vscode, eslint install globally (npm i eslint -g), and an eslintrc.js file too. My system is Windows 10.

I used:

  • CTRL + SHIFT + P, typed settings (select .json ext)
  • added { "editor.tabSize": 2, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } }

I didn't need to close & re-open. Hopefully that helps out. My VS code version is pretty new also. Eslint > format is off.

@JSoon
Copy link

JSoon commented Mar 19, 2020

For me, I have solved it exactly by the following configs:

"eslint.validate": [
    {
        "language": "vue", // Whatever language you are using
        "autoFix": true // This is vital, because the autofixing won't work without this even if you have the right settings below
    }
],
// https://github.com/microsoft/vscode-eslint/issues/600#issuecomment-469211948
"eslint.autoFixOnSave": true,
"files.autoSave": "off", // no fix on save with auto save on :-)

@keemor
Copy link

keemor commented May 8, 2020

Looks like right now adding only this:

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

solves the issue

@feross
Copy link
Member

feross commented Nov 19, 2020

autoFixOnSave works fine for me in the latest version of this plugin. Just make sure that standard is installed as a local dependency with npm install standard --save-dev in your project.

@feross feross closed this as completed Nov 19, 2020
@nioposiquit
Copy link

autoFixOnSave works fine for me in the latest version of this plugin. Just make sure that standard is installed as a local dependency with npm install standard --save-dev in your project.

this works for me installing the standard locally but not when I installed it globally even I defined standard.enableGlobally to true

@ocroz
Copy link

ocroz commented Feb 2, 2022

Same here. I can use standard --fix however I install standard locally or globally. But autoFixOnSave works only when standard is installed locally. Could this issue be reopened to make this work when standard is installed globally too?
Or fix the related issue: #373.

@ShawnTalbert
Copy link

I haven't had any luck getting this plugin to do anything tangible on typescript code. This is running the latest version of the plugin and vscode as of this comment.

@edgeorgie
Copy link

Pretty late but just in case...

I got the same issue, this was my solution:

In your settings.json of VSCode:

  • Make sure that in your [javascript]: {...} config DO NOT have some prettier stuff because you would need to do some extra config with prettier files, etc...

Put this:

[javascript]": { "editor.defaultFormatter": "standard.vscode-standard" },

  • Make sure to add or extends standard into your package.json, something like this (remember to install the ESLint extension first and as a bonus, the Stantard's too):
...
  "eslintConfig": {
    "extends": "standard"
  }
...

PLUS: This could be unnecessary but its pretty helpful: npm install -g standard/semistandard just in case you love Standard to use it in every project 💖.

@SteveImmanuel
Copy link

SteveImmanuel commented Mar 20, 2023

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.

@aaronmeder
Copy link

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,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests