Skip to content

Commit ae266d7

Browse files
committed
fix(markuplint): add exclusions for image src naming rules
1 parent ee41e41 commit ae266d7

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

packages/@d-zero/markuplint-config/base.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export default {
4343
reason:
4444
'省略可能なケースがほとんど想定されないため、原則禁止としています。省略する場合は明確な理由が必要です。(D-ZERO独自ルール)',
4545
},
46+
},
47+
},
48+
{
49+
selector:
50+
'img:not([src^="data:"], [src^="blob:"], [src^="https://"], [src^="http://"], [src^="//"])',
51+
rules: {
4652
'invalid-attr': {
4753
options: {
4854
disallowAttrs: [

test/cli.spec.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ describe('markuplint', () => {
171171
'packages/@d-zero/markuplint-config/base.js',
172172
);
173173
expect(invalidNaming).toStrictEqual([
174-
'test/fixtures/markuplint/image-naming-test.html:16:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
175-
'test/fixtures/markuplint/image-naming-test.html:17:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
176-
'test/fixtures/markuplint/image-naming-test.html:18:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
177-
'test/fixtures/markuplint/image-naming-test.html:19:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
174+
'test/fixtures/markuplint/image-naming-test.html:21:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
175+
'test/fixtures/markuplint/image-naming-test.html:22:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
176+
'test/fixtures/markuplint/image-naming-test.html:23:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
177+
'test/fixtures/markuplint/image-naming-test.html:24:15 The "src" attribute is matched with the below disallowed patterns: /[A-Z\\s_]/',
178178
]);
179179

180180
const validNaming = await markuplint(

test/fixtures/markuplint/image-naming-test.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
</head>
77
<body>
88
<h1>Image Naming Test</h1>
9-
9+
1010
<!-- Valid image file names -->
1111
<img src="images/hero-banner.jpg" alt="Hero banner" />
1212
<img src="assets/icons/search-icon.png" alt="Search icon" />
1313
<img src="media/product-image-01.webp" alt="Product image" />
14-
14+
<img src="data:image/png;base64,XXXX" alt="Data URI image" />
15+
<img src="blob:XXXX" alt="Blob image" />
16+
<img src="https://XXXX" alt="HTTPS image" />
17+
<img src="http://XXXX" alt="HTTP image" />
18+
<img src="//XXXX" alt="Protocol-relative image" />
19+
1520
<!-- Invalid image file names - should trigger errors -->
1621
<img src="images/Hero Banner.jpg" alt="Hero banner with spaces" />
1722
<img src="assets/ProductImage.PNG" alt="Uppercase letters" />

0 commit comments

Comments
 (0)