vscode-standard: Format on save not working on .vue files

  • StandardJS version? 1.1.7
  • VSCode version? 1.14
  • StandardJS configuration?
  "editor.formatOnSave": false,
  "javascript.validate.enable": false,
  "standard.validate": [
    "javascript",
    "javascriptreact",
    "html"
  ],
  "standard.options": {
    "globals": [
      "$",
      "jQuery",
      "fetch"
    ],
    "ignore": [
      "node_modules/**"
    ],
    "parser": "babel-eslint",
    "plugins": [
      "html"
    ]
  },
  "files.associations": {
    "*.vue": "html"
  },
  "standard.autoFixOnSave": true,

About this issue

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

Most upvoted comments

I’m using the same setup as @SolT31 but standard.js seems to try and parse the whole .vue file and not just the javascript in the script tag:

<template>
  <button @click="foo"></button>
</template>
<script>
module.exports = {
  methods: {
    async foo() { badMethod("bad quotes");;; }
  }
}
</script>

This example file shows only a single error by standard in line 2: @click - “unexpected character @”.

StandardJS does not even get to the JS-lines to mark errors.

My configuration works here.

standard v12.0.1 Extension v1.2.3

npm i -g standard
npm i -g eslint-plugin-html@4

settings.json

"standard.autoFixOnSave": true,
"standard.validate": [
  "javascript",
  "javascriptreact", 
  {
    "language": "vue",
    "autoFix": true
  }
],
"standard.options": {
  "plugins": ["html"]
}

Similar issue, although even Format Document isn’t formatting to Standard.

I think you need this:

 "standard.validate": [
     "javascript",
     "javascriptreact",
     { "language": "html", "autoFix": true }
 ],