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:
parent
a9e7bb0027
commit
d94f35a8f6
38 changed files with 199 additions and 171 deletions
21
script/markdownlint-emd001.js
Normal file
21
script/markdownlint-emd001.js
Normal 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}"`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue