Can't get correct autoformat on save in Visual Studio Code with ESLint and Prettier

后端 未结 7 782
囚心锁ツ
囚心锁ツ 2021-01-30 03:16

in Visual Studio Code with ESLint and Prettier when working on .vue files, it seems I can\'t get vue/max-attributes-per-line to auto-fix correctly.

For example, with vue

7条回答
  •  清酒与你
    2021-01-30 03:49

    I've struggled through a similar problem. I tried the solution above but didn't work for me, unfortunately. I'm using eslint and Vetur, didn't install prettier plugin but configured it via eslint and enabled "eslint.autoFixOnSave": true. I finally got the correct autoformat on save by removing the following configuration in settings.json. Not sure why but it's working for me.

      "eslint.options": {
        "extensions": [".html", ".js", ".vue", ".jsx"]
      },
      "eslint.validate": [{
          "language": "html",
          "autoFix": true
        },
        {
          "language": "vue",
          "autoFix": true
        },
        {
          "language": "javascript",
          "autoFix": true
        },
        {
          "language": "javascriptreact",
          "autoFix": true
        }
      ]
    

    Will update this answer if I get other issues related to this.

提交回复
热议问题