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.

prettier not fixing vue/max-attributes-per-line

See original GitHub issue

What version of eslint are you using? "^4.15.0"

What version of prettier are you using? VS Code plugin for prettier/prettier - 1.4.0

What version of eslint-plugin-prettier are you using? "^2.6.0"

Please paste any applicable config files that you’re using (e.g. .prettierrc or .eslintrc files)

/* .eslintrc */
module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  parserOptions: {
    parser: 'babel-eslint'
  },
  extends: [
    'eslint:recommended',
    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
    'plugin:vue/strongly-recommended'
  ],
  // required to lint *.vue files
  plugins: [
    'prettier',
    'vue'
  ],
  // add your custom rules here
  rules: {}
}

What source code are you linting?

      <!-- example.vue -->
      <div class="Cart__top">
        <button class="Cart__close  t-h5" type="button" @click="closeCart">Close</button>
        <div class="Cart__subtotal">
          <div class="Cart__subtotalTitle  t-h5">Subtotal</div>
          <div class="Cart__subtotalPrice  t-h1">€150</div>
        </div>
      </div>

What did you expect to happen? Output after executing format document command in vs code, line 3 would be formatted such that each attribute on the button element would be on a new line. I could be making a wrong assumption that my vs code prettier extension would make use of these settings, that prettier would ever do this, or that this is even the right place to post this??

What actually happened? No formatting of the attributes occurred.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

110reactions
not-an-aardvarkcommented, Jul 20, 2018

To fix this issue, you should disable the vue/max-attributes-per-line rule since it seems like it conflicts with how prettier attempts to style your code.

47reactions
hansiemithuncommented, Apr 27, 2020

Disabling prettier for Vue project, tired researching on the fix…

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue/max-attributes-per-line
It checks all the elements in a template and verifies that the number of attributes per line does not exceed the defined maximum....
Read more >
Prettier 2.6: new singleAttributePerLine option and new ...
This release includes a new `singleAttributePerLine` option. This is an option to print only one attribute per line in Vue SFC templates, ...
Read more >
Can't get correct autoformat on save in Visual Studio Code ...
vue files, it seems I can't get vue/max-attributes-per-line to auto-fix correctly. For example, with vue/max-attributes-per-line set to 'off', ...
Read more >
eslint prettier not fixing vue max-attributes-per-line - Lost a li
eslint prettier not fixing vue max-attributes-per-line · 禁用vue/max-attributes-per-line · 修改其配置,使其与prettier不冲突. 1 2 3 4 5 6 7, 'vue/ ...
Read more >
Having a tough time setting up EsLint/Prettier to work with Volar
Currently if I force the attributes to a new line, I receive a warning that ... 'vue/max-attributes-per-line': [ 1, { singleline: { max:...
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