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.

no-duplicate-attributes should have css exceptions

See original GitHub issue
  • ESLint Version: 4.3.0
  • eslint-plugin-vue Version: 3.8.0
  • Node Version: 8.1.4

<span class="label label-rounded" :class="statusColor"></span>
<span style="font-weight:bold;" :style="{ color: activeColor, fontSize: fontSize + 'px' }"></span>

Duplicate attribute ‘class’. (vue/no-duplicate-attributes) Duplicate attribute ‘style’. (vue/no-duplicate-attributes)

Class and Style, specifically, should be allowed to be duplicated since they tend to have a mix of static and dynamic content. You often have structural styling that gets set in stone at development time, but want reactive styles or classes applied at runtime.

Perhaps no-duplicate-attributes should take an option for ignoring css attributes (class and style).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
armano2commented, Jul 28, 2017

@nchutchind nice catch Vue is allowing for duplicates for style and class but not always:

This is ok:

  • <div style="" :style="">
  • <div class="" :class="">

This is not ok:

  • <div style="" style="">
  • <div :style="" :style="">
  • <div class="" class="">
  • <div :class="" :class="">

I think we should add setting to allow this.

2reactions
mysticateacommented, Aug 1, 2017

Thank you for the report!

I had not noticed that class and :class can coexist. Yes, this is a bug. I think that the rule should ignore class and style by default. I think “good to have” about the option which disallows duplicate of class and style.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make exceptions to CSS rules? - html - Stack Overflow
Long story short, I would like to tell the a attribute to apply to everything except img elements. Here is my existing CSS...
Read more >
Specificity - CSS: Cascading Style Sheets - MDN Web Docs
As a special case for increasing specificity, you can duplicate weights from the CLASS or ID columns. Duplicating id, class, pseudo-class or ...
Read more >
DRY CSS: How to Use Declarations Just Once, Effectively
Be sure to remove the duplicate declarations whose selectors have just been copied up in the style sheet, and to remove the entire...
Read more >
CSS :not() with Multiple Classes
I think it goes without saying but having chained (:not)s just seems logically confusing. If 2 are checked for :not, then every class...
Read more >
Attribute is not duplicated[proposed] | ACT Rule | WAI - W3C
This rule checks that HTML and SVG starting tags do not contain duplicated attributes. Applicability. This rule applies to any starting tag in...
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