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.

Remove Multi-attribute-elements-strongly-recommended

See original GitHub issue

I think we should reconsider https://vuejs.org/v2/style-guide/#Multi-attribute-elements-strongly-recommended and its dedicated eslint rule that is included by default in strongly-recommended It doesn’ make sense to split per attribute count as they can be very short leading to extremely narrow-column-looking html. There was this issue https://github.com/vuejs/eslint-plugin-vue/issues/378 but I don’t think it makes sense to support both rules I think we should split when the line is above a certain length (like prettier does). And this can already be achieved by deactivating the eslint rule for max-attributes-per-line and using prettier but recommending to split per attribute count is bad. Take vuetify as an example:

          <v-layout
            shrink
            align-center
          >
            <v-btn
              small
              depressed
            >Engagement</v-btn>
            <v-btn
              small
              depressed
              color="primary"
            >
              <v-icon>loop</v-icon> GED
            </v-btn>
            <v-btn
              depressed
              small
              color="info"
            >
              <v-icon>cast</v-icon>
            </v-btn>
            <v-flex class="bold">21H 10 MIN</v-flex>
          </v-layout>
        </v-layout>

This would be a good example:

<a :href="href" class="short" target="_blank">Foo<a>
<a
  foo="a very long multi-tribute element that exceeds the max length"
  any
  other
  attr
  should
  be
  on="its own line"
>

For anybody interested in having the obove formatting working automatically, it’s achievable by deactivating the rule vue/max-attributes-per-line in .eslintrc with "vue/max-attributes-per-line": 0 and make sure you don’t have "vetur.format.defaultFormatter.html": "js-beautify-html" in your VSCode settings

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:11
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
jak-kalcommented, Sep 4, 2019

For me, I find that splitting attributes into one-per-line decreases the overall readability of my markup. I favour readability and always try and make effective use of whitespace.

I’ve seen a few of my colleagues start writing this way - as per the docs - and I cannot stand it. Any more thoughts on this?

1reaction
phanancommented, Mar 8, 2019

The reason we use

<a
  foo="a very long multi-tribute element that exceeds the max length"
  any
  other
  attr
  should
  be
  on="its own line"
>

in our codebase is because it’s quite simple to reason about (and effective, I’d say): either all attributes are on the same line (if the max length isn’t exceeded), or none of them. This applies for HTML, JS, and even backend structs alike.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue/max-attributes-per-line
This rule aims to enforce a number of attributes per line in templates. It checks all the elements in a template and verifies...
Read more >
prettier not fixing vue/max-attributes-per-line · Issue #94 - GitHub
I noticed you haven't enabled any rules from prettier in your config file. What happens if you add "plugin:prettier/recommended" to your extends ...
Read more >
Using Variant Groups | Walmart Marketplace
A Variant Group is a group of individual items that only differ by a few attributes (size, color, scent, count, material, etc.) Items...
Read more >
Remove a child with a specific attribute, in SimpleXML for PHP
I need to remove a specific seg element, with an id of "A12", how can I do this? I've tried looping through the...
Read more >
ARIA: listbox role - Accessibility - MDN Web Docs - Mozilla
It is highly recommended using the HTML select element, or a group of ... setting the aria-selected to false , or removing the...
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