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:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nchutchind nice catch Vue is allowing for duplicates for
style
andclass
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.
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 ignoreclass
andstyle
by default. I think “good to have” about the option which disallows duplicate ofclass
andstyle
.