Enable custom rules to use the micromark parser, export micromark helpers for reuse.

This commit is contained in:
David Anson 2024-10-01 22:41:10 -07:00
parent 264da24dae
commit 5cc40c54b7
16 changed files with 4109 additions and 113 deletions

1
helpers/.npmignore Normal file
View file

@ -0,0 +1 @@
test.js

View file

@ -3,7 +3,10 @@
"version": "0.26.0",
"description": "A collection of markdownlint helper functions for custom rules",
"main": "./helpers.js",
"exports": "./helpers.js",
"exports": {
".": "./helpers.js",
"./micromark": "./micromark-helpers.cjs"
},
"author": "David Anson (https://dlaa.me/)",
"license": "MIT",
"homepage": "https://github.com/DavidAnson/markdownlint",

28
helpers/test.cjs Normal file
View file

@ -0,0 +1,28 @@
// @ts-check
"use strict";
// eslint-disable-next-line n/no-extraneous-require
const test = require("ava").default;
const { "exports": packageExports, name } = require("../helpers/package.json");
const exportMappings = new Map([
[ ".", "../helpers/helpers.js" ],
[ "./micromark", "../helpers/micromark-helpers.cjs" ]
]);
test("exportMappings", (t) => {
t.deepEqual(
Object.keys(packageExports),
[ ...exportMappings.keys() ]
);
});
for (const [ exportName, exportPath ] of exportMappings) {
test(exportName, (t) => {
t.is(
require(exportName.replace(/^\./u, name)),
require(exportPath)
);
});
}