mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Convert markdownlint library to an ECMAScript module, replace markdownlint-micromark with micromark, stop publishing (large) markdownlint-browser.js, see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c for guidance.
This commit is contained in:
parent
191226f070
commit
1e71f6f44e
140 changed files with 1087 additions and 10428 deletions
37
lib/md023.mjs
Normal file
37
lib/md023.mjs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// @ts-check
|
||||
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD023", "heading-start-left" ],
|
||||
"description": "Headings must start at the beginning of the line",
|
||||
"tags": [ "headings", "spaces" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD023(params, onError) {
|
||||
const headings = filterByTypesCached([ "atxHeading", "linePrefix", "setextHeading" ]);
|
||||
for (let i = 0; i < headings.length - 1; i++) {
|
||||
if (
|
||||
(headings[i].type === "linePrefix") &&
|
||||
(headings[i + 1].type !== "linePrefix") &&
|
||||
(headings[i].startLine === headings[i + 1].startLine)
|
||||
) {
|
||||
const { endColumn, startColumn, startLine } = headings[i];
|
||||
const length = endColumn - startColumn;
|
||||
addErrorContext(
|
||||
onError,
|
||||
startLine,
|
||||
params.lines[startLine - 1],
|
||||
true,
|
||||
false,
|
||||
[ startColumn, length ],
|
||||
{
|
||||
"editColumn": startColumn,
|
||||
"deleteCount": length
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue