2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2018-04-27 22:05:34 -07:00
|
|
|
const shared = require("./shared");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
|
|
|
module.exports = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"names": [ "MD024", "no-duplicate-heading", "no-duplicate-header" ],
|
|
|
|
"description": "Multiple headings with the same content",
|
|
|
|
"tags": [ "headings", "headers" ],
|
2018-01-21 21:44:25 -08:00
|
|
|
"function": function MD024(params, onError) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const knownContent = [];
|
2018-01-21 21:44:25 -08:00
|
|
|
shared.forEachHeading(params, function forHeading(heading, content) {
|
|
|
|
if (knownContent.indexOf(content) === -1) {
|
|
|
|
knownContent.push(content);
|
|
|
|
} else {
|
|
|
|
shared.addErrorContext(onError, heading.lineNumber,
|
|
|
|
heading.line.trim());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|