fix(agents): validate SVG images and conventional guides

This commit is contained in:
4gray committed 2026-09-21 05:10:12 +02:00
1 parent 87a27b5458
commit 91d04d94cb
4 files changed
+37 -4

No files matched your search

+1 -1
View File
@@ -77,7 +77,7 @@ function htmlNavigation(html, inspect = () => {}) {
)
anchors.push(attribute.value);
if (
(['a', 'area'].includes(node.tagName) &&
(['a', 'area', 'image'].includes(node.tagName) &&
attribute.name === 'href') ||
([
'img',
+1 -1
View File
@@ -166,7 +166,7 @@ async function packageMentions(rootDir) {
if (
/%[\da-f]{2}/iu.test(token) ||
MARKDOWN_EXTENSION.test(path) ||
/(?:^|\/)(?:AGENTS|CLAUDE|INSTRUCTIONS|README|LICENSE|LICENCE|NOTICE|COPYING|AUTHORS|CONTRIBUTORS|CHANGELOG)$/iu.test(
/(?:^|\/)(?:AGENTS|CLAUDE|INSTRUCTIONS|README|LICENSE|LICENCE|NOTICE|COPYING|AUTHORS|CONTRIBUTORS|CHANGELOG|CONTRIBUTING|SECURITY|CODE_OF_CONDUCT|SUPPORT)$/iu.test(
path
) ||
DOCUMENT_EXTENSION.test(path)
@@ -1669,3 +1669,36 @@ test('image input source is validated', async (t) => {
[]
);
});
for (const attribute of ['href', 'xlink:href']) {
test(`SVG image reference is checked: ${attribute}`, async (t) => {
assert.ok(
(
await diagnostics(t, {
'AGENTS.md': `<svg><image ${attribute}="missing.png"/></svg>`,
})
).length > 0
);
assert.deepEqual(
await diagnostics(t, {
'AGENTS.md': `<svg><image ${attribute}="docs/example.md"/></svg>`,
}),
[]
);
});
}
for (const name of ['CONTRIBUTING', 'SECURITY', 'code_of_conduct', 'SUPPORT']) {
test(`conventional guidance basename is not a package: ${name}`, async (t) => {
assert.ok(
(
await diagnostics(t, {
'package.json': JSON.stringify({
dependencies: { '@angular/core': '*' },
}),
'CLAUDE.md':
'@AGENTS.md\n\nRead @angular/core/docs/' + name,
})
).some((message) => message.includes('additional or inline'))
);
});
}