mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Refactor Token.parent() to Token.parent, add validation tests for parent, fix parent in htmlFlow scenario, improve type saftey slightly.
This commit is contained in:
parent
06466905a5
commit
2a56f130c1
9 changed files with 73 additions and 372 deletions
11
lib/md007.js
11
lib/md007.js
|
|
@ -5,6 +5,10 @@
|
|||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
|
||||
/**
|
||||
* @typedef {import("../helpers/micromark.cjs").Token} Token
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD007", "ul-indent" ],
|
||||
"description": "Unordered list indentation",
|
||||
|
|
@ -20,13 +24,14 @@ module.exports = {
|
|||
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ]
|
||||
);
|
||||
for (const token of tokens) {
|
||||
const { startColumn, startLine, type } = token;
|
||||
const { parent, startColumn, startLine, type } = token;
|
||||
if (type === "blockQuotePrefix") {
|
||||
lastBlockQuotePrefix = token;
|
||||
} else if (type === "listUnordered") {
|
||||
let nesting = 0;
|
||||
/** @type {Token | null} */
|
||||
let current = token;
|
||||
while ((current = current.parent())) {
|
||||
while ((current = current.parent)) {
|
||||
if (current.type === "listUnordered") {
|
||||
nesting++;
|
||||
} else if (current.type === "listOrdered") {
|
||||
|
|
@ -41,7 +46,7 @@ module.exports = {
|
|||
}
|
||||
} else {
|
||||
// listItemPrefix
|
||||
const nesting = unorderedListNesting.get(token.parent());
|
||||
const nesting = unorderedListNesting.get(parent);
|
||||
if (nesting !== undefined) {
|
||||
// listItemPrefix for listUnordered
|
||||
const expectedIndent =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue