question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vetur Prettier ignores ESLint rules with prettier.eslintIntegration set to true

See original GitHub issue
  • [x ] I have searched through existing issues
  • [ x] I have read through docs
  • [ x] I have read FAQ

Info

  • Platform: macOS
  • Vetur version: 0.11.7
  • VS Code version: 1.20.1

Problem

Vetur’s version of prettier does not respect my ESLint rules even though I have prettier.eslintIntegration set to true.

Cannot get .vue files to format according to eslintrc.js. .js files format without issue. This causes a problem when using vue-cli and the Standard ESLint rules.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:36
  • Comments:32 (6 by maintainers)

github_iconTop GitHub Comments

20reactions
alexeigscommented, Nov 27, 2018

Open your settings.json and overwrite the default settings:

"vetur.format.defaultFormatterOptions": {
    "prettier": {
        // add your prettier settings here
        "singleQuote": true,
        "semi": false,
    }
}
7reactions
Bartozzzcommented, Oct 25, 2018

cc @iamswain25 @gilesbutler

I had the same issue. I was using ESLint & Prettier to format my code but it was only formatting code between <template> and <style> tags – not <script>'s. The following configuration should solve this issue:

  • VSCode config:

Update: Removed "prettier.disableLanguages"

{
  "editor.formatOnSave": true,

  "vetur.validation.template": false,
  "vetur.format.defaultFormatter.scss": "prettier",
  "vetur.format.defaultFormatter.css": "prettier",
  "vetur.format.defaultFormatter.js": "prettier",

  "prettier.eslintIntegration": true,

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

  "javascript.validate.enable": false,
  "javascript.format.enable": false
}
  • .eslintrc.json:
module.exports = {
  root: true,

  extends: ["plugin:vue/essential", "@vue/prettier"],
  plugins: ["vue"],

  env: {
    browser: true,
    node: true
  },

  parserOptions: {
    parser: "babel-eslint",
    ecmaVersion: 2017,
    sourceType: "module"
  }
};
  • package.json:
{
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.4",
    "@vue/cli-plugin-eslint": "^3.0.4",
    "eslint": "5.6.1",
    "eslint-plugin-vue": "4.7.1",
    "prettier": "1.14.3"
  }
}

Required VSCode plugins:

  • Prettier
  • ESLint
  • Vetur
Read more comments on GitHub >

github_iconTop Results From Across the Web

Integrating with Linters - Prettier
Linters usually contain not only code quality rules, but also stylistic rules. Most stylistic rules are unnecessary when using Prettier, but worse –...
Read more >
Using Prettier and ESLint to automate formatting and fixing ...
Methods for linting and pretty-printing your code; Remove conflicting rules and run serially; Run Prettier followed by ESLint programmatically ...
Read more >
Efficient Code Analyzing and Formatting (for Vue.js) with ...
Lately, I have been investigating quite some time into linting and formatting of JavaScript code for large projects with many developers and ...
Read more >
How to use Prettier with ESLint - Robin Wieruch
In this brief setup guide, I want to show you how to combine Prettier with ESLint without wasting any tear. If you haven't...
Read more >
ESLint runs prettier twice if config in .eslintrc and .prettierrc
defaultFormatter": "vscode.typescript-language-features" }, "editor.formatOnSave": true, "vetur.experimental.templateInterpolationService": true ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found