electron/script/markdownlint-emd001.js
David Sanders d94f35a8f6
chore: disallow shortcut reference links in docs Markdown (#36860)
* chore: disallow shortcut reference links in docs Markdown

* docs: clean up shortcut-style links
2023-01-16 10:22:49 +01:00

21 lines
748 B
JavaScript

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}"`
);
}
}
}
};