-
-
Notifications
You must be signed in to change notification settings - Fork 752
/
Copy pathmd046.mjs
31 lines (28 loc) · 867 Bytes
/
md046.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// @ts-check
import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";
const tokenTypeToStyle = {
"codeFenced": "fenced",
"codeIndented": "indented"
};
/** @type {import("markdownlint").Rule} */
export default {
"names": [ "MD046", "code-block-style" ],
"description": "Code block style",
"tags": [ "code" ],
"parser": "micromark",
"function": function MD046(params, onError) {
let expectedStyle = String(params.config.style || "consistent");
for (const token of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
const { startLine, type } = token;
if (expectedStyle === "consistent") {
expectedStyle = tokenTypeToStyle[type];
}
addErrorDetailIf(
onError,
startLine,
expectedStyle,
tokenTypeToStyle[type]);
}
}
};