mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-21 00:10:13 +01:00
Enable "line-length": { "strict": true } for all user-facing Markdown files in the repository.
This commit is contained in:
parent
72439f42c6
commit
91dd6dcb1d
49 changed files with 819 additions and 517 deletions
|
|
@ -4,10 +4,26 @@ import { default as rules } from "../lib/rules.js";
|
|||
import { newLineRe } from "../helpers/helpers.js";
|
||||
import { deprecatedRuleNames, fixableRuleNames } from "../lib/constants.js";
|
||||
|
||||
const maxLineLength = 80;
|
||||
|
||||
const pathFor = (relativePath) => new URL(relativePath, import.meta.url);
|
||||
const inCode = (items) => items.map((item) => `\`${item}\``);
|
||||
const sortedComma = (items) => items.sort().join(", ");
|
||||
const linesFrom = (text) => text.split(newLineRe);
|
||||
const wrapListItem = (line) => {
|
||||
const wrappedLines = [];
|
||||
let remainingLine = line;
|
||||
while (remainingLine.length > maxLineLength) {
|
||||
let index = maxLineLength - 1;
|
||||
while (remainingLine[index] !== " ") {
|
||||
index--;
|
||||
}
|
||||
wrappedLines.push(remainingLine.slice(0, index + 1).trimEnd());
|
||||
remainingLine = " " + remainingLine.slice(index + 1).trimStart();
|
||||
}
|
||||
wrappedLines.push(remainingLine);
|
||||
return wrappedLines;
|
||||
};
|
||||
|
||||
// import { default as schema } from "file.json" assert { type: "json" };
|
||||
const importJson =
|
||||
|
|
@ -48,24 +64,27 @@ for (const rule of rules) {
|
|||
if (ruleData.properties) {
|
||||
section.push(
|
||||
"Parameters:",
|
||||
"",
|
||||
...Object.keys(ruleData.properties).sort().map((property) => {
|
||||
const propData = ruleData.properties[property];
|
||||
const propType = (propData.type === "array") ?
|
||||
`${propData.items.type}[]` :
|
||||
propData.type;
|
||||
const defaultValue = Array.isArray(propData.default) ?
|
||||
JSON.stringify(propData.default) :
|
||||
propData.default;
|
||||
const allValues = propData.enum?.sort();
|
||||
return `* \`${property}\`: ${propData.description} (` +
|
||||
`\`${propType}\`, default \`${defaultValue}\`` +
|
||||
(propData.enum ?
|
||||
`, values ${allValues.map((value) => `\`${value}\``).join("/")}` :
|
||||
""
|
||||
) +
|
||||
")";
|
||||
}),
|
||||
""
|
||||
);
|
||||
for (const property of Object.keys(ruleData.properties).sort()) {
|
||||
const propData = ruleData.properties[property];
|
||||
const propType = (propData.type === "array") ?
|
||||
`${propData.items.type}[]` :
|
||||
propData.type;
|
||||
const defaultValue = Array.isArray(propData.default) ?
|
||||
JSON.stringify(propData.default) :
|
||||
propData.default;
|
||||
const allValues = propData.enum?.sort();
|
||||
const listItem = `* \`${property}\`: ${propData.description} (` +
|
||||
`\`${propType}\`, default \`${defaultValue}\`` +
|
||||
(propData.enum ?
|
||||
`, values ${allValues.map((value) => `\`${value}\``).join(" / ")}` :
|
||||
""
|
||||
) +
|
||||
")";
|
||||
section.push(...wrapListItem(listItem));
|
||||
}
|
||||
section.push(
|
||||
""
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue