Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Nov 26, 2024
1 parent 78c7145 commit 0aff190
Show file tree
Hide file tree
Showing 72 changed files with 166 additions and 159 deletions.
2 changes: 1 addition & 1 deletion demo/markdownlint-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ function annotateAndFreezeTokens(tokens, lines) {
* @param {import("./markdownlint").Plugin[]} markdownItPlugins Additional plugins.
* @param {string} content Markdown content.
* @param {string[]} lines Lines of Markdown content.
* @returns {import("../lib/markdownlint").MarkdownItToken} Array of markdown-it tokens.
* @returns {import("../lib/markdownlint.mjs").MarkdownItToken} Array of markdown-it tokens.
*/
function getMarkdownItTokens(markdownItPlugins, content, lines) {
const markdownit = __webpack_require__(/*! markdown-it */ "markdown-it");
Expand Down
4 changes: 2 additions & 2 deletions doc/CustomRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A simple rule implementation using the `micromark` parser to report a violation
for any use of blockquotes might look like:

```javascript
/** @type import("markdownlint").Rule */
/** @type {import("markdownlint").Rule} */
module.exports = {
"names": [ "any-blockquote-micromark" ],
"description": "Rule that reports an error for any blockquote",
Expand All @@ -61,7 +61,7 @@ module.exports = {
That same rule implemented using the `markdown-it` parser might look like:

```javascript
/** @type import("markdownlint").Rule */
/** @type {import("markdownlint").Rule} */
module.exports = {
"names": [ "any-blockquote-markdown-it" ],
"description": "Rule that reports an error for any blockquote",
Expand Down
8 changes: 4 additions & 4 deletions helpers/helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const { newLineRe, nextLinesRe } = require("./shared.cjs");
module.exports.newLineRe = newLineRe;
module.exports.nextLinesRe = nextLinesRe;

/** @typedef {import("../lib/markdownlint.js").RuleOnError} RuleOnError */
/** @typedef {import("../lib/markdownlint.js").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
/** @typedef {import("../lib/markdownlint.mjs").RuleOnError} RuleOnError */

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 12 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.
/** @typedef {import("../lib/markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 13 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

// Regular expression for matching common front matter (YAML and TOML)
module.exports.frontMatterRe =
Expand Down Expand Up @@ -336,8 +336,8 @@ const positionLessThanOrEqual = (lineA, columnA, lineB, columnB) => (
/**
* Returns whether two ranges (or MicromarkTokens) overlap anywhere.
*
* @param {FileRange|import("../lib/markdownlint.js").MicromarkToken} rangeA Range A.
* @param {FileRange|import("../lib/markdownlint.js").MicromarkToken} rangeB Range B.
* @param {FileRange|import("../lib/markdownlint.mjs").MicromarkToken} rangeA Range A.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 339 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.
* @param {FileRange|import("../lib/markdownlint.mjs").MicromarkToken} rangeB Range B.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (macos-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 23.1)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.

Check failure on line 340 in helpers/helpers.cjs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 22)

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../lib/markdownlint.mjs")' call instead.
* @returns {boolean} True iff the two ranges overlap.
*/
module.exports.hasOverlap = function hasOverlap(rangeA, rangeB) {
Expand Down
4 changes: 2 additions & 2 deletions helpers/micromark-helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.cjs");

/** @typedef {import("markdownlint-micromark").TokenType} TokenType */
/** @typedef {import("../lib/markdownlint.js").MicromarkToken} Token */
/** @typedef {import("micromark-util-types").TokenType} TokenType */
/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} Token */

/**
* Determines if a Micromark token is within an htmlFlow type.
Expand Down
9 changes: 2 additions & 7 deletions helpers/micromark-parse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@ import { labelEnd } from "micromark-core-commonmark";
import { isHtmlFlowComment } from "./micromark-helpers.cjs";
import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "./shared.cjs";

/** @typedef {import("micromark-util-types").Event} Event */
/** @typedef {import("micromark-util-types").ParseOptions} MicromarkParseOptions */
/** @typedef {import("micromark-util-types").State} State */
/** @typedef {import("micromark-util-types").Token} Token */
/** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */
/** @typedef {import("./micromark-types").PlaceholderForImporting} */
/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} MicromarkToken */

// export declare interface TokenTypeMap {
// undefinedReference: 'undefinedReference'
// undefinedReferenceCollapsed: 'undefinedReferenceCollapsed'
// undefinedReferenceFull: 'undefinedReferenceFull'
// undefinedReferenceShortcut: 'undefinedReferenceShortcut'
// }

/**
* Parse options.
*
Expand Down
12 changes: 12 additions & 0 deletions helpers/micromark-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Augment TokenTypeMap with markdownlint-specific types.
export declare module "micromark-util-types" {
interface TokenTypeMap {
undefinedReference: "undefinedReference"
undefinedReferenceCollapsed: "undefinedReferenceCollapsed"
undefinedReferenceFull: "undefinedReferenceFull"
undefinedReferenceShortcut: "undefinedReferenceShortcut"
}
}

// Placeholder to use when importing.
declare type PlaceholderForImporting = never;
10 changes: 5 additions & 5 deletions lib/cache.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import helpers from "../helpers/helpers.cjs";
import { getReferenceLinkImageData as helpersGetReferenceLinkImageData } from "../helpers/helpers.cjs";
import { filterByTypes } from "../helpers/micromark-helpers.cjs";

/** @type {Map<string, object>} */
Expand All @@ -10,7 +10,7 @@ let params = undefined;
/**
* Initializes (resets) the cache.
*
* @param {import("./markdownlint").RuleParams} [p] Rule parameters object.
* @param {import("./markdownlint.mjs").RuleParams} [p] Rule parameters object.
* @returns {void}
*/
export function initialize(p) {
Expand All @@ -37,9 +37,9 @@ function getCached(name, getValue) {
/**
* Filters a list of Micromark tokens by type and caches the result.
*
* @param {import("./markdownlint").MicromarkTokenType[]} types Types to allow.
* @param {import("./markdownlint.mjs").MicromarkTokenType[]} types Types to allow.
* @param {boolean} [htmlFlow] Whether to include htmlFlow content.
* @returns {import("./markdownlint").MicromarkToken[]} Filtered tokens.
* @returns {import("./markdownlint.mjs").MicromarkToken[]} Filtered tokens.
*/
export function filterByTypesCached(types, htmlFlow) {
return getCached(
Expand All @@ -57,6 +57,6 @@ export function filterByTypesCached(types, htmlFlow) {
export function getReferenceLinkImageData() {
return getCached(
getReferenceLinkImageData.name,
() => helpers.getReferenceLinkImageData(params.parsers.micromark.tokens)
() => helpersGetReferenceLinkImageData(params.parsers.micromark.tokens)
);
}
8 changes: 4 additions & 4 deletions lib/markdownit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function forEachInlineCodeSpan(input, handler) {
/**
* Freeze all freeze-able members of a token and its children.
*
* @param {import("./markdownlint").MarkdownItToken} token A markdown-it token.
* @param {import("./markdownlint.mjs").MarkdownItToken} token A markdown-it token.
* @returns {void}
*/
function freezeToken(token) {
Expand Down Expand Up @@ -99,7 +99,7 @@ function freezeToken(token) {
function annotateAndFreezeTokens(tokens, lines) {
let trMap = null;
// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").MarkdownItToken[] */
/** @type {import("./markdownlint.mjs").MarkdownItToken[]} */
// @ts-ignore
const markdownItTokens = tokens;
for (const token of markdownItTokens) {
Expand Down Expand Up @@ -148,10 +148,10 @@ function annotateAndFreezeTokens(tokens, lines) {
/**
* Gets an array of markdown-it tokens for the input.
*
* @param {import("./markdownlint").Plugin[]} markdownItPlugins Additional plugins.
* @param {import("./markdownlint.mjs").Plugin[]} markdownItPlugins Additional plugins.
* @param {string} content Markdown content.
* @param {string[]} lines Lines of Markdown content.
* @returns {import("../lib/markdownlint").MarkdownItToken} Array of markdown-it tokens.
* @returns {import("../lib/markdownlint.mjs").MarkdownItToken} Array of markdown-it tokens.
*/
function getMarkdownItTokens(markdownItPlugins, content, lines) {
const markdownit = require("markdown-it");
Expand Down
8 changes: 4 additions & 4 deletions lib/markdownlint.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// @ts-check

import nodeFs from "node:fs";
import * as nodeFs from "node:fs";
import { createRequire } from "node:module";
const dynamicRequire = createRequire(import.meta.url);
import os from "node:os";
import * as os from "node:os";
import path from "node:path";
import { promisify } from "node:util";
import { getMarkdownItTokens } from "./markdownit.cjs";
import { parse as micromarkParse } from "../helpers/micromark-parse.mjs";
import { version } from "./constants.mjs";
import rules from "./rules.mjs";
import helpers from "../helpers/helpers.cjs";
import * as helpers from "../helpers/helpers.cjs";
import { initialize as cacheInitialize } from "./cache.mjs";

/**
Expand Down Expand Up @@ -1411,7 +1411,7 @@ export default markdownlint;
* @property {string} line Line content.
*/

/** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
/** @typedef {import("micromark-util-types").TokenType} MicromarkTokenType */

/**
* micromark token.
Expand Down
2 changes: 1 addition & 1 deletion lib/md001.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD001", "heading-increment" ],
"description": "Heading levels should only increment by one level at a time",
Expand Down
2 changes: 1 addition & 1 deletion lib/md003.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.c
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD003", "heading-style" ],
"description": "Heading style",
Expand Down
2 changes: 1 addition & 1 deletion lib/md004.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const validStyles = new Set([
]);

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD004", "ul-style" ],
"description": "Unordered list style",
Expand Down
2 changes: 1 addition & 1 deletion lib/md005.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD005", "list-indent" ],
"description": "Inconsistent indentation for list items at the same level",
Expand Down
6 changes: 3 additions & 3 deletions lib/md007.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { getParentOfType } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("markdownlint-micromark").TokenType[] */
/** @type {import("micromark-util-types").TokenType[]} */
const unorderedListTypes =
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
// eslint-disable-next-line jsdoc/valid-types
/** @type import("markdownlint-micromark").TokenType[] */
/** @type {import("micromark-util-types").TokenType[]} */
const unorderedParentTypes =
[ "blockQuote", "listOrdered", "listUnordered" ];

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD007", "ul-indent" ],
"description": "Unordered list indentation",
Expand Down
2 changes: 1 addition & 1 deletion lib/md009.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD009", "no-trailing-spaces" ],
"description": "Trailing spaces",
Expand Down
6 changes: 3 additions & 3 deletions lib/md010.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { filterByTypesCached } from "./cache.mjs";
const tabRe = /\t+/g;

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD010", "no-hard-tabs" ],
"description": "Hard tabs",
Expand All @@ -25,7 +25,7 @@ export default {
1 :
Math.max(0, Number(spacesPerTab));
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark-helpers.cjs").TokenType[] */
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
const exclusionTypes = [];
if (includeCode) {
if (ignoreCodeLanguages.size > 0) {
Expand Down Expand Up @@ -58,7 +58,7 @@ export default {
const lineNumber = lineIndex + 1;
const column = match.index + 1;
const length = match[0].length;
/** @type {import("../helpers").FileRange} */
/** @type {import("../helpers/helpers.cjs").FileRange} */
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
if (!codeRanges.some((codeRange) => hasOverlap(codeRange, range))) {
addError(
Expand Down
4 changes: 2 additions & 2 deletions lib/md011.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const reversedLinkRe =
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD011", "no-reversed-links" ],
"description": "Reversed link syntax",
Expand All @@ -32,7 +32,7 @@ export default {
) {
const column = match.index + preChar.length + 1;
const length = match[0].length - preChar.length;
/** @type {import("../helpers").FileRange} */
/** @type {import("../helpers/helpers.cjs").FileRange} */
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
if (!codeTexts.some((codeText) => hasOverlap(codeText, range))) {
addError(
Expand Down
2 changes: 1 addition & 1 deletion lib/md012.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD012", "no-multiple-blanks" ],
"description": "Multiple consecutive blank lines",
Expand Down
2 changes: 1 addition & 1 deletion lib/md013.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const longLineRePostfixStrict = "}.+$";
const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD013", "line-length" ],
"description": "Line length",
Expand Down
2 changes: 1 addition & 1 deletion lib/md014.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs";
const dollarCommandRe = /^(\s*)(\$\s+)/;

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD014", "commands-show-output" ],
"description": "Dollar signs used before commands without showing output",
Expand Down
2 changes: 1 addition & 1 deletion lib/md018.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD018", "no-missing-space-atx" ],
"description": "No space after hash on atx style heading",
Expand Down
6 changes: 3 additions & 3 deletions lib/md019-md021.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { filterByTypesCached } from "./cache.mjs";
/**
* Validate heading sequence and whitespace length at start or end.
*
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
* @param {import("./markdownlint").MicromarkToken} heading ATX heading token.
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
* @param {import("./markdownlint.mjs").MicromarkToken} heading ATX heading token.
* @param {number} delta Direction to scan.
* @returns {void}
*/
Expand Down Expand Up @@ -46,7 +46,7 @@ function validateHeadingSpaces(onError, heading, delta) {
}

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule[] */
/** @type {import("./markdownlint.mjs").Rule[]} */
export default [
{
"names": [ "MD019", "no-multiple-space-atx" ],
Expand Down
2 changes: 1 addition & 1 deletion lib/md020.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD020", "no-missing-space-closed-atx" ],
"description": "No space inside hashes on closed atx style heading",
Expand Down
2 changes: 1 addition & 1 deletion lib/md022.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getLinesFunction = (linesParam) => {
};

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD022", "blanks-around-headings" ],
"description": "Headings should be surrounded by blank lines",
Expand Down
2 changes: 1 addition & 1 deletion lib/md023.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD023", "heading-start-left" ],
"description": "Headings must start at the beginning of the line",
Expand Down
2 changes: 1 addition & 1 deletion lib/md024.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cj
import { filterByTypesCached } from "./cache.mjs";

// eslint-disable-next-line jsdoc/valid-types
/** @type import("./markdownlint").Rule */
/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD024", "no-duplicate-heading" ],
"description": "Multiple headings with the same content",
Expand Down
Loading

0 comments on commit 0aff190

Please sign in to comment.