chore: disallow shortcut reference links in docs Markdown (#36860)

* chore: disallow shortcut reference links in docs Markdown

* docs: clean up shortcut-style links
This commit is contained in:
David Sanders 2023-01-16 01:22:49 -08:00 committed by GitHub
parent a9e7bb0027
commit d94f35a8f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 199 additions and 171 deletions

View file

@ -0,0 +1,21 @@
const { addError, getLineMetadata, getReferenceLinkImageData } = require('markdownlint/helpers');
module.exports = {
names: ['EMD001', 'no-shortcut-reference-links'],
description:
'Disallow shortcut reference links (those with no link label)',
tags: ['images', 'links'],
function: function EMD001 (params, onError) {
const lineMetadata = getLineMetadata(params);
const { shortcuts } = getReferenceLinkImageData(lineMetadata);
for (const [shortcut, occurrences] of shortcuts) {
for (const [lineNumber] of occurrences) {
addError(
onError,
lineNumber + 1, // human-friendly line numbers (1-based)
`Disallowed shortcut reference link: "${shortcut}"`
);
}
}
}
};