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 = {
|
|
|
|
"names": [ "MD018", "no-missing-space-atx" ],
|
2018-03-19 23:39:42 +01:00
|
|
|
"description": "No space after hash on atx style heading",
|
|
|
|
"tags": [ "headings", "headers", "atx", "spaces" ],
|
2018-01-21 21:44:25 -08:00
|
|
|
"function": function MD018(params, onError) {
|
2018-03-04 23:06:31 -08:00
|
|
|
shared.forEachLine(function forLine(line, lineIndex, inCode) {
|
2018-01-21 21:44:25 -08:00
|
|
|
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
|
|
|
|
shared.addErrorContext(onError, lineIndex + 1, line.trim(), null,
|
2018-03-19 23:39:42 +01:00
|
|
|
null, shared.rangeFromRegExp(line, shared.atxHeadingSpaceRe));
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|