We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0812502 commit 702ebcaCopy full SHA for 702ebca
package-lock.json
package.json
@@ -1,6 +1,6 @@
1
{
2
"name": "htmlhint",
3
- "version": "1.6.1",
+ "version": "1.6.2",
4
"description": "The Static Code Analysis Tool for your HTML",
5
"keywords": [
6
"html",
src/core/rules/attr-value-no-duplication.ts
@@ -20,8 +20,12 @@ export default {
20
// Skip content, media, and style attributes entirely
21
if (
22
attr.name.toLowerCase() === 'content' ||
23
+ attr.name.toLowerCase() === 'd' ||
24
attr.name.toLowerCase() === 'media' ||
- attr.name.toLowerCase() === 'style'
25
+ attr.name.toLowerCase() === 'sizes' ||
26
+ attr.name.toLowerCase() === 'src' ||
27
+ attr.name.toLowerCase() === 'style' ||
28
+ attr.name.toLowerCase().startsWith('on') // Skip all event handlers (onclick, onchange, etc.)
29
) {
30
continue
31
}
test/rules/attr-value-no-duplication.spec.js
@@ -98,4 +98,25 @@ describe(`Rules: ${ruleId}`, () => {
98
const messages = HTMLHint.verify(code, ruleOptions)
99
expect(messages.length).toBe(0)
100
})
101
+
102
+ it('Script src attribute should be skipped entirely', () => {
103
+ const code =
104
+ '<script src="data:text/javascript,window.analytics = window.analytics || function() { (window.analytics.q = window.analytics.q || []).push(arguments) }"></script>'
105
+ const messages = HTMLHint.verify(code, ruleOptions)
106
+ expect(messages.length).toBe(0)
107
+ })
108
109
+ it('Sizes attribute should be skipped entirely', () => {
110
111
+ '<source type="" sizes="(min-width: 1rem) 1vw, (min-width: 2rem) 2vw" srcset="">'
112
113
114
115
116
+ it('Event handler attributes should be skipped entirely', () => {
117
118
+ "<button onclick=\"trackEvent('click'); validateForm(); trackEvent('click');\">Submit</button>"
119
120
121
122
website/src/content/docs/changelog.mdx
@@ -5,6 +5,10 @@ description: The release notes for HTMLHint, see what's changed with each new ve
import { Badge } from '@astrojs/starlight/components'
7
8
+## 1.6.2 _(2025-06-18)_
9
10
+- <Badge text="Fix" size="small" variant="danger" /> Improve [`attr-value-no-duplication`](/rules/attr-value-no-duplication/) logic
11
12
## 1.6.1 _(2025-06-17)_
13
14
- <Badge text="Fix" size="small" variant="danger" /> Improve SARIF report formatting
website/src/content/docs/index.mdx
@@ -14,7 +14,7 @@ hero:
variant: minimal
15
banner:
16
content: |
17
- v1.6.1 is now available! Check the <a href="/changelog/">changelog</a> to see what's new.
+ v1.6.2 is now available! Check the <a href="/changelog/">changelog</a> to see what's new.
18
tableOfContents: false
19
lastUpdated: false
editUrl: false
website/src/content/docs/rules/attr-value-no-duplication.mdx
@@ -31,6 +31,22 @@ Level: <Badge text="Error" variant="danger" />
<div class="btn btn-primary btn-large">Button</div>
32
```
33
34
+```html
35
+<source type="" sizes="(min-width: 1rem) 1vw, (min-width: 2rem) 2vw" srcset="">
36
+```
37
38
+## Excluded attributes
39
40
+The following attributes are excluded from this rule and will not trigger errors even if they contain duplicate values:
41
42
+- `content` - Common for meta tags that may contain duplicate keywords
43
+- `d` - Used in SVG path data which may contain repetitive pattern data
44
+- `media` - Used for media queries which have special parsing rules
45
+- `on*` - All event handlers (onclick, onkeydown, etc.) that may contain legitimate duplicate JavaScript operations
46
+- `sizes` - Used in responsive images with complex viewport conditions
47
+- `src` - URLs and data URIs that might legitimately contain repeated patterns
48
+- `style` - Inline CSS which has its own syntax and may contain duplicate property names
49
50
### The following patterns are considered rule violations:
51
52
```html
@@ -42,7 +58,7 @@ Level: <Badge text="Error" variant="danger" />
58
59
60
-<div class="btn primary btn">Button</div>
61
+<div class="btn primary btn">Button</div>
62
63
64
## Why does this rule exist?
website/src/content/docs/rules/tag-no-obsolete.mdx
@@ -23,10 +23,9 @@ This rule prevents the use of HTML tags that have been deprecated and are consid
### Obsolete tags include:
-- `applet`, `acronym`, `bgsound`, `dir`, `frame`, `frameset`, `noframes`
-- `isindex`, `keygen`, `listing`, `menuitem`, `nextid`, `noembed`
-- `plaintext`, `rb`, `rtc`, `strike`, `xmp`, `basefont`, `big`
-- `blink`, `center`, `font`, `marquee`, `multicol`, `nobr`, `spacer`, `tt`
+`acronym`, `applet`, `basefont`, `bgsound`, `big`, `blink`, `center`, `dir`, `font`, `frame`, `frameset`,
+`isindex`, `keygen`, `listing`, `marquee`, `menuitem`, `multicol`, `nextid`, `nobr`, `noembed`, `noframes`,
+`plaintext`, `rb`, `rtc`, `spacer`, `strike`, `tt`, `xmp`
### The following patterns are **not** considered rule violations
0 commit comments