Skip to content

Commit 3f3a048

Browse files
authored
fix: Improve attr-value-no-duplication logic (#1664)
Ignore `content` (otherwise will have problems with meta descriptions using a word twice etc.
1 parent aadd4cf commit 3f3a048

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

package-lock.json

Lines changed: 23 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/rules/attr-value-no-duplication.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ export default {
1717
for (let i = 0, l = attrs.length; i < l; i++) {
1818
attr = attrs[i]
1919

20-
// Skip style and media attributes entirely
20+
// Skip content, media, and style attributes entirely
2121
if (
22-
attr.name.toLowerCase() === 'style' ||
23-
attr.name.toLowerCase() === 'media'
22+
attr.name.toLowerCase() === 'content' ||
23+
attr.name.toLowerCase() === 'media' ||
24+
attr.name.toLowerCase() === 'style'
2425
) {
2526
continue
2627
}

test/rules/attr-value-no-duplication.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,11 @@ describe(`Rules: ${ruleId}`, () => {
9191
const messages = HTMLHint.verify(code, ruleOptions)
9292
expect(messages.length).toBe(0)
9393
})
94+
95+
it('Content attribute should be skipped entirely', () => {
96+
const code =
97+
'<meta name="keywords" content="HTML, CSS, JavaScript, HTML, responsive design">'
98+
const messages = HTMLHint.verify(code, ruleOptions)
99+
expect(messages.length).toBe(0)
100+
})
94101
})

website/src/content/docs/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ An example configuration file (with all rules disabled):
4747
"attr-sorted": false,
4848
"attr-unsafe-chars": false,
4949
"attr-value-double-quotes": false,
50+
"attr-value-no-duplication": false,
5051
"attr-value-not-empty": false,
5152
"attr-value-single-quotes": false,
5253
"attr-whitespace": false,
@@ -74,6 +75,7 @@ An example configuration file (with all rules disabled):
7475
"spec-char-escape": false,
7576
"src-not-empty": false,
7677
"style-disabled": false,
78+
"tag-no-obsolete": false,
7779
"tag-pair": false,
7880
"tag-self-close": false,
7981
"tagname-lowercase": false,

website/src/content/docs/getting-started.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components';
3737
"meta-viewport-require": true,
3838
"spec-char-escape": true,
3939
"src-not-empty": true,
40+
"tag-no-obsolete": true,
4041
"tag-pair": true,
4142
"tagname-lowercase": true,
4243
"title-require": true

0 commit comments

Comments
 (0)