From 8da43dd24691ea47cda7f0b9e6ad4d82db286071 Mon Sep 17 00:00:00 2001 From: David Anson Date: Tue, 3 Dec 2024 19:58:28 -0800 Subject: [PATCH] Update to use named exports via / /async /promise /sync, simplify references via self-referencing, refine examples. --- README.md | 76 +++++---- demo/browser-exports.mjs | 3 +- demo/default.js | 6 +- doc/CustomRules.md | 4 +- eslint.config.mjs | 2 +- example/Gruntfile.cjs | 4 +- example/gulpfile.cjs | 4 +- example/standalone.mjs | 59 ++++--- example/typescript/type-check.ts | 44 ++--- helpers/helpers.cjs | 13 +- helpers/micromark-helpers.cjs | 6 +- lib/cache.mjs | 6 +- lib/exports-async.d.mts | 1 + lib/exports-async.mjs | 3 + lib/exports-promise.d.mts | 1 + lib/exports-promise.mjs | 3 + lib/exports-sync.d.mts | 1 + lib/exports-sync.mjs | 3 + lib/exports.d.mts | 28 +++ lib/exports.mjs | 31 ++++ lib/markdownit.cjs | 4 +- lib/markdownlint.d.mts | 183 +++++++++----------- lib/markdownlint.mjs | 47 ++---- lib/md001.mjs | 2 +- lib/md003.mjs | 2 +- lib/md004.mjs | 4 +- lib/md005.mjs | 2 +- lib/md007.mjs | 4 +- lib/md009.mjs | 2 +- lib/md010.mjs | 4 +- lib/md011.mjs | 2 +- lib/md012.mjs | 2 +- lib/md013.mjs | 2 +- lib/md014.mjs | 2 +- lib/md018.mjs | 2 +- lib/md019-md021.mjs | 6 +- lib/md020.mjs | 2 +- lib/md022.mjs | 2 +- lib/md023.mjs | 2 +- lib/md024.mjs | 2 +- lib/md025.mjs | 2 +- lib/md026.mjs | 2 +- lib/md027.mjs | 2 +- lib/md028.mjs | 2 +- lib/md029.mjs | 4 +- lib/md030.mjs | 2 +- lib/md031.mjs | 4 +- lib/md032.mjs | 2 +- lib/md033.mjs | 2 +- lib/md034.mjs | 2 +- lib/md035.mjs | 2 +- lib/md036.mjs | 4 +- lib/md037.mjs | 2 +- lib/md038.mjs | 2 +- lib/md039.mjs | 12 +- lib/md040.mjs | 2 +- lib/md041.mjs | 2 +- lib/md042.mjs | 2 +- lib/md043.mjs | 2 +- lib/md044.mjs | 2 +- lib/md045.mjs | 2 +- lib/md046.mjs | 2 +- lib/md047.mjs | 2 +- lib/md048.mjs | 2 +- lib/md049-md050.mjs | 6 +- lib/md051.mjs | 8 +- lib/md052.mjs | 2 +- lib/md053.mjs | 2 +- lib/md054.mjs | 2 +- lib/md055.mjs | 2 +- lib/md056.mjs | 2 +- lib/md058.mjs | 2 +- lib/micromark-parse.mjs | 2 +- lib/types.d.mts | 12 ++ package.json | 9 +- schema/build-config-schema.mjs | 2 +- test/harness.mjs | 5 +- test/markdownlint-test-config.mjs | 72 ++++---- test/markdownlint-test-custom-rules.mjs | 206 ++++++++++++----------- test/markdownlint-test-extra-parse.mjs | 4 +- test/markdownlint-test-extra-type.mjs | 4 +- test/markdownlint-test-fixes.mjs | 6 +- test/markdownlint-test-helpers.mjs | 7 +- test/markdownlint-test-parallel.mjs | 9 +- test/markdownlint-test-repos.mjs | 5 +- test/markdownlint-test-result-object.mjs | 25 +-- test/markdownlint-test-scenarios.mjs | 9 +- test/markdownlint-test-worker.mjs | 5 +- test/markdownlint-test.mjs | 102 +++++------ test/profile-fixture.mjs | 5 +- test/rules/any-blockquote.cjs | 2 +- test/rules/every-n-lines.cjs | 2 +- test/rules/first-line.cjs | 2 +- test/rules/letters-E-X.cjs | 2 +- test/rules/lint-javascript.cjs | 2 +- test/rules/validate-json.cjs | 2 +- 96 files changed, 627 insertions(+), 540 deletions(-) create mode 100644 lib/exports-async.d.mts create mode 100644 lib/exports-async.mjs create mode 100644 lib/exports-promise.d.mts create mode 100644 lib/exports-promise.mjs create mode 100644 lib/exports-sync.d.mts create mode 100644 lib/exports-sync.mjs create mode 100644 lib/exports.d.mts create mode 100644 lib/exports.mjs create mode 100644 lib/types.d.mts diff --git a/README.md b/README.md index 16a85eac0..01797a119 100644 --- a/README.md +++ b/README.md @@ -312,42 +312,41 @@ alternate formats. ### Linting -Standard asynchronous API: +Asynchronous API via `import { lint } from "markdownlint/async"`: ```javascript /** * Lint specified Markdown files. * - * @param {Options} options Configuration options. + * @param {Options | null} options Configuration options. * @param {LintCallback} callback Callback (err, result) function. * @returns {void} */ -function markdownlint(options, callback) { ... } +function lint(options, callback) { ... } ``` -Synchronous API (for build scripts, etc.): +Synchronous API via `import { lint } from "markdownlint/sync"`: ```javascript /** - * Lint specified Markdown files synchronously. + * Lint specified Markdown files. * - * @param {Options} options Configuration options. + * @param {Options | null} options Configuration options. * @returns {LintResults} Results object. */ -function markdownlint.sync(options) { ... } +function lint(options) { ... } ``` -Promise API (in the `promises` namespace like Node.js's -[`fs` Promises API](https://nodejs.org/api/fs.html#fs_fs_promises_api)): +Promise API via `import { lint } from "markdownlint/promise"`: ```javascript /** * Lint specified Markdown files. * - * @param {Options} options Configuration options. + * @param {Options | null} options Configuration options. * @returns {Promise} Results object. */ -function markdownlint(options) { ... } +function lint(options) { ... } ``` #### options @@ -669,7 +668,7 @@ By default, configuration files are parsed as JSON (and named `.markdownlint.json`). Custom parsers can be provided to handle other formats like JSONC, YAML, and TOML. -Asynchronous API: +Asynchronous API via `import { readConfig } from "markdownlint/async"`: ```javascript /** @@ -684,22 +683,21 @@ Asynchronous API: function readConfig(file, parsers, fs, callback) { ... } ``` -Synchronous API: +Synchronous API via `import { readConfig } from "markdownlint/sync"`: ```javascript /** - * Read specified configuration file synchronously. + * Read specified configuration file. * * @param {string} file Configuration file name. * @param {ConfigurationParser[]} [parsers] Parsing function(s). * @param {Object} [fs] File system implementation. * @returns {Configuration} Configuration object. */ -function readConfigSync(file, parsers, fs) { ... } +function readConfig(file, parsers, fs) { ... } ``` -Promise API (in the `promises` namespace like Node.js's -[`fs` Promises API](https://nodejs.org/api/fs.html#fs_promises_api)): +Promise API via `import { readConfig } from "markdownlint/promise"`: ```javascript /** @@ -772,7 +770,8 @@ Configuration object. Rules that can be fixed automatically include a `fixInfo` property which is outlined in the [documentation for custom rules](doc/CustomRules.md#authoring). -To apply fixes consistently, the `applyFix`/`applyFixes` methods may be used: +To apply fixes consistently, the `applyFix`/`applyFixes` methods may be used via +`import { applyFix, applyFixes } from "markdownlint"`: ```javascript /** @@ -798,18 +797,19 @@ function applyFixes(input, errors) { ... } Invoking `applyFixes` with the results of a call to lint can be done like so: ```javascript -import markdownlint from "markdownlint"; +import { applyFixes } from "markdownlint"; +import { lint as lintSync } from "markdownlint/sync"; -const fixResults = markdownlint.sync({ "strings": { "content": original } }); -const fixed = markdownlint.applyFixes(original, fixResults.content); +const results = lintSync({ "strings": { "content": original } }); +const fixed = applyFixes(original, results.content); ``` ## Usage -Invoke `markdownlint` and use the `result` object's `toString` method: +Invoke `lint` and use the `result` object's `toString` method: ```javascript -import markdownlint from "markdownlint"; +import { lint as lintAsync } from "markdownlint/async"; const options = { "files": [ "good.md", "bad.md" ], @@ -819,9 +819,9 @@ const options = { } }; -markdownlint(options, function callback(err, result) { - if (!err) { - console.log(result.toString()); +lintAsync(options, function callback(error, results) { + if (!error && results) { + console.log(results.toString()); } }); ``` @@ -839,21 +839,22 @@ bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [ bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"] ``` -Or invoke `markdownlint.sync` for a synchronous call: +Or as a synchronous call: ```javascript -const result = markdownlint.sync(options); -console.log(result.toString()); +import { lint as lintSync } from "markdownlint/sync"; + +const results = lintSync(options); +console.log(results.toString()); ``` -To examine the `result` object directly: +To examine the `result` object directly via a `Promise`-based call: ```javascript -markdownlint(options, function callback(err, result) { - if (!err) { - console.dir(result, { "colors": true, "depth": null }); - } -}); +import { lint as lintPromise } from "markdownlint/promise"; + +const results = await lintPromise(options); +console.dir(results, { "colors": true, "depth": null }); ``` Output: @@ -910,7 +911,7 @@ Generate normal and minified scripts with: npm run build-demo ``` -Then reference the `markdownlint` script: +Then reference the `markdownlint-browser` script: ```html @@ -924,7 +925,8 @@ const options = { "content": "Some Markdown to lint." } }; -const results = window.markdownlint.markdownlint.sync(options).toString(); + +const results = globalThis.markdownlint.lintSync(options).toString(); ``` ## Examples diff --git a/demo/browser-exports.mjs b/demo/browser-exports.mjs index b1e8acf2d..42adabcbd 100644 --- a/demo/browser-exports.mjs +++ b/demo/browser-exports.mjs @@ -1,6 +1,7 @@ // @ts-check -export { default as markdownlint } from "../lib/markdownlint.mjs"; +export { applyFixes, getVersion } from "markdownlint"; +export { lint as lintSync } from "markdownlint/sync"; export { compile, parse, postprocess, preprocess } from "micromark"; export { directive, directiveHtml } from "micromark-extension-directive"; export { gfmAutolinkLiteral, gfmAutolinkLiteralHtml } from "micromark-extension-gfm-autolink-literal"; diff --git a/demo/default.js b/demo/default.js index 27fffc510..2a78a3af4 100644 --- a/demo/default.js +++ b/demo/default.js @@ -3,8 +3,8 @@ (function main() { // Dependencies var markdownit = globalThis.markdownit; - var markdownlint = globalThis.markdownlint.markdownlint; - var micromark = globalThis.markdownlint; + var markdownlint = globalThis.markdownlint; + var micromark = markdownlint; // DOM elements var markdown = document.getElementById("markdown"); @@ -112,7 +112,7 @@ }, "handleRuleFailures": true }; - allLintErrors = markdownlint.sync(options).content; + allLintErrors = markdownlint.lintSync(options).content; violations.innerHTML = allLintErrors.map(function mapResult(result) { var ruleName = result.ruleNames.slice(0, 2).join(" / "); return "" + diff --git a/doc/CustomRules.md b/doc/CustomRules.md index 1136d2caa..8f696ac47 100644 --- a/doc/CustomRules.md +++ b/doc/CustomRules.md @@ -160,8 +160,8 @@ implementation that is resolved when the rule completes. (The value passed to reported via the `onError` function just like for synchronous rules. **Note**: Asynchronous rules cannot be referenced in a synchronous calling -context (i.e., `markdownlint.sync(...)`). Attempting to do so throws an -exception. +context (i.e., `import { lint } from "markdownlint/sync"`). Attempting to do so +throws an exception. ## Examples diff --git a/eslint.config.mjs b/eslint.config.mjs index 62d20d0ed..2bf6cec78 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -149,7 +149,7 @@ export default [ ], "rules": { "no-console": "off", - "no-shadow": "off" + "no-constant-condition": "off" } }, { diff --git a/example/Gruntfile.cjs b/example/Gruntfile.cjs index bbb2a6f58..571d403df 100644 --- a/example/Gruntfile.cjs +++ b/example/Gruntfile.cjs @@ -13,8 +13,8 @@ module.exports = function wrapper(grunt) { grunt.registerMultiTask("markdownlint", function task() { const done = this.async(); - import("markdownlint").then(({ "default": markdownlint }) => { - markdownlint( + import("markdownlint/async").then(({ lint }) => { + lint( { "files": this.filesSrc }, function callback(err, result) { const resultString = err || ((result || "").toString()); diff --git a/example/gulpfile.cjs b/example/gulpfile.cjs index fda31268c..25dcdd58d 100644 --- a/example/gulpfile.cjs +++ b/example/gulpfile.cjs @@ -9,8 +9,8 @@ const through2 = require("through2"); gulp.task("markdownlint", function task() { return gulp.src("*.md", { "read": false }) .pipe(through2.obj(function obj(file, enc, next) { - import("markdownlint").then(({ "default": markdownlint }) => { - markdownlint( + import("markdownlint/async").then(({ lint }) => { + lint( { "files": [ file.relative ] }, function callback(err, result) { const resultString = (result || "").toString(); diff --git a/example/standalone.mjs b/example/standalone.mjs index 804a5094d..a1eed89c1 100644 --- a/example/standalone.mjs +++ b/example/standalone.mjs @@ -1,6 +1,9 @@ // @ts-check -import markdownlint from "markdownlint"; +import { applyFixes } from "markdownlint"; +import { lint as lintAsync } from "markdownlint/async"; +import { lint as lintPromise } from "markdownlint/promise"; +import { lint as lintSync } from "markdownlint/sync"; const options = { "files": [ "good.md", "bad.md" ], @@ -10,27 +13,39 @@ const options = { } }; -// Makes a synchronous call, using result.toString for pretty formatting -const result = markdownlint.sync(options); -console.log(result.toString()); +if (true) { -// Makes an asynchronous call -markdownlint(options, function callback(err, result) { - if (!err) { - // @ts-ignore - console.log(result.toString()); - } -}); + // Makes a synchronous call, uses result.toString for pretty formatting + const results = lintSync(options); + console.log(results.toString()); -// Displays the result object directly -markdownlint(options, function callback(err, result) { - if (!err) { - console.dir(result, { "colors": true, "depth": null }); - } -}); +} + +if (true) { + + // Makes an asynchronous call, uses result.toString for pretty formatting + lintAsync(options, function callback(error, results) { + if (!error && results) { + console.log(results.toString()); + } + }); + +} + +if (true) { + + // Makes a Promise-based asynchronous call, displays the result object directly + const results = await lintPromise(options); + console.dir(results, { "colors": true, "depth": null }); + +} + +if (true) { + + // Fixes all supported violations in Markdown content + const original = "# Heading"; + const results = lintSync({ "strings": { "content": original } }); + const fixed = applyFixes(original, results.content); + console.log(fixed); -// Fixes all supported violations in Markdown content -const original = "# Heading"; -const fixResults = markdownlint.sync({ "strings": { "content": original } }); -const fixed = markdownlint.applyFixes(original, fixResults.content); -console.log(fixed); +} diff --git a/example/typescript/type-check.ts b/example/typescript/type-check.ts index 1ab5cea15..725deade2 100644 --- a/example/typescript/type-check.ts +++ b/example/typescript/type-check.ts @@ -1,13 +1,17 @@ -// Attempt to validate all the type declarations in markdownlint.d.mts +// Attempt to validate important type declarations -import { default as markdownlint, Configuration, ConfigurationStrict, LintResults, Options, Rule, RuleParams, RuleOnError, RuleOnErrorInfo } from "../../lib/markdownlint.mjs"; +import { Configuration, ConfigurationStrict, LintResults, Options, Rule, RuleParams, RuleOnError, RuleOnErrorInfo } from "../../lib/exports.mjs"; +import { applyFix, applyFixes, getVersion } from "../../lib/exports.mjs"; +import { lint as lintAsync, readConfig as readConfigAsync } from "../../lib/exports-async.mjs"; +import { lint as lintPromise, readConfig as readConfigPromise } from "../../lib/exports-promise.mjs"; +import { lint as lintSync, readConfig as readConfigSync } from "../../lib/exports-sync.mjs"; import assert from "assert"; // @ts-expect-error TS7016: Could not find a declaration file for module 'markdown-it-sub'. import markdownItSub from "markdown-it-sub"; const markdownlintJsonPath = "../../.markdownlint.json"; -const version: string = markdownlint.getVersion(); +const version: string = getVersion(); assert(/^\d+\.\d+\.\d+$/.test(version)); function assertConfiguration(config: Configuration) { @@ -67,15 +71,15 @@ function assertLintResultsCallback(err: Error | null, results?: LintResults) { results && assertLintResults(results); } -assertConfiguration(markdownlint.readConfigSync(markdownlintJsonPath)); -assertConfiguration(markdownlint.readConfigSync(markdownlintJsonPath, [ JSON.parse ])); +assertConfiguration(readConfigSync(markdownlintJsonPath)); +assertConfiguration(readConfigSync(markdownlintJsonPath, [ JSON.parse ])); -markdownlint.readConfig(markdownlintJsonPath, assertConfigurationCallback); -markdownlint.readConfig(markdownlintJsonPath, [ JSON.parse ], assertConfigurationCallback); +readConfigAsync(markdownlintJsonPath, assertConfigurationCallback); +readConfigAsync(markdownlintJsonPath, [ JSON.parse ], assertConfigurationCallback); (async () => { - assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath)); - assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath, [ JSON.parse ])) + assertConfigurationCallback(null, await readConfigPromise(markdownlintJsonPath)); + assertConfigurationCallback(null, await readConfigPromise(markdownlintJsonPath, [ JSON.parse ])) })(); let options: Options; @@ -98,17 +102,17 @@ options = { "markdownItPlugins": [ [ markdownItSub ] ] }; -assertLintResults(markdownlint.sync(options)); -markdownlint(options, assertLintResultsCallback); +assertLintResults(lintSync(options)); +lintAsync(options, assertLintResultsCallback); (async () => { - assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options)); + assertLintResultsCallback(null, await lintPromise(options)); })(); options.files = "../bad.md"; -assertLintResults(markdownlint.sync(options)); -markdownlint(options, assertLintResultsCallback); +assertLintResults(lintSync(options)); +lintAsync(options, assertLintResultsCallback); (async () => { - assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options)); + assertLintResultsCallback(null, await lintPromise(options)); })(); const testRule: Rule = { @@ -162,14 +166,14 @@ const testRule: Rule = { }; options.customRules = [ testRule ]; -assertLintResults(markdownlint.sync(options)); -markdownlint(options, assertLintResultsCallback); +assertLintResults(lintSync(options)); +lintAsync(options, assertLintResultsCallback); (async () => { - assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options)); + assertLintResultsCallback(null, await lintPromise(options)); })(); assert.equal( - markdownlint.applyFix( + applyFix( "# Fixing\n", { "insertText": "Head", @@ -182,7 +186,7 @@ assert.equal( ); assert.equal( - markdownlint.applyFixes( + applyFixes( "# Fixing\n", [ { diff --git a/helpers/helpers.cjs b/helpers/helpers.cjs index f35f94291..5b5f6491f 100644 --- a/helpers/helpers.cjs +++ b/helpers/helpers.cjs @@ -10,13 +10,18 @@ module.exports.newLineRe = newLineRe; module.exports.nextLinesRe = nextLinesRe; // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("../lib/markdownlint.mjs").RuleOnError} RuleOnError */ +/** @typedef {import("markdownlint").RuleOnError} RuleOnError */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("../lib/markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ +/** @typedef {import("markdownlint").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} MicromarkToken */ +/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ +// eslint-disable-next-line jsdoc/valid-types +/** @typedef {import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} */ +// eslint-disable-next-line jsdoc/valid-types +/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */ // Regular expression for matching common front matter (YAML and TOML) +// @ts-ignore module.exports.frontMatterRe = /((^---[^\S\r\n\u2028\u2029]*$[\s\S]+?^---\s*)|(^\+\+\+[^\S\r\n\u2028\u2029]*$[\s\S]+?^(\+\+\+|\.\.\.)\s*)|(^\{[^\S\r\n\u2028\u2029]*$[\s\S]+?^\}\s*))(\r\n|\r|\n|$)/m; @@ -368,7 +373,7 @@ module.exports.frontMatterHasTitle = /** * Returns an object with information about reference links and images. * - * @param {import("../helpers/micromark-helpers.cjs").Token[]} tokens Micromark tokens. + * @param {MicromarkToken[]} tokens Micromark tokens. * @returns {Object} Reference link/image data. */ function getReferenceLinkImageData(tokens) { diff --git a/helpers/micromark-helpers.cjs b/helpers/micromark-helpers.cjs index 230279d9a..bed42c862 100644 --- a/helpers/micromark-helpers.cjs +++ b/helpers/micromark-helpers.cjs @@ -4,10 +4,10 @@ const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.cjs"); +// eslint-disable-next-line jsdoc/valid-types +/** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("micromark-util-types").TokenType} TokenType */ -// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} Token */ +/** @typedef {import("markdownlint").MicromarkToken} Token */ /** * Determines if a Micromark token is within an htmlFlow type. diff --git a/lib/cache.mjs b/lib/cache.mjs index c4af0e977..9d19b0a4a 100644 --- a/lib/cache.mjs +++ b/lib/cache.mjs @@ -10,7 +10,7 @@ let params = undefined; /** * Initializes (resets) the cache. * - * @param {import("./markdownlint.mjs").RuleParams} [p] Rule parameters object. + * @param {import("markdownlint").RuleParams} [p] Rule parameters object. * @returns {void} */ export function initialize(p) { @@ -37,9 +37,9 @@ function getCached(name, getValue) { /** * Filters a list of Micromark tokens by type and caches the result. * - * @param {import("./markdownlint.mjs").MicromarkTokenType[]} types Types to allow. + * @param {import("markdownlint").MicromarkTokenType[]} types Types to allow. * @param {boolean} [htmlFlow] Whether to include htmlFlow content. - * @returns {import("./markdownlint.mjs").MicromarkToken[]} Filtered tokens. + * @returns {import("markdownlint").MicromarkToken[]} Filtered tokens. */ export function filterByTypesCached(types, htmlFlow) { return getCached( diff --git a/lib/exports-async.d.mts b/lib/exports-async.d.mts new file mode 100644 index 000000000..72e1d8c6d --- /dev/null +++ b/lib/exports-async.d.mts @@ -0,0 +1 @@ +export { lintAsync as lint, readConfigAsync as readConfig } from "./markdownlint.mjs"; diff --git a/lib/exports-async.mjs b/lib/exports-async.mjs new file mode 100644 index 000000000..a39022472 --- /dev/null +++ b/lib/exports-async.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export { lintAsync as lint, readConfigAsync as readConfig } from "./markdownlint.mjs"; diff --git a/lib/exports-promise.d.mts b/lib/exports-promise.d.mts new file mode 100644 index 000000000..27ef95d26 --- /dev/null +++ b/lib/exports-promise.d.mts @@ -0,0 +1 @@ +export { extendConfigPromise as extendConfig, lintPromise as lint, readConfigPromise as readConfig } from "./markdownlint.mjs"; diff --git a/lib/exports-promise.mjs b/lib/exports-promise.mjs new file mode 100644 index 000000000..5ba296908 --- /dev/null +++ b/lib/exports-promise.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export { extendConfigPromise as extendConfig, lintPromise as lint, readConfigPromise as readConfig } from "./markdownlint.mjs"; diff --git a/lib/exports-sync.d.mts b/lib/exports-sync.d.mts new file mode 100644 index 000000000..8a26d4281 --- /dev/null +++ b/lib/exports-sync.d.mts @@ -0,0 +1 @@ +export { lintSync as lint, readConfigSync as readConfig } from "./markdownlint.mjs"; diff --git a/lib/exports-sync.mjs b/lib/exports-sync.mjs new file mode 100644 index 000000000..636fc94ec --- /dev/null +++ b/lib/exports-sync.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export { lintSync as lint, readConfigSync as readConfig } from "./markdownlint.mjs"; diff --git a/lib/exports.d.mts b/lib/exports.d.mts new file mode 100644 index 000000000..74f6dab1a --- /dev/null +++ b/lib/exports.d.mts @@ -0,0 +1,28 @@ +export type Configuration = import("./markdownlint.mjs").Configuration; +export type ConfigurationParser = import("./markdownlint.mjs").ConfigurationParser; +export type ConfigurationStrict = import("./markdownlint.mjs").ConfigurationStrict; +export type FixInfo = import("./markdownlint.mjs").FixInfo; +export type LintCallback = import("./markdownlint.mjs").LintCallback; +export type LintContentCallback = import("./markdownlint.mjs").LintContentCallback; +export type LintError = import("./markdownlint.mjs").LintError; +export type LintResults = import("./markdownlint.mjs").LintResults; +export type MarkdownItToken = import("./markdownlint.mjs").MarkdownItToken; +export type MarkdownParsers = import("./markdownlint.mjs").MarkdownParsers; +export type MicromarkToken = import("./markdownlint.mjs").MicromarkToken; +export type MicromarkTokenType = import("./markdownlint.mjs").MicromarkTokenType; +export type Options = import("./markdownlint.mjs").Options; +export type ParserMarkdownIt = import("./markdownlint.mjs").ParserMarkdownIt; +export type ParserMicromark = import("./markdownlint.mjs").ParserMicromark; +export type Plugin = import("./markdownlint.mjs").Plugin; +export type ReadConfigCallback = import("./markdownlint.mjs").ReadConfigCallback; +export type ResolveConfigExtendsCallback = import("./markdownlint.mjs").ResolveConfigExtendsCallback; +export type Rule = import("./markdownlint.mjs").Rule; +export type RuleConfiguration = import("./markdownlint.mjs").RuleConfiguration; +export type RuleFunction = import("./markdownlint.mjs").RuleFunction; +export type RuleOnError = import("./markdownlint.mjs").RuleOnError; +export type RuleOnErrorFixInfo = import("./markdownlint.mjs").RuleOnErrorFixInfo; +export type RuleOnErrorFixInfoNormalized = import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized; +export type RuleOnErrorInfo = import("./markdownlint.mjs").RuleOnErrorInfo; +export type RuleParams = import("./markdownlint.mjs").RuleParams; +export type ToStringCallback = import("./markdownlint.mjs").ToStringCallback; +export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs"; diff --git a/lib/exports.mjs b/lib/exports.mjs new file mode 100644 index 000000000..8fdef2e2a --- /dev/null +++ b/lib/exports.mjs @@ -0,0 +1,31 @@ +// @ts-check + +export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs"; + +/** @typedef {import("./markdownlint.mjs").Configuration} Configuration */ +/** @typedef {import("./markdownlint.mjs").ConfigurationParser} ConfigurationParser */ +/** @typedef {import("./markdownlint.mjs").ConfigurationStrict} ConfigurationStrict */ +/** @typedef {import("./markdownlint.mjs").FixInfo} FixInfo */ +/** @typedef {import("./markdownlint.mjs").LintCallback} LintCallback */ +/** @typedef {import("./markdownlint.mjs").LintContentCallback} LintContentCallback */ +/** @typedef {import("./markdownlint.mjs").LintError} LintError */ +/** @typedef {import("./markdownlint.mjs").LintResults} LintResults */ +/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */ +/** @typedef {import("./markdownlint.mjs").MarkdownParsers} MarkdownParsers */ +/** @typedef {import("./markdownlint.mjs").MicromarkToken} MicromarkToken */ +/** @typedef {import("./markdownlint.mjs").MicromarkTokenType} MicromarkTokenType */ +/** @typedef {import("./markdownlint.mjs").Options} Options */ +/** @typedef {import("./markdownlint.mjs").ParserMarkdownIt} ParserMarkdownIt */ +/** @typedef {import("./markdownlint.mjs").ParserMicromark} ParserMicromark */ +/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */ +/** @typedef {import("./markdownlint.mjs").ReadConfigCallback} ReadConfigCallback */ +/** @typedef {import("./markdownlint.mjs").ResolveConfigExtendsCallback} ResolveConfigExtendsCallback */ +/** @typedef {import("./markdownlint.mjs").Rule} Rule */ +/** @typedef {import("./markdownlint.mjs").RuleConfiguration} RuleConfiguration */ +/** @typedef {import("./markdownlint.mjs").RuleFunction} RuleFunction */ +/** @typedef {import("./markdownlint.mjs").RuleOnError} RuleOnError */ +/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ +/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized} RuleOnErrorFixInfoNormalized */ +/** @typedef {import("./markdownlint.mjs").RuleOnErrorInfo} RuleOnErrorInfo */ +/** @typedef {import("./markdownlint.mjs").RuleParams} RuleParams */ +/** @typedef {import("./markdownlint.mjs").ToStringCallback} ToStringCallback */ diff --git a/lib/markdownit.cjs b/lib/markdownit.cjs index 5651dc081..62db38262 100644 --- a/lib/markdownit.cjs +++ b/lib/markdownit.cjs @@ -5,9 +5,9 @@ const { newLineRe } = require("../helpers"); // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */ +/** @typedef {import("markdownlint").MarkdownItToken} MarkdownItToken */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */ +/** @typedef {import("markdownlint").Plugin} Plugin */ /** * @callback InlineCodeSpanCallback diff --git a/lib/markdownlint.d.mts b/lib/markdownlint.d.mts index 900f2be3f..e4d01230e 100644 --- a/lib/markdownlint.d.mts +++ b/lib/markdownlint.d.mts @@ -1,4 +1,87 @@ -export default markdownlint; +/** + * Lint specified Markdown files. + * + * @param {Options | null} options Configuration options. + * @param {LintCallback} callback Callback (err, result) function. + * @returns {void} + */ +export function lintAsync(options: Options | null, callback: LintCallback): void; +/** + * Lint specified Markdown files. + * + * @param {Options | null} options Configuration options. + * @returns {Promise} Results object. + */ +export function lintPromise(options: Options | null): Promise; +/** + * Lint specified Markdown files. + * + * @param {Options | null} options Configuration options. + * @returns {LintResults} Results object. + */ +export function lintSync(options: Options | null): LintResults; +/** + * Extend specified configuration object. + * + * @param {Configuration} config Configuration object. + * @param {string} file Configuration file name. + * @param {ConfigurationParser[] | undefined} parsers Parsing function(s). + * @param {Object} fs File system implementation. + * @returns {Promise} Configuration object. + */ +export function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: any): Promise; +/** + * Read specified configuration file. + * + * @param {string} file Configuration file name. + * @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing + * function(s). + * @param {Object} [fs] File system implementation. + * @param {ReadConfigCallback} [callback] Callback (err, result) function. + * @returns {void} + */ +export function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void; +/** + * Read specified configuration file. + * + * @param {string} file Configuration file name. + * @param {ConfigurationParser[]} [parsers] Parsing function(s). + * @param {Object} [fs] File system implementation. + * @returns {Promise} Configuration object. + */ +export function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise; +/** + * Read specified configuration file. + * + * @param {string} file Configuration file name. + * @param {ConfigurationParser[]} [parsers] Parsing function(s). + * @param {Object} [fs] File system implementation. + * @returns {Configuration} Configuration object. + */ +export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration; +/** + * Applies the specified fix to a Markdown content line. + * + * @param {string} line Line of Markdown content. + * @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance. + * @param {string} [lineEnding] Line ending to use. + * @returns {string | null} Fixed content or null if deleted. + */ +export function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null; +/** + * Applies as many of the specified fixes as possible to Markdown content. + * + * @param {string} input Lines of Markdown content. + * @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances. + * @returns {string} Fixed content. + */ +export function applyFixes(input: string, errors: RuleOnErrorInfo[]): string; +/** + * Gets the (semantic) version of the library. + * + * @returns {string} SemVer string. + */ +export function getVersion(): string; /** * Function to implement rule logic. */ @@ -431,101 +514,3 @@ export type ReadConfigCallback = (err: Error | null, config?: Configuration) => * Called with the result of the resolveConfigExtends function. */ export type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void; -/** - * Lint specified Markdown files. - * - * @param {Options | null} options Configuration options. - * @param {LintCallback} callback Callback (err, result) function. - * @returns {void} - */ -declare function markdownlint(options: Options | null, callback: LintCallback): void; -declare namespace markdownlint { - export { markdownlintSync as sync }; - export { readConfig }; - export { readConfigSync }; - export { getVersion }; - export namespace promises { - export { markdownlintPromise as markdownlint }; - export { extendConfigPromise as extendConfig }; - export { readConfigPromise as readConfig }; - } - export { applyFix }; - export { applyFixes }; -} -/** - * Lint specified Markdown files synchronously. - * - * @param {Options | null} options Configuration options. - * @returns {LintResults} Results object. - */ -declare function markdownlintSync(options: Options | null): LintResults; -/** - * Read specified configuration file. - * - * @param {string} file Configuration file name. - * @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing - * function(s). - * @param {Object} [fs] File system implementation. - * @param {ReadConfigCallback} [callback] Callback (err, result) function. - * @returns {void} - */ -declare function readConfig(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void; -/** - * Read specified configuration file synchronously. - * - * @param {string} file Configuration file name. - * @param {ConfigurationParser[]} [parsers] Parsing function(s). - * @param {Object} [fs] File system implementation. - * @returns {Configuration} Configuration object. - * @throws An Error if processing fails. - */ -declare function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration; -/** - * Gets the (semantic) version of the library. - * - * @returns {string} SemVer string. - */ -declare function getVersion(): string; -/** - * Lint specified Markdown files. - * - * @param {Options} options Configuration options. - * @returns {Promise} Results object. - */ -declare function markdownlintPromise(options: Options): Promise; -/** - * Extend specified configuration object. - * - * @param {Configuration} config Configuration object. - * @param {string} file Configuration file name. - * @param {ConfigurationParser[] | undefined} parsers Parsing function(s). - * @param {Object} fs File system implementation. - * @returns {Promise} Configuration object. - */ -declare function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: any): Promise; -/** - * Read specified configuration file. - * - * @param {string} file Configuration file name. - * @param {ConfigurationParser[]} [parsers] Parsing function(s). - * @param {Object} [fs] File system implementation. - * @returns {Promise} Configuration object. - */ -declare function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise; -/** - * Applies the specified fix to a Markdown content line. - * - * @param {string} line Line of Markdown content. - * @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance. - * @param {string} [lineEnding] Line ending to use. - * @returns {string | null} Fixed content or null if deleted. - */ -declare function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null; -/** - * Applies as many of the specified fixes as possible to Markdown content. - * - * @param {string} input Lines of Markdown content. - * @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances. - * @returns {string} Fixed content. - */ -declare function applyFixes(input: string, errors: RuleOnErrorInfo[]): string; diff --git a/lib/markdownlint.mjs b/lib/markdownlint.mjs index a40cb8497..6ff36222b 100644 --- a/lib/markdownlint.mjs +++ b/lib/markdownlint.mjs @@ -954,19 +954,19 @@ function lintInput(options, synchronous, callback) { * @param {LintCallback} callback Callback (err, result) function. * @returns {void} */ -function markdownlint(options, callback) { +export function lintAsync(options, callback) { return lintInput(options, false, callback); } /** * Lint specified Markdown files. * - * @param {Options} options Configuration options. + * @param {Options | null} options Configuration options. * @returns {Promise} Results object. */ -function markdownlintPromise(options) { +export function lintPromise(options) { return new Promise((resolve, reject) => { - markdownlint(options, (error, results) => { + lintAsync(options, (error, results) => { if (error || !results) { reject(error); } else { @@ -977,12 +977,12 @@ function markdownlintPromise(options) { } /** - * Lint specified Markdown files synchronously. + * Lint specified Markdown files. * * @param {Options | null} options Configuration options. * @returns {LintResults} Results object. */ -function markdownlintSync(options) { +export function lintSync(options) { let results = null; lintInput(options, true, function callback(error, res) { if (error) { @@ -1072,7 +1072,7 @@ function extendConfig(config, file, parsers, fs, callback) { helpers.expandTildePath(configExtends, os), fs, // eslint-disable-next-line no-use-before-define - (_, resolvedExtends) => readConfig( + (_, resolvedExtends) => readConfigAsync( // @ts-ignore resolvedExtends, parsers, @@ -1103,7 +1103,7 @@ function extendConfig(config, file, parsers, fs, callback) { * @param {Object} fs File system implementation. * @returns {Promise} Configuration object. */ -function extendConfigPromise(config, file, parsers, fs) { +export function extendConfigPromise(config, file, parsers, fs) { return new Promise((resolve, reject) => { extendConfig(config, file, parsers, fs, (error, results) => { if (error || !results) { @@ -1125,7 +1125,7 @@ function extendConfigPromise(config, file, parsers, fs) { * @param {ReadConfigCallback} [callback] Callback (err, result) function. * @returns {void} */ -function readConfig(file, parsers, fs, callback) { +export function readConfigAsync(file, parsers, fs, callback) { if (!callback) { if (fs) { callback = fs; @@ -1168,9 +1168,9 @@ function readConfig(file, parsers, fs, callback) { * @param {Object} [fs] File system implementation. * @returns {Promise} Configuration object. */ -function readConfigPromise(file, parsers, fs) { +export function readConfigPromise(file, parsers, fs) { return new Promise((resolve, reject) => { - readConfig(file, parsers, fs, (error, results) => { + readConfigAsync(file, parsers, fs, (error, results) => { if (error || !results) { reject(error); } else { @@ -1181,15 +1181,14 @@ function readConfigPromise(file, parsers, fs) { } /** - * Read specified configuration file synchronously. + * Read specified configuration file. * * @param {string} file Configuration file name. * @param {ConfigurationParser[]} [parsers] Parsing function(s). * @param {Object} [fs] File system implementation. * @returns {Configuration} Configuration object. - * @throws An Error if processing fails. */ -function readConfigSync(file, parsers, fs) { +export function readConfigSync(file, parsers, fs) { if (!fs) { fs = nodeFs; } @@ -1242,7 +1241,7 @@ function normalizeFixInfo(fixInfo, lineNumber = 0) { * @param {string} [lineEnding] Line ending to use. * @returns {string | null} Fixed content or null if deleted. */ -function applyFix(line, fixInfo, lineEnding = "\n") { +export function applyFix(line, fixInfo, lineEnding = "\n") { const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo); const editIndex = editColumn - 1; return (deleteCount === -1) ? @@ -1257,7 +1256,7 @@ function applyFix(line, fixInfo, lineEnding = "\n") { * @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances. * @returns {string} Fixed content. */ -function applyFixes(input, errors) { +export function applyFixes(input, errors) { const lineEnding = helpers.getPreferredLineEnding(input, os); const lines = input.split(helpers.newLineRe); // Normalize fixInfo objects @@ -1335,24 +1334,10 @@ function applyFixes(input, errors) { * * @returns {string} SemVer string. */ -function getVersion() { +export function getVersion() { return version; } -// Export a/synchronous/Promise APIs -markdownlint.sync = markdownlintSync; -markdownlint.readConfig = readConfig; -markdownlint.readConfigSync = readConfigSync; -markdownlint.getVersion = getVersion; -markdownlint.promises = { - "markdownlint": markdownlintPromise, - "extendConfig": extendConfigPromise, - "readConfig": readConfigPromise -}; -markdownlint.applyFix = applyFix; -markdownlint.applyFixes = applyFixes; -export default markdownlint; - // Type declarations /** diff --git a/lib/md001.mjs b/lib/md001.mjs index b36db6a62..0413d3556 100644 --- a/lib/md001.mjs +++ b/lib/md001.mjs @@ -4,7 +4,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs"; import { getHeadingLevel } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD001", "heading-increment" ], "description": "Heading levels should only increment by one level at a time", diff --git a/lib/md003.mjs b/lib/md003.mjs index 6ed1d048b..d06068daa 100644 --- a/lib/md003.mjs +++ b/lib/md003.mjs @@ -4,7 +4,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs"; import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD003", "heading-style" ], "description": "Heading style", diff --git a/lib/md004.mjs b/lib/md004.mjs index 1679736f3..c56e3ad80 100644 --- a/lib/md004.mjs +++ b/lib/md004.mjs @@ -27,7 +27,7 @@ const validStyles = new Set([ "sublist" ]); -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD004", "ul-style" ], "description": "Unordered list style", @@ -40,7 +40,7 @@ export default { for (const listUnordered of filterByTypesCached([ "listUnordered" ])) { let nesting = 0; if (style === "sublist") { - /** @type {import("../helpers/micromark-helpers.cjs").Token | null} */ + /** @type {import("markdownlint").MicromarkToken | null} */ let parent = listUnordered; // @ts-ignore while ((parent = getParentOfType(parent, [ "listOrdered", "listUnordered" ]))) { diff --git a/lib/md005.mjs b/lib/md005.mjs index 0c79e2a9f..33374a7b6 100644 --- a/lib/md005.mjs +++ b/lib/md005.mjs @@ -3,7 +3,7 @@ import { addError, addErrorDetailIf } from "../helpers/helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD005", "list-indent" ], "description": "Inconsistent indentation for list items at the same level", diff --git a/lib/md007.mjs b/lib/md007.mjs index 37ec553b9..6b38447c3 100644 --- a/lib/md007.mjs +++ b/lib/md007.mjs @@ -11,7 +11,7 @@ const unorderedListTypes = const unorderedParentTypes = [ "blockQuote", "listOrdered", "listUnordered" ]; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD007", "ul-indent" ], "description": "Unordered list indentation", @@ -30,7 +30,7 @@ export default { lastBlockQuotePrefix = token; } else if (type === "listUnordered") { let nesting = 0; - /** @type {import("../helpers/micromark-helpers.cjs").Token | null} */ + /** @type {import("markdownlint").MicromarkToken | null} */ let current = token; while ( // @ts-ignore diff --git a/lib/md009.mjs b/lib/md009.mjs index f9de27178..55394ad63 100644 --- a/lib/md009.mjs +++ b/lib/md009.mjs @@ -4,7 +4,7 @@ import { addError } from "../helpers/helpers.cjs"; import { addRangeToSet } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD009", "no-trailing-spaces" ], "description": "Trailing spaces", diff --git a/lib/md010.mjs b/lib/md010.mjs index 2f6858c10..36ad10174 100644 --- a/lib/md010.mjs +++ b/lib/md010.mjs @@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs"; const tabRe = /\t+/g; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD010", "no-hard-tabs" ], "description": "Hard tabs", @@ -23,7 +23,7 @@ export default { const spaceMultiplier = (spacesPerTab === undefined) ? 1 : Math.max(0, Number(spacesPerTab)); - /** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */ + /** @type {import("markdownlint").MicromarkTokenType[]} */ const exclusionTypes = []; if (includeCode) { if (ignoreCodeLanguages.size > 0) { diff --git a/lib/md011.mjs b/lib/md011.mjs index f13e60bc3..32df13d6e 100644 --- a/lib/md011.mjs +++ b/lib/md011.mjs @@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs"; const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD011", "no-reversed-links" ], "description": "Reversed link syntax", diff --git a/lib/md012.mjs b/lib/md012.mjs index 1d48a47a0..2ec4a84e5 100644 --- a/lib/md012.mjs +++ b/lib/md012.mjs @@ -4,7 +4,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs"; import { addRangeToSet } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD012", "no-multiple-blanks" ], "description": "Multiple consecutive blank lines", diff --git a/lib/md013.mjs b/lib/md013.mjs index a2333a06e..0d1b24ead 100644 --- a/lib/md013.mjs +++ b/lib/md013.mjs @@ -12,7 +12,7 @@ const sternModeRe = /^(?:[#>\s]*\s)?\S*$/; /** @typedef {import("micromark-extension-gfm-autolink-literal")} */ /** @typedef {import("micromark-extension-gfm-table")} */ -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD013", "line-length" ], "description": "Line length", diff --git a/lib/md014.mjs b/lib/md014.mjs index 9d42e5f60..351d2f407 100644 --- a/lib/md014.mjs +++ b/lib/md014.mjs @@ -5,7 +5,7 @@ import { filterByTypesCached } from "./cache.mjs"; const dollarCommandRe = /^(\s*)(\$\s+)/; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD014", "commands-show-output" ], "description": "Dollar signs used before commands without showing output", diff --git a/lib/md018.mjs b/lib/md018.mjs index 5e9fbf94d..8575d0488 100644 --- a/lib/md018.mjs +++ b/lib/md018.mjs @@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs"; import { addRangeToSet } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD018", "no-missing-space-atx" ], "description": "No space after hash on atx style heading", diff --git a/lib/md019-md021.mjs b/lib/md019-md021.mjs index 954a45a16..ef579d471 100644 --- a/lib/md019-md021.mjs +++ b/lib/md019-md021.mjs @@ -7,8 +7,8 @@ import { filterByTypesCached } from "./cache.mjs"; /** * Validate heading sequence and whitespace length at start or end. * - * @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback. - * @param {import("./markdownlint.mjs").MicromarkToken} heading ATX heading token. + * @param {import("markdownlint").RuleOnError} onError Error-reporting callback. + * @param {import("markdownlint").MicromarkToken} heading ATX heading token. * @param {number} delta Direction to scan. * @returns {void} */ @@ -45,7 +45,7 @@ function validateHeadingSpaces(onError, heading, delta) { } } -/** @type {import("./markdownlint.mjs").Rule[]} */ +/** @type {import("markdownlint").Rule[]} */ export default [ { "names": [ "MD019", "no-multiple-space-atx" ], diff --git a/lib/md020.mjs b/lib/md020.mjs index 37584c3cf..3b45d2a3c 100644 --- a/lib/md020.mjs +++ b/lib/md020.mjs @@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs"; import { addRangeToSet } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD020", "no-missing-space-closed-atx" ], "description": "No space inside hashes on closed atx style heading", diff --git a/lib/md022.mjs b/lib/md022.mjs index f1ae5b8ce..bc82429b5 100644 --- a/lib/md022.mjs +++ b/lib/md022.mjs @@ -19,7 +19,7 @@ const getLinesFunction = (linesParam) => { return () => lines; }; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD022", "blanks-around-headings" ], "description": "Headings should be surrounded by blank lines", diff --git a/lib/md023.mjs b/lib/md023.mjs index c251ccdf3..bfb91beb8 100644 --- a/lib/md023.mjs +++ b/lib/md023.mjs @@ -3,7 +3,7 @@ import { addErrorContext } from "../helpers/helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD023", "heading-start-left" ], "description": "Headings must start at the beginning of the line", diff --git a/lib/md024.mjs b/lib/md024.mjs index 2ecaefe89..e10f7281a 100644 --- a/lib/md024.mjs +++ b/lib/md024.mjs @@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs"; import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD024", "no-duplicate-heading" ], "description": "Multiple headings with the same content", diff --git a/lib/md025.mjs b/lib/md025.mjs index 70ed09b60..f0b83a34b 100644 --- a/lib/md025.mjs +++ b/lib/md025.mjs @@ -4,7 +4,7 @@ import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs"; import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD025", "single-title", "single-h1" ], "description": "Multiple top-level headings in the same document", diff --git a/lib/md026.mjs b/lib/md026.mjs index bde45188b..273481101 100644 --- a/lib/md026.mjs +++ b/lib/md026.mjs @@ -4,7 +4,7 @@ import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe, endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD026", "no-trailing-punctuation" ], "description": "Trailing punctuation in heading", diff --git a/lib/md027.mjs b/lib/md027.mjs index df39c0c2a..bc9a4f59e 100644 --- a/lib/md027.mjs +++ b/lib/md027.mjs @@ -3,7 +3,7 @@ import { addErrorContext } from "../helpers/helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD027", "no-multiple-space-blockquote" ], "description": "Multiple spaces after blockquote symbol", diff --git a/lib/md028.mjs b/lib/md028.mjs index b81b368f0..1f4ce9eba 100644 --- a/lib/md028.mjs +++ b/lib/md028.mjs @@ -5,7 +5,7 @@ import { filterByTypesCached } from "./cache.mjs"; const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]); -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD028", "no-blanks-blockquote" ], "description": "Blank line inside blockquote", diff --git a/lib/md029.mjs b/lib/md029.mjs index 39fda4abc..f87e55134 100644 --- a/lib/md029.mjs +++ b/lib/md029.mjs @@ -13,14 +13,14 @@ const listStyleExamples = { /** * Gets the value of an ordered list item prefix token. * - * @param {import("../helpers/micromark-helpers.cjs").Token} listItemPrefix List item prefix token. + * @param {import("markdownlint").MicromarkToken} listItemPrefix List item prefix token. * @returns {number} List item value. */ function getOrderedListItemValue(listItemPrefix) { return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text); } -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD029", "ol-prefix" ], "description": "Ordered list item prefix", diff --git a/lib/md030.mjs b/lib/md030.mjs index 82f0b9745..6e7ee9e65 100644 --- a/lib/md030.mjs +++ b/lib/md030.mjs @@ -3,7 +3,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD030", "list-marker-space" ], "description": "Spaces after list markers", diff --git a/lib/md031.mjs b/lib/md031.mjs index a741fd5af..3494561f7 100644 --- a/lib/md031.mjs +++ b/lib/md031.mjs @@ -12,7 +12,7 @@ const codeFencePrefixRe = /^(.*?)[`~]/; /** * Adds an error for the top or bottom of a code fence. * - * @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback. + * @param {import("markdownlint").RuleOnError} onError Error-reporting callback. * @param {ReadonlyStringArray} lines Lines of Markdown content. * @param {number} lineNumber Line number. * @param {boolean} top True iff top fence. @@ -38,7 +38,7 @@ function addError(onError, lines, lineNumber, top) { ); } -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD031", "blanks-around-fences" ], "description": "Fenced code blocks should be surrounded by blank lines", diff --git a/lib/md032.mjs b/lib/md032.mjs index 5337cca72..5dc23cdd3 100644 --- a/lib/md032.mjs +++ b/lib/md032.mjs @@ -8,7 +8,7 @@ const isList = (token) => ( (token.type === "listOrdered") || (token.type === "listUnordered") ); -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD032", "blanks-around-lists" ], "description": "Lists should be surrounded by blank lines", diff --git a/lib/md033.mjs b/lib/md033.mjs index dd76308cf..d353c0d61 100644 --- a/lib/md033.mjs +++ b/lib/md033.mjs @@ -4,7 +4,7 @@ import { addError, nextLinesRe } from "../helpers/helpers.cjs"; import { getHtmlTagInfo } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD033", "no-inline-html" ], "description": "Inline HTML", diff --git a/lib/md034.mjs b/lib/md034.mjs index 4215e2b93..a33e4978e 100644 --- a/lib/md034.mjs +++ b/lib/md034.mjs @@ -5,7 +5,7 @@ import { filterByPredicate, getHtmlTagInfo, inHtmlFlow } from "../helpers/microm /** @typedef {import("micromark-extension-gfm-autolink-literal")} */ -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD034", "no-bare-urls" ], "description": "Bare URL used", diff --git a/lib/md035.mjs b/lib/md035.mjs index 81fde3d46..13f79124d 100644 --- a/lib/md035.mjs +++ b/lib/md035.mjs @@ -3,7 +3,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD035", "hr-style" ], "description": "Horizontal rule style", diff --git a/lib/md036.mjs b/lib/md036.mjs index 1dd4a86f7..c30ffc96e 100644 --- a/lib/md036.mjs +++ b/lib/md036.mjs @@ -4,14 +4,14 @@ import { addErrorContext, allPunctuation } from "../helpers/helpers.cjs"; import { getDescendantsByType } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @typedef {import("../helpers/micromark-helpers.cjs").TokenType} TokenType */ +/** @typedef {import("markdownlint").MicromarkTokenType} TokenType */ /** @type {TokenType[][]} */ const emphasisTypes = [ [ "emphasis", "emphasisText" ], [ "strong", "strongText" ] ]; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD036", "no-emphasis-as-heading" ], "description": "Emphasis used instead of a heading", diff --git a/lib/md037.mjs b/lib/md037.mjs index 09befcaa0..e2be28479 100644 --- a/lib/md037.mjs +++ b/lib/md037.mjs @@ -3,7 +3,7 @@ import { addError } from "../helpers/helpers.cjs"; import { filterByPredicate, inHtmlFlow } from "../helpers/micromark-helpers.cjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD037", "no-space-in-emphasis" ], "description": "Spaces inside emphasis markers", diff --git a/lib/md038.mjs b/lib/md038.mjs index 1664cd277..263b8eb79 100644 --- a/lib/md038.mjs +++ b/lib/md038.mjs @@ -17,7 +17,7 @@ const trimCodeText = (text, start, end) => { return text; }; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD038", "no-space-in-code" ], "description": "Spaces inside code span elements", diff --git a/lib/md039.mjs b/lib/md039.mjs index 26dd28865..691a5aff1 100644 --- a/lib/md039.mjs +++ b/lib/md039.mjs @@ -6,9 +6,9 @@ import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs"; /** * Adds an error for a label space issue. * - * @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback. - * @param {import("../helpers/micromark-helpers.cjs").Token} label Label token. - * @param {import("../helpers/micromark-helpers.cjs").Token} labelText LabelText token. + * @param {import("markdownlint").RuleOnError} onError Error-reporting callback. + * @param {import("markdownlint").MicromarkToken} label Label token. + * @param {import("markdownlint").MicromarkToken} labelText LabelText token. * @param {boolean} isStart True iff error is at the start of the link. */ function addLabelSpaceError(onError, label, labelText, isStart) { @@ -38,8 +38,8 @@ function addLabelSpaceError(onError, label, labelText, isStart) { /** * Determines if a link is a valid link (and not a fake shortcut link due to parser tricks). * - * @param {import("../helpers/micromark-helpers.cjs").Token} label Label token. - * @param {import("../helpers/micromark-helpers.cjs").Token} labelText LabelText token. + * @param {import("markdownlint").MicromarkToken} label Label token. + * @param {import("markdownlint").MicromarkToken} labelText LabelText token. * @param {Map} definitions Map of link definitions. * @returns {boolean} True iff the link is valid. */ @@ -47,7 +47,7 @@ function validLink(label, labelText, definitions) { return (label.parent?.children.length !== 1) || definitions.has(labelText.text.trim()); } -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD039", "no-space-in-links" ], "description": "Spaces inside link text", diff --git a/lib/md040.mjs b/lib/md040.mjs index 3bc1dfbdc..26e3d6258 100644 --- a/lib/md040.mjs +++ b/lib/md040.mjs @@ -4,7 +4,7 @@ import { addError, addErrorContext } from "../helpers/helpers.cjs"; import { getDescendantsByType } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD040", "fenced-code-language" ], "description": "Fenced code blocks should have a language specified", diff --git a/lib/md041.mjs b/lib/md041.mjs index 35764c94e..89a9a0a95 100644 --- a/lib/md041.mjs +++ b/lib/md041.mjs @@ -3,7 +3,7 @@ import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs"; import { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD041", "first-line-heading", "first-line-h1" ], "description": "First line in a file should be a top-level heading", diff --git a/lib/md042.mjs b/lib/md042.mjs index 6e005fb00..2127a548b 100644 --- a/lib/md042.mjs +++ b/lib/md042.mjs @@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs"; import { getDescendantsByType } from "../helpers/micromark-helpers.cjs"; import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD042", "no-empty-links" ], "description": "No empty links", diff --git a/lib/md043.mjs b/lib/md043.mjs index e7c8036c6..7342b190f 100644 --- a/lib/md043.mjs +++ b/lib/md043.mjs @@ -4,7 +4,7 @@ import { addErrorContext, addErrorDetailIf } from "../helpers/helpers.cjs"; import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs"; import { filterByTypesCached } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD043", "required-headings" ], "description": "Required heading structure", diff --git a/lib/md044.mjs b/lib/md044.mjs index de8b6432d..8e586b3fa 100644 --- a/lib/md044.mjs +++ b/lib/md044.mjs @@ -8,7 +8,7 @@ const ignoredChildTypes = new Set( [ "codeFencedFence", "definition", "reference", "resource" ] ); -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD044", "proper-names" ], "description": "Proper names should have the correct capitalization", diff --git a/lib/md045.mjs b/lib/md045.mjs index a54ca6957..a6219aa25 100644 --- a/lib/md045.mjs +++ b/lib/md045.mjs @@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs"; const altRe = getHtmlAttributeRe("alt"); -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD045", "no-alt-text" ], "description": "Images should have alternate text (alt text)", diff --git a/lib/md046.mjs b/lib/md046.mjs index 264a02737..f30abb97c 100644 --- a/lib/md046.mjs +++ b/lib/md046.mjs @@ -8,7 +8,7 @@ const tokenTypeToStyle = { "codeIndented": "indented" }; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD046", "code-block-style" ], "description": "Code block style", diff --git a/lib/md047.mjs b/lib/md047.mjs index f1272ff17..a78b16724 100644 --- a/lib/md047.mjs +++ b/lib/md047.mjs @@ -2,7 +2,7 @@ import { addError, isBlankLine } from "../helpers/helpers.cjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD047", "single-trailing-newline" ], "description": "Files should end with a single newline character", diff --git a/lib/md048.mjs b/lib/md048.mjs index f70e437da..6265a3c2c 100644 --- a/lib/md048.mjs +++ b/lib/md048.mjs @@ -19,7 +19,7 @@ function fencedCodeBlockStyleFor(markup) { } }; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD048", "code-fence-style" ], "description": "Code fence style", diff --git a/lib/md049-md050.mjs b/lib/md049-md050.mjs index f641cb896..45fb7882d 100644 --- a/lib/md049-md050.mjs +++ b/lib/md049-md050.mjs @@ -21,8 +21,8 @@ function emphasisOrStrongStyleFor(markup) { }; /** - * @param {import("./markdownlint.mjs").RuleParams} params Rule parameters. - * @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback. + * @param {import("markdownlint").RuleParams} params Rule parameters. + * @param {import("markdownlint").RuleOnError} onError Error-reporting callback. * @param {import("micromark-util-types").TokenType} type Token type. * @param {import("micromark-util-types").TokenType} typeSequence Token sequence type. * @param {"*" | "**"} asterisk Asterisk kind. @@ -76,7 +76,7 @@ const impl = } }; -/** @type {import("./markdownlint.mjs").Rule[]} */ +/** @type {import("markdownlint").Rule[]} */ export default [ { "names": [ "MD049", "emphasis-style" ], diff --git a/lib/md051.mjs b/lib/md051.mjs index 51a40c7f7..65e51a9e9 100644 --- a/lib/md051.mjs +++ b/lib/md051.mjs @@ -20,7 +20,7 @@ const tokensInclude = new Set( * Converts a Markdown heading into an HTML fragment according to the rules * used by GitHub. * - * @param {import("../helpers/micromark-helpers.cjs").Token} headingText Heading text token. + * @param {import("markdownlint").MicromarkToken} headingText Heading text token. * @returns {string} Fragment string for heading. */ function convertHeadingToHTMLFragment(headingText) { @@ -49,7 +49,7 @@ function convertHeadingToHTMLFragment(headingText) { /** * Unescapes the text of a String-type micromark Token. * - * @param {import("../helpers/micromark-helpers.cjs").Token} token String-type micromark Token. + * @param {import("markdownlint").MicromarkToken} token String-type micromark Token. * @returns {string} Unescaped token text. */ function unescapeStringTokenText(token) { @@ -58,7 +58,7 @@ function unescapeStringTokenText(token) { .join(""); } -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD051", "link-fragments" ], "description": "Link fragments should be valid", @@ -101,7 +101,7 @@ export default { } // Process link and definition fragments - /** @type {import("../helpers/micromark-helpers.cjs").TokenType[][]} */ + /** @type {import("markdownlint").MicromarkTokenType[][]} */ const parentChilds = [ [ "link", "resourceDestinationString" ], [ "definition", "definitionDestinationString" ] diff --git a/lib/md052.mjs b/lib/md052.mjs index 883ea256c..975c45c67 100644 --- a/lib/md052.mjs +++ b/lib/md052.mjs @@ -3,7 +3,7 @@ import { addError } from "../helpers/helpers.cjs"; import { getReferenceLinkImageData } from "./cache.mjs"; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD052", "reference-links-images" ], "description": diff --git a/lib/md053.mjs b/lib/md053.mjs index fc724b73e..4ee3f82d4 100644 --- a/lib/md053.mjs +++ b/lib/md053.mjs @@ -5,7 +5,7 @@ import { getReferenceLinkImageData } from "./cache.mjs"; const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])\]:/; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD053", "link-image-reference-definitions" ], "description": "Link and image reference definitions should be needed", diff --git a/lib/md054.mjs b/lib/md054.mjs index ec509a476..37f88193a 100644 --- a/lib/md054.mjs +++ b/lib/md054.mjs @@ -18,7 +18,7 @@ const autolinkAble = (destination) => { return !autolinkDisallowedRe.test(destination); }; -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD054", "link-image-style" ], "description": "Link and image style", diff --git a/lib/md055.mjs b/lib/md055.mjs index 10b1f281f..ed6c26b53 100644 --- a/lib/md055.mjs +++ b/lib/md055.mjs @@ -13,7 +13,7 @@ const makeRange = (start, end) => [ start, end - start + 1 ]; /** @typedef {import("micromark-extension-gfm-table")} */ -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD055", "table-pipe-style" ], "description": "Table pipe style", diff --git a/lib/md056.mjs b/lib/md056.mjs index d6f1a32b1..c1da47c15 100644 --- a/lib/md056.mjs +++ b/lib/md056.mjs @@ -8,7 +8,7 @@ const makeRange = (start, end) => [ start, end - start + 1 ]; /** @typedef {import("micromark-extension-gfm-table")} */ -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD056", "table-column-count" ], "description": "Table column count", diff --git a/lib/md058.mjs b/lib/md058.mjs index 4c1ee28f3..4d00857a3 100644 --- a/lib/md058.mjs +++ b/lib/md058.mjs @@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs"; /** @typedef {import("micromark-extension-gfm-table")} */ -/** @type {import("./markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ export default { "names": [ "MD058", "blanks-around-tables" ], "description": "Tables should be surrounded by blank lines", diff --git a/lib/micromark-parse.mjs b/lib/micromark-parse.mjs index afa496405..d848f5d1d 100644 --- a/lib/micromark-parse.mjs +++ b/lib/micromark-parse.mjs @@ -17,8 +17,8 @@ import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "../helpers/shared.c /** @typedef {import("micromark-util-types").State} State */ /** @typedef {import("micromark-util-types").Token} Token */ /** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */ +/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ /** @typedef {import("./micromark-types.d.mts")} */ -/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} MicromarkToken */ /** * Parse options. diff --git a/lib/types.d.mts b/lib/types.d.mts new file mode 100644 index 000000000..2ca3e4d35 --- /dev/null +++ b/lib/types.d.mts @@ -0,0 +1,12 @@ +declare module "markdownlint" { + export * from "./exports.mjs"; +} +declare module "markdownlint/async" { + export * from "./exports-async.mjs"; +} +declare module "markdownlint/promise" { + export * from "./exports-promise.mjs"; +} +declare module "markdownlint/sync" { + export * from "./exports-sync.mjs"; +} diff --git a/package.json b/package.json index ce1dad348..851dbc5cf 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,17 @@ "description": "A Node.js style checker and lint tool for Markdown/CommonMark files.", "type": "module", "exports": { - ".": "./lib/markdownlint.mjs", + ".": "./lib/exports.mjs", + "./async": "./lib/exports-async.mjs", + "./promise": "./lib/exports-promise.mjs", + "./sync": "./lib/exports-sync.mjs", "./helpers": "./helpers/helpers.cjs", "./style/all": "./style/all.json", "./style/cirosantilli": "./style/cirosantilli.json", "./style/prettier": "./style/prettier.json", "./style/relaxed": "./style/relaxed.json" }, - "types": "./lib/markdownlint.d.mts", + "types": "./lib/types.d.mts", "author": "David Anson (https://dlaa.me/)", "license": "MIT", "homepage": "https://github.com/DavidAnson/markdownlint", @@ -25,7 +28,7 @@ "build-config": "npm run build-config-schema && npm run build-config-example", "build-config-example": "node schema/build-config-example.mjs", "build-config-schema": "node schema/build-config-schema.mjs", - "build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module nodenext --outDir dts --target es2015 lib/markdownlint.mjs && node scripts/index.mjs copy dts/lib/markdownlint.d.mts lib/markdownlint.d.mts && node scripts/index.mjs remove dts", + "build-declaration": "tsc --allowJs --checkJs --declaration --emitDeclarationOnly --module nodenext --outDir dts --rootDir . --target es2015 lib/exports.mjs lib/exports-async.mjs lib/exports-promise.mjs lib/exports-sync.mjs lib/markdownlint.mjs && node scripts/index.mjs copy dts/lib/exports.d.mts lib/exports.d.mts && node scripts/index.mjs copy dts/lib/exports-async.d.mts lib/exports-async.d.mts && node scripts/index.mjs copy dts/lib/exports-promise.d.mts lib/exports-promise.d.mts && node scripts/index.mjs copy dts/lib/exports-sync.d.mts lib/exports-sync.d.mts && node scripts/index.mjs copy dts/lib/markdownlint.d.mts lib/markdownlint.d.mts && node scripts/index.mjs remove dts", "build-demo": "node scripts/index.mjs copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && cd demo && webpack --no-stats", "build-docs": "node doc-build/build-rules.mjs", "build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2", diff --git a/schema/build-config-schema.mjs b/schema/build-config-schema.mjs index ee91cbece..dd4a9bcaa 100644 --- a/schema/build-config-schema.mjs +++ b/schema/build-config-schema.mjs @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import path from "node:path"; -/** @type {import("../lib/markdownlint.mjs").Rule[]} */ +/** @type {import("markdownlint").Rule[]} */ import rules from "../lib/rules.mjs"; import jsonSchemaToTypeScript from "json-schema-to-typescript"; import { version } from "../lib/constants.mjs"; diff --git a/test/harness.mjs b/test/harness.mjs index e9eebe423..92ae78012 100644 --- a/test/harness.mjs +++ b/test/harness.mjs @@ -1,7 +1,6 @@ import { readFile } from "node:fs/promises"; +import { lint } from "markdownlint/promise"; import { parse } from "../lib/micromark-parse.mjs"; -import library from "../lib/markdownlint.mjs"; -const markdownlint = library.promises.markdownlint; /* eslint-disable no-await-in-loop, no-console */ @@ -43,7 +42,7 @@ for (const file of files) { let results = null; performance.mark("profile-start"); for (let i = 0; i < count; i++) { - results = await markdownlint({ + results = await lint({ "files": [ file ] }); } diff --git a/test/markdownlint-test-config.mjs b/test/markdownlint-test-config.mjs index e421661f0..524e095f4 100644 --- a/test/markdownlint-test-config.mjs +++ b/test/markdownlint-test-config.mjs @@ -6,14 +6,16 @@ const require = createRequire(import.meta.url); import os from "node:os"; import path from "node:path"; import test from "ava"; -import markdownlint from "../lib/markdownlint.mjs"; +import { readConfig as readConfigAsync } from "markdownlint/async"; +import { extendConfig, readConfig as readConfigPromise } from "markdownlint/promise"; +import { readConfig as readConfigSync } from "markdownlint/sync"; import { __dirname } from "./esm-helpers.mjs"; const sameFileSystem = (path.relative(os.homedir(), __dirname(import.meta)) !== __dirname(import.meta)); test("configSingle", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig("./test/config/config-child.json", + readConfigAsync("./test/config/config-child.json", function callback(err, actual) { t.falsy(err); const expected = require("./config/config-child.json"); @@ -24,7 +26,7 @@ test("configSingle", (t) => new Promise((resolve) => { test("configAbsolute", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig(path.join(__dirname(import.meta), "config", "config-child.json"), + readConfigAsync(path.join(__dirname(import.meta), "config", "config-child.json"), function callback(err, actual) { t.falsy(err); const expected = require("./config/config-child.json"); @@ -36,7 +38,7 @@ test("configAbsolute", (t) => new Promise((resolve) => { if (sameFileSystem) { test("configTilde", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig( + readConfigAsync( `~/${path.relative(os.homedir(), "./test/config/config-child.json")}`, function callback(err, actual) { t.falsy(err); @@ -49,7 +51,7 @@ if (sameFileSystem) { test("configMultiple", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig("./test/config/config-grandparent.json", + readConfigAsync("./test/config/config-grandparent.json", function callback(err, actual) { t.falsy(err); const expected = { @@ -66,7 +68,7 @@ test("configMultiple", (t) => new Promise((resolve) => { test("configMultipleWithRequireResolve", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig("./test/config/config-packageparent.json", + readConfigAsync("./test/config/config-packageparent.json", function callback(err, actual) { t.falsy(err); const expected = { @@ -108,7 +110,7 @@ test("configCustomFileSystem", (t) => new Promise((resolve) => { return t.fail(p); } }; - markdownlint.readConfig( + readConfigAsync( file, // @ts-ignore null, @@ -128,7 +130,7 @@ test("configCustomFileSystem", (t) => new Promise((resolve) => { test("configBadFile", (t) => new Promise((resolve) => { t.plan(4); - markdownlint.readConfig("./test/config/config-badfile.json", + readConfigAsync("./test/config/config-badfile.json", function callback(err, result) { t.truthy(err, "Did not get an error for bad file."); t.true(err instanceof Error, "Error not instance of Error."); @@ -141,7 +143,7 @@ test("configBadFile", (t) => new Promise((resolve) => { test("configBadChildFile", (t) => new Promise((resolve) => { t.plan(4); - markdownlint.readConfig("./test/config/config-badchildfile.json", + readConfigAsync("./test/config/config-badchildfile.json", function callback(err, result) { t.truthy(err, "Did not get an error for bad child file."); t.true(err instanceof Error, "Error not instance of Error."); @@ -155,7 +157,7 @@ test("configBadChildFile", (t) => new Promise((resolve) => { test("configBadChildPackage", (t) => new Promise((resolve) => { t.plan(4); - markdownlint.readConfig("./test/config/config-badchildpackage.json", + readConfigAsync("./test/config/config-badchildpackage.json", function callback(err, result) { t.truthy(err, "Did not get an error for bad child package."); t.true(err instanceof Error, "Error not instance of Error."); @@ -169,7 +171,7 @@ test("configBadChildPackage", (t) => new Promise((resolve) => { test("configBadJson", (t) => new Promise((resolve) => { t.plan(3); - markdownlint.readConfig("./test/config/config-badjson.json", + readConfigAsync("./test/config/config-badjson.json", function callback(err, result) { t.truthy(err, "Did not get an error for bad JSON."); t.true(err instanceof Error, "Error not instance of Error."); @@ -180,7 +182,7 @@ test("configBadJson", (t) => new Promise((resolve) => { test("configBadChildJson", (t) => new Promise((resolve) => { t.plan(3); - markdownlint.readConfig("./test/config/config-badchildjson.json", + readConfigAsync("./test/config/config-badchildjson.json", function callback(err, result) { t.truthy(err, "Did not get an error for bad child JSON."); t.true(err instanceof Error, "Error not instance of Error."); @@ -191,7 +193,7 @@ test("configBadChildJson", (t) => new Promise((resolve) => { test("configSingleYaml", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig( + readConfigAsync( "./test/config/config-child.yaml", // @ts-ignore [ require("js-yaml").load ], @@ -205,7 +207,7 @@ test("configSingleYaml", (t) => new Promise((resolve) => { test("configMultipleYaml", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig( + readConfigAsync( "./test/config/config-grandparent.yaml", // @ts-ignore [ require("js-yaml").load ], @@ -225,7 +227,7 @@ test("configMultipleYaml", (t) => new Promise((resolve) => { test("configMultipleHybrid", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.readConfig( + readConfigAsync( "./test/config/config-grandparent-hybrid.yaml", // @ts-ignore [ JSON.parse, require("toml").parse, require("js-yaml").load ], @@ -245,7 +247,7 @@ test("configMultipleHybrid", (t) => new Promise((resolve) => { test("configBadHybrid", (t) => new Promise((resolve) => { t.plan(4); - markdownlint.readConfig( + readConfigAsync( "./test/config/config-badcontent.txt", // @ts-ignore [ JSON.parse, require("toml").parse, require("js-yaml").load ], @@ -262,14 +264,14 @@ test("configBadHybrid", (t) => new Promise((resolve) => { test("configSingleSync", (t) => { t.plan(1); - const actual = markdownlint.readConfigSync("./test/config/config-child.json"); + const actual = readConfigSync("./test/config/config-child.json"); const expected = require("./config/config-child.json"); t.deepEqual(actual, expected, "Config object not correct."); }); test("configAbsoluteSync", (t) => { t.plan(1); - const actual = markdownlint.readConfigSync( + const actual = readConfigSync( path.join(__dirname(import.meta), "config", "config-child.json")); const expected = require("./config/config-child.json"); t.deepEqual(actual, expected, "Config object not correct."); @@ -278,7 +280,7 @@ test("configAbsoluteSync", (t) => { if (sameFileSystem) { test("configTildeSync", (t) => { t.plan(1); - const actual = markdownlint.readConfigSync( + const actual = readConfigSync( `~/${path.relative(os.homedir(), "./test/config/config-child.json")}`); const expected = require("./config/config-child.json"); t.deepEqual(actual, expected, "Config object not correct."); @@ -288,7 +290,7 @@ if (sameFileSystem) { test("configMultipleSync", (t) => { t.plan(1); const actual = - markdownlint.readConfigSync("./test/config/config-grandparent.json"); + readConfigSync("./test/config/config-grandparent.json"); const expected = { ...require("./config/config-child.json"), ...require("./config/config-parent.json"), @@ -303,7 +305,7 @@ test("configBadFileSync", (t) => { t.plan(1); t.throws( function badFileCall() { - markdownlint.readConfigSync("./test/config/config-badfile.json"); + readConfigSync("./test/config/config-badfile.json"); }, { "message": /ENOENT/ @@ -316,7 +318,7 @@ test("configBadChildFileSync", (t) => { t.plan(1); t.throws( function badChildFileCall() { - markdownlint.readConfigSync("./test/config/config-badchildfile.json"); + readConfigSync("./test/config/config-badchildfile.json"); }, { "message": /ENOENT/ @@ -329,7 +331,7 @@ test("configBadJsonSync", (t) => { t.plan(1); t.throws( function badJsonCall() { - markdownlint.readConfigSync("./test/config/config-badjson.json"); + readConfigSync("./test/config/config-badjson.json"); }, { "message": @@ -343,7 +345,7 @@ test("configBadChildJsonSync", (t) => { t.plan(1); t.throws( function badChildJsonCall() { - markdownlint.readConfigSync("./test/config/config-badchildjson.json"); + readConfigSync("./test/config/config-badchildjson.json"); }, { "message": @@ -355,7 +357,7 @@ test("configBadChildJsonSync", (t) => { test("configSingleYamlSync", (t) => { t.plan(1); - const actual = markdownlint.readConfigSync( + const actual = readConfigSync( // @ts-ignore "./test/config/config-child.yaml", [ require("js-yaml").load ]); const expected = require("./config/config-child.json"); @@ -364,7 +366,7 @@ test("configSingleYamlSync", (t) => { test("configMultipleYamlSync", (t) => { t.plan(1); - const actual = markdownlint.readConfigSync( + const actual = readConfigSync( // @ts-ignore "./test/config/config-grandparent.yaml", [ require("js-yaml").load ]); const expected = { @@ -379,7 +381,7 @@ test("configMultipleYamlSync", (t) => { test("configMultipleHybridSync", (t) => { t.plan(1); - const actual = markdownlint.readConfigSync( + const actual = readConfigSync( "./test/config/config-grandparent-hybrid.yaml", // @ts-ignore [ JSON.parse, require("toml").parse, require("js-yaml").load ]); @@ -420,7 +422,7 @@ test("configCustomFileSystemSync", (t) => { return t.fail(p); } }; - const actual = markdownlint.readConfigSync(file, undefined, fsApi); + const actual = readConfigSync(file, undefined, fsApi); const expected = { ...extendedContent, ...fileContent @@ -434,7 +436,7 @@ test("configBadHybridSync", (t) => { t.plan(1); t.throws( function badHybridCall() { - markdownlint.readConfigSync( + readConfigSync( "./test/config/config-badcontent.txt", // @ts-ignore [ JSON.parse, require("toml").parse, require("js-yaml").load ]); @@ -448,7 +450,7 @@ test("configBadHybridSync", (t) => { test("configSinglePromise", (t) => new Promise((resolve) => { t.plan(1); - markdownlint.promises.readConfig("./test/config/config-child.json") + readConfigPromise("./test/config/config-child.json") .then((actual) => { const expected = require("./config/config-child.json"); t.deepEqual(actual, expected, "Config object not correct."); @@ -487,7 +489,7 @@ test("configCustomFileSystemPromise", (t) => new Promise((resolve) => { } } }; - markdownlint.promises.readConfig(file, undefined, fsApi) + readConfigPromise(file, undefined, fsApi) .then((actual) => { const expected = { ...extendedContent, @@ -502,7 +504,7 @@ test("configCustomFileSystemPromise", (t) => new Promise((resolve) => { test("configBadFilePromise", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.promises.readConfig("./test/config/config-badfile.json") + readConfigPromise("./test/config/config-badfile.json") .then( null, (error) => { @@ -516,7 +518,7 @@ test("configBadFilePromise", (t) => new Promise((resolve) => { test("extendSinglePromise", (t) => new Promise((resolve) => { t.plan(1); const expected = require("./config/config-child.json"); - markdownlint.promises.extendConfig( + extendConfig( expected, "./test/config/config-child.json", undefined, @@ -530,7 +532,7 @@ test("extendSinglePromise", (t) => new Promise((resolve) => { test("extendBadPromise", (t) => new Promise((resolve) => { t.plan(2); - markdownlint.promises.extendConfig( + extendConfig( { "extends": "missing.json" }, @@ -576,7 +578,7 @@ test("extendCustomFileSystemPromise", (t) => new Promise((resolve) => { } } }; - markdownlint.promises.extendConfig(fileContent, file, undefined, fsApi) + extendConfig(fileContent, file, undefined, fsApi) .then((actual) => { t.truthy(fileContent.extends); const expected = { diff --git a/test/markdownlint-test-custom-rules.mjs b/test/markdownlint-test-custom-rules.mjs index c6cf367d5..9e640f1f0 100644 --- a/test/markdownlint-test-custom-rules.mjs +++ b/test/markdownlint-test-custom-rules.mjs @@ -4,7 +4,9 @@ import fs from "node:fs/promises"; import { createRequire } from "node:module"; const require = createRequire(import.meta.url); import test from "ava"; -import markdownlint from "../lib/markdownlint.mjs"; +import { lint as lintAsync } from "markdownlint/async"; +import { lint as lintPromise } from "markdownlint/promise"; +import { lint as lintSync } from "markdownlint/sync"; import customRules from "./rules/rules.cjs"; import { newLineRe } from "../helpers/helpers.cjs"; import { __filename, importWithTypeJson } from "./esm-helpers.mjs"; @@ -14,13 +16,13 @@ const { homepage, version } = packageJson; test("customRulesV0", (t) => new Promise((resolve) => { t.plan(4); const customRulesMd = "./test/custom-rules.md"; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": customRules.all, "files": [ customRulesMd ], "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = {}; expectedResult[customRulesMd] = { @@ -86,13 +88,13 @@ test("customRulesV0", (t) => new Promise((resolve) => { test("customRulesV1", (t) => new Promise((resolve) => { t.plan(3); const customRulesMd = "./test/custom-rules.md"; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": customRules.all, "files": [ customRulesMd ], "resultVersion": 1 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = {}; expectedResult[customRulesMd] = [ @@ -217,13 +219,13 @@ test("customRulesV1", (t) => new Promise((resolve) => { test("customRulesV2", (t) => new Promise((resolve) => { t.plan(3); const customRulesMd = "./test/custom-rules.md"; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": customRules.all, "files": [ customRulesMd ], "resultVersion": 2 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = {}; expectedResult[customRulesMd] = [ @@ -338,7 +340,7 @@ test("customRulesV2", (t) => new Promise((resolve) => { test("customRulesConfig", (t) => new Promise((resolve) => { t.plan(2); const customRulesMd = "./test/custom-rules.md"; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": customRules.all, "files": [ customRulesMd ], @@ -351,7 +353,7 @@ test("customRulesConfig", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = {}; expectedResult[customRulesMd] = { @@ -368,7 +370,7 @@ test("customRulesConfig", (t) => new Promise((resolve) => { test("customRulesNpmPackage", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ require("./rules/npm"), @@ -379,7 +381,7 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = {}; expectedResult.string = { @@ -431,13 +433,13 @@ test("customRulesBadProperty", (t) => { for (const propertyValue of propertyValues) { const badRule = { ...customRules.firstLine }; badRule[propertyName] = propertyValue; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ badRule ] }; t.throws( function badRuleCall() { - markdownlint.sync(options); + lintSync(options); }, { "message": @@ -451,8 +453,8 @@ test("customRulesBadProperty", (t) => { test("customRulesUsedNameName", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name", "NO-missing-SPACE-atx" ], @@ -477,8 +479,8 @@ test("customRulesUsedNameName", (t) => new Promise((resolve) => { test("customRulesUsedNameTag", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name", "HtMl" ], @@ -502,8 +504,8 @@ test("customRulesUsedNameTag", (t) => new Promise((resolve) => { test("customRulesUsedTagName", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "filler" ], @@ -535,7 +537,7 @@ test("customRulesUsedTagName", (t) => new Promise((resolve) => { test("customRulesParserUndefined", (t) => { t.plan(5); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ // @ts-ignore @@ -557,12 +559,12 @@ test("customRulesParserUndefined", (t) => { "string": "# Heading\n" } }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesParserNone", (t) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -581,12 +583,12 @@ test("customRulesParserNone", (t) => { "string": "# Heading\n" } }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesParserMarkdownIt", (t) => { t.plan(5); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -608,12 +610,12 @@ test("customRulesParserMarkdownIt", (t) => { "string": "# Heading\n" } }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesParserMicromark", (t) => { t.plan(5); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -635,12 +637,12 @@ test("customRulesParserMicromark", (t) => { "string": "# Heading\n" } }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesMarkdownItParamsTokensSameObject", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ // @ts-ignore @@ -659,12 +661,12 @@ test("customRulesMarkdownItParamsTokensSameObject", (t) => { "string": "# Heading\n" } }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesMarkdownItTokensSnapshot", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -684,13 +686,13 @@ test("customRulesMarkdownItTokensSnapshot", (t) => { .readFile("./test/every-markdown-syntax.md", "utf8") .then((content) => { options.strings = { "content": content.split(newLineRe).join("\n") }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); }); test("customRulesMicromarkTokensSnapshot", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -710,13 +712,13 @@ test("customRulesMicromarkTokensSnapshot", (t) => { .readFile("./test/every-markdown-syntax.md", "utf8") .then((content) => { options.strings = { "content": content.split(newLineRe).join("\n") }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); }); test("customRulesDefinitionStatic", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -741,7 +743,7 @@ test("customRulesDefinitionStatic", (t) => new Promise((resolve) => { "string": "# Heading\n" } }; - markdownlint(options, (err, actualResult) => { + lintAsync(options, (err, actualResult) => { t.falsy(err); const expectedResult = { "string": [ @@ -765,8 +767,8 @@ test("customRulesDefinitionStatic", (t) => new Promise((resolve) => { test("customRulesThrowForFile", (t) => new Promise((resolve) => { t.plan(4); const exceptionMessage = "Test exception message"; - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -795,8 +797,8 @@ test("customRulesThrowForFileSync", (t) => { const exceptionMessage = "Test exception message"; t.throws( function customRuleThrowsCall() { - markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -821,8 +823,8 @@ test("customRulesThrowForFileSync", (t) => { test("customRulesThrowForString", (t) => new Promise((resolve) => { t.plan(4); const exceptionMessage = "Test exception message"; - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -853,8 +855,8 @@ test("customRulesThrowForStringSync", (t) => { const exceptionMessage = "Test exception message"; t.throws( function customRuleThrowsCall() { - markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -880,8 +882,8 @@ test("customRulesThrowForStringSync", (t) => { test("customRulesOnErrorNull", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -914,7 +916,7 @@ test("customRulesOnErrorNull", (t) => new Promise((resolve) => { test("customRulesOnErrorNullSync", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -934,7 +936,7 @@ test("customRulesOnErrorNullSync", (t) => { }; t.throws( function nullErrorCall() { - markdownlint.sync(options); + lintSync(options); }, { "message": "Value of 'lineNumber' passed to onError by 'NAME' is incorrect for 'string'." @@ -1005,7 +1007,7 @@ test("customRulesOnErrorBad", (t) => { badObject[propertyName] = propertyValue; propertyNames = propertyName; } - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1024,7 +1026,7 @@ test("customRulesOnErrorBad", (t) => { }; t.throws( function badErrorCall() { - markdownlint.sync(options); + lintSync(options); }, { "message": @@ -1077,7 +1079,7 @@ test("customRulesOnErrorInvalid", (t) => { badObject[propertyName] = propertyValue; propertyNames = propertyName; } - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1096,7 +1098,7 @@ test("customRulesOnErrorInvalid", (t) => { }; t.throws( function invalidErrorCall() { - markdownlint.sync(options); + lintSync(options); }, { "message": @@ -1152,7 +1154,7 @@ test("customRulesOnErrorValid", (t) => { } else { goodObject[propertyName] = propertyValue; } - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1169,7 +1171,7 @@ test("customRulesOnErrorValid", (t) => { "string": "Text\ntext" } }; - markdownlint.sync(options); + lintSync(options); t.truthy(true); } } @@ -1177,7 +1179,7 @@ test("customRulesOnErrorValid", (t) => { test("customRulesOnErrorLazy", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1199,7 +1201,7 @@ test("customRulesOnErrorLazy", (t) => new Promise((resolve) => { "string": "# Heading\n" } }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "string": [ @@ -1234,7 +1236,7 @@ test("customRulesOnErrorModified", (t) => new Promise((resolve) => { "insertText": "text" } }; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1259,7 +1261,7 @@ test("customRulesOnErrorModified", (t) => new Promise((resolve) => { "string": "# Heading\n" } }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "string": [ @@ -1286,8 +1288,8 @@ test("customRulesOnErrorModified", (t) => new Promise((resolve) => { test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + lintAsync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1329,8 +1331,8 @@ test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => { test("customRulesOnErrorInvalidHandledSync", (t) => { t.plan(1); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1370,7 +1372,7 @@ test("customRulesOnErrorInvalidHandledSync", (t) => { test("customRulesVersion", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1385,7 +1387,7 @@ test("customRulesVersion", (t) => new Promise((resolve) => { ], "files": "doc/CustomRules.md" }; - markdownlint(options, function callback(err) { + lintAsync(options, function callback(err) { t.falsy(err); resolve(); }); @@ -1393,7 +1395,7 @@ test("customRulesVersion", (t) => new Promise((resolve) => { test("customRulesFileName", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1408,7 +1410,7 @@ test("customRulesFileName", (t) => new Promise((resolve) => { ], "files": "doc/CustomRules.md" }; - markdownlint(options, function callback(err) { + lintAsync(options, function callback(err) { t.falsy(err); resolve(); }); @@ -1416,7 +1418,7 @@ test("customRulesFileName", (t) => new Promise((resolve) => { test("customRulesStringName", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1433,7 +1435,7 @@ test("customRulesStringName", (t) => new Promise((resolve) => { "string": "# Heading" } }; - markdownlint(options, function callback(err) { + lintAsync(options, function callback(err) { t.falsy(err); resolve(); }); @@ -1441,8 +1443,8 @@ test("customRulesStringName", (t) => new Promise((resolve) => { test("customRulesOnErrorInformationNotRuleNotError", (t) => { t.plan(1); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1465,8 +1467,8 @@ test("customRulesOnErrorInformationNotRuleNotError", (t) => { test("customRulesOnErrorInformationRuleNotError", (t) => { t.plan(1); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1494,8 +1496,8 @@ test("customRulesOnErrorInformationRuleNotError", (t) => { test("customRulesOnErrorInformationNotRuleError", (t) => { t.plan(1); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1523,8 +1525,8 @@ test("customRulesOnErrorInformationNotRuleError", (t) => { test("customRulesOnErrorInformationRuleError", (t) => { t.plan(1); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1553,8 +1555,8 @@ test("customRulesOnErrorInformationRuleError", (t) => { test("customRulesOnErrorInformationRuleErrorUndefined", (t) => { t.plan(1); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1583,8 +1585,8 @@ test("customRulesOnErrorInformationRuleErrorUndefined", (t) => { test("customRulesOnErrorInformationRuleErrorMultiple", (t) => { t.plan(6); - const actualResult = markdownlint.sync({ - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + const actualResult = lintSync({ + /** @type {import("markdownlint").Rule[]} */ "customRules": [ { "names": [ "name" ], @@ -1645,7 +1647,7 @@ test("customRulesOnErrorInformationRuleErrorMultiple", (t) => { test("customRulesDoc", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "files": "./doc/CustomRules.md", "config": { "MD013": { "line_length": 200 } @@ -1660,12 +1662,12 @@ test("customRulesDoc", (t) => new Promise((resolve) => { test("customRulesLintJavaScript", (t) => new Promise((resolve) => { t.plan(2); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": customRules.lintJavaScript, "files": "test/lint-javascript.md" }; - markdownlint(options, (err, actual) => { + lintAsync(options, (err, actual) => { t.falsy(err); const expected = { "test/lint-javascript.md": [ @@ -1688,12 +1690,12 @@ test("customRulesLintJavaScript", (t) => new Promise((resolve) => { test("customRulesValidateJson", (t) => new Promise((resolve) => { t.plan(3); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": customRules.validateJson, "files": "test/validate-json.md" }; - markdownlint(options, (err, actual) => { + lintAsync(options, (err, actual) => { t.falsy(err); const expected = { "test/validate-json.md": [ @@ -1721,7 +1723,7 @@ test("customRulesValidateJson", (t) => new Promise((resolve) => { test("customRulesAsyncThrowsInSyncContext", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1738,7 +1740,7 @@ test("customRulesAsyncThrowsInSyncContext", (t) => { } }; t.throws( - () => markdownlint.sync(options), + () => lintSync(options), { "message": "Custom rule name1/name2 at index 0 is asynchronous and " + "can not be used in a synchronous context." @@ -1765,7 +1767,7 @@ test("customRulesParamsAreFrozen", (t) => { } } }; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1792,14 +1794,14 @@ test("customRulesParamsAreFrozen", (t) => { ], "files": [ "README.md" ] }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesParamsAreStable", (t) => { t.plan(4); const config1 = { "value1": 10 }; const config2 = { "value2": 20 }; - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "config": { "MD010": true, @@ -1860,12 +1862,12 @@ test("customRulesParamsAreStable", (t) => { "string": "# Heading" } }; - return markdownlint.promises.markdownlint(options).then(() => null); + return lintPromise(options).then(() => null); }); test("customRulesAsyncReadFiles", (t) => { t.plan(3); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1947,13 +1949,13 @@ test("customRulesAsyncReadFiles", (t) => { } ] }; - return markdownlint.promises.markdownlint(options) + return lintPromise(options) .then((actual) => t.deepEqual(actual, expected, "Unexpected issues.")); }); test("customRulesAsyncIgnoresSyncReturn", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -2011,7 +2013,7 @@ test("customRulesAsyncIgnoresSyncReturn", (t) => { } ] }; - return markdownlint.promises.markdownlint(options) + return lintPromise(options) .then((actual) => t.deepEqual(actual, expected, "Unexpected issues.")); }); @@ -2044,7 +2046,7 @@ for (const flavor of [ ] ]) { const [ name, func ] = flavor; - /** @type {import("../lib/markdownlint.mjs").Rule[]} */ + /** @type {import("markdownlint").Rule[]} */ const customRule = [ { "names": [ "name" ], @@ -2074,7 +2076,7 @@ for (const flavor of [ test(`${name}${subname}UnhandledAsync`, (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ + lintAsync({ // @ts-ignore "customRules": customRule, // @ts-ignore @@ -2093,7 +2095,7 @@ for (const flavor of [ test(`${name}${subname}HandledAsync`, (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ // @ts-ignore "customRules": customRule, // @ts-ignore @@ -2111,7 +2113,7 @@ for (const flavor of [ test(`${name}${subname}UnhandledSync`, (t) => { t.plan(1); t.throws( - () => markdownlint.sync({ + () => lintSync({ // @ts-ignore "customRules": customRule, // @ts-ignore @@ -2128,7 +2130,7 @@ for (const flavor of [ test(`${name}${subname}HandledSync`, (t) => { t.plan(1); - const actualResult = markdownlint.sync({ + const actualResult = lintSync({ // @ts-ignore "customRules": customRule, // @ts-ignore @@ -2181,7 +2183,7 @@ for (const flavor of [ ] ]) { const [ name, func ] = flavor; - /** @type {import("../lib/markdownlint.mjs").Rule} */ + /** @type {import("markdownlint").Rule} */ const customRule = { "names": [ "name" ], "description": "description", @@ -2196,7 +2198,7 @@ for (const flavor of [ test(`${name}${subname}Unhandled`, (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ + lintAsync({ // @ts-ignore "customRules": [ customRule ], // @ts-ignore @@ -2215,7 +2217,7 @@ for (const flavor of [ test(`${name}${subname}Handled`, (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ // @ts-ignore "customRules": [ customRule ], // @ts-ignore diff --git a/test/markdownlint-test-extra-parse.mjs b/test/markdownlint-test-extra-parse.mjs index 976014484..84fe3de31 100644 --- a/test/markdownlint-test-extra-parse.mjs +++ b/test/markdownlint-test-extra-parse.mjs @@ -2,12 +2,12 @@ import test from "ava"; import { globby } from "globby"; -import markdownlint from "../lib/markdownlint.mjs"; +import { lint } from "markdownlint/promise"; // Parses all Markdown files in all package dependencies test("parseAllFiles", async(t) => { t.plan(1); const files = await globby("**/*.{md,markdown}"); - await markdownlint.promises.markdownlint({ files }); + await lint({ files }); t.pass(); }); diff --git a/test/markdownlint-test-extra-type.mjs b/test/markdownlint-test-extra-type.mjs index e18b36cb0..f5b0c2308 100644 --- a/test/markdownlint-test-extra-type.mjs +++ b/test/markdownlint-test-extra-type.mjs @@ -3,7 +3,7 @@ import fs from "node:fs"; import path from "node:path"; import test from "ava"; -import markdownlint from "../lib/markdownlint.mjs"; +import { lint } from "markdownlint/sync"; // Simulates typing each test file to validate handling of partial input const files = fs @@ -18,7 +18,7 @@ for (const file of files) { } test.serial(`type ${file}`, (t) => { t.plan(1); - markdownlint.sync({ + lint({ // @ts-ignore strings, "resultVersion": 0 diff --git a/test/markdownlint-test-fixes.mjs b/test/markdownlint-test-fixes.mjs index 4db880d32..6cf6407da 100644 --- a/test/markdownlint-test-fixes.mjs +++ b/test/markdownlint-test-fixes.mjs @@ -1,7 +1,7 @@ // @ts-check import test from "ava"; -import markdownlint from "../lib/markdownlint.mjs"; +import { applyFix, applyFixes } from "markdownlint"; test("applyFix", (t) => { t.plan(4); @@ -46,7 +46,7 @@ test("applyFix", (t) => { for (const testCase of testCases) { const [ line, fixInfo, lineEnding, expected ] = testCase; // @ts-ignore - const actual = markdownlint.applyFix(line, fixInfo, lineEnding); + const actual = applyFix(line, fixInfo, lineEnding); t.is(actual, String(expected), "Incorrect fix applied."); } }); @@ -524,7 +524,7 @@ test("applyFixes", (t) => { for (const testCase of testCases) { const [ input, errors, expected ] = testCase; // @ts-ignore - const actual = markdownlint.applyFixes(input, errors); + const actual = applyFixes(input, errors); t.is(actual, String(expected), "Incorrect fix applied."); } }); diff --git a/test/markdownlint-test-helpers.mjs b/test/markdownlint-test-helpers.mjs index 0284e859d..64ff908f6 100644 --- a/test/markdownlint-test-helpers.mjs +++ b/test/markdownlint-test-helpers.mjs @@ -6,8 +6,7 @@ import test from "ava"; import { characterEntities } from "character-entities"; import { gemoji } from "gemoji"; import helpers from "../helpers/helpers.cjs"; -import libMarkdownlint from "../lib/markdownlint.mjs"; -const { markdownlint } = libMarkdownlint.promises; +import { lint } from "markdownlint/promise"; import { forEachInlineCodeSpan } from "../lib/markdownit.cjs"; import { getReferenceLinkImageData } from "../lib/cache.mjs"; @@ -387,7 +386,7 @@ test("expandTildePath", (t) => { test("getReferenceLinkImageData().shortcuts", (t) => { t.plan(1); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -415,7 +414,7 @@ Empty bracket pair: [text4[]] ` } }; - return markdownlint(options).then(() => null); + return lint(options).then(() => null); }); test("endOfLineHtmlEntityRe", (t) => { diff --git a/test/markdownlint-test-parallel.mjs b/test/markdownlint-test-parallel.mjs index 615b464e6..e9bc26c0c 100644 --- a/test/markdownlint-test-parallel.mjs +++ b/test/markdownlint-test-parallel.mjs @@ -3,15 +3,14 @@ // eslint-disable-next-line n/no-unsupported-features/node-builtins import { availableParallelism } from "node:os"; import { Worker } from "node:worker_threads"; +import { lint } from "markdownlint/sync"; import { __filename } from "./esm-helpers.mjs"; -import markdownlint from "../lib/markdownlint.mjs"; -const markdownlintSync = markdownlint.sync; /** * Lint specified Markdown files (using multiple threads). * - * @param {import("../lib/markdownlint.mjs").Options} options Configuration options. - * @returns {Promise} Results object. + * @param {import("markdownlint").Options} options Configuration options. + * @returns {Promise} Results object. */ export function markdownlintParallel(options) { const workerCount = availableParallelism(); @@ -30,7 +29,7 @@ export function markdownlintParallel(options) { })); } return Promise.all(promises).then((workerResults) => { - const combinedResults = markdownlintSync(null); + const combinedResults = lint(null); for (const workerResult of workerResults) { // eslint-disable-next-line guard-for-in for (const result in workerResult) { diff --git a/test/markdownlint-test-repos.mjs b/test/markdownlint-test-repos.mjs index 1ff5bc39a..13d36fe9f 100644 --- a/test/markdownlint-test-repos.mjs +++ b/test/markdownlint-test-repos.mjs @@ -5,8 +5,7 @@ const { join } = path.posix; import { globby } from "globby"; import jsoncParser from "jsonc-parser"; import jsYaml from "js-yaml"; -import library from "../lib/markdownlint.mjs"; -const { markdownlint, readConfig } = library.promises; +import { lint, readConfig } from "markdownlint/promise"; import { markdownlintParallel } from "./markdownlint-test-parallel.mjs"; /** @@ -39,7 +38,7 @@ export function lintTestRepo(t, globPatterns, configPath, parallel) { v ]) ); - return (parallel ? markdownlintParallel : markdownlint)({ + return (parallel ? markdownlintParallel : lint)({ files, config }).then((results) => { diff --git a/test/markdownlint-test-result-object.mjs b/test/markdownlint-test-result-object.mjs index 3f4b549df..a67e37318 100644 --- a/test/markdownlint-test-result-object.mjs +++ b/test/markdownlint-test-result-object.mjs @@ -1,7 +1,8 @@ // @ts-check import test from "ava"; -import markdownlint from "../lib/markdownlint.mjs"; +import { lint as lintAsync } from "markdownlint/async"; +import { lint as lintSync } from "markdownlint/sync"; import { importWithTypeJson } from "./esm-helpers.mjs"; const packageJson = await importWithTypeJson(import.meta, "../package.json"); const { homepage, version } = packageJson; @@ -13,7 +14,7 @@ test("resultObjectToStringNotEnumerable", (t) => new Promise((resolve) => { "string": "# Heading" } }; - markdownlint(options, function callback(err, result) { + lintAsync(options, function callback(err, result) { t.falsy(err); // eslint-disable-next-line guard-for-in for (const property in result) { @@ -36,7 +37,7 @@ test("resultFormattingV0", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -95,7 +96,7 @@ test("resultFormattingSyncV0", (t) => { "noInlineConfig": true, "resultVersion": 0 }; - const actualResult = markdownlint.sync(options); + const actualResult = lintSync(options); const expectedResult = { "./test/atx_heading_spacing.md": { "MD018": [ 1 ], @@ -154,7 +155,7 @@ test("resultFormattingV1", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 1 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "truncate": [ @@ -258,7 +259,7 @@ test("resultFormattingV2", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 2 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "truncate": [ @@ -352,7 +353,7 @@ test("resultFormattingV3", (t) => new Promise((resolve) => { }, "resultVersion": 3 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "input": [ @@ -467,7 +468,7 @@ test("onePerLineResultVersion0", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "input": { @@ -488,7 +489,7 @@ test("onePerLineResultVersion1", (t) => new Promise((resolve) => { }, "resultVersion": 1 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "input": [ @@ -519,7 +520,7 @@ test("onePerLineResultVersion2", (t) => new Promise((resolve) => { }, "resultVersion": 2 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "input": [ @@ -548,7 +549,7 @@ test("manyPerLineResultVersion3", (t) => new Promise((resolve) => { }, "resultVersion": 3 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "input": [ @@ -597,7 +598,7 @@ test("frontMatterResultVersion3", (t) => new Promise((resolve) => { }, "resultVersion": 3 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "input": [ diff --git a/test/markdownlint-test-scenarios.mjs b/test/markdownlint-test-scenarios.mjs index 76f60f870..c98b4f9c1 100644 --- a/test/markdownlint-test-scenarios.mjs +++ b/test/markdownlint-test-scenarios.mjs @@ -3,9 +3,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import test from "ava"; -import libMarkdownlint from "../lib/markdownlint.mjs"; -const { applyFixes, promises } = libMarkdownlint; -const { markdownlint } = promises; +import { lint } from "markdownlint/promise"; +import { applyFixes } from "markdownlint"; import helpers from "../helpers/helpers.cjs"; import { fixableRuleNames } from "../lib/constants.mjs"; @@ -22,7 +21,7 @@ function createTestForFile(file) { // Read and lint Markdown test file Promise.all([ fs.readFile(file, "utf8"), - markdownlint({ + lint({ "files": [ file ] }) ]) @@ -89,7 +88,7 @@ function createTestForFile(file) { fixed }); // Identify missing fixes - return markdownlint({ + return lint({ "strings": { "input": fixed } diff --git a/test/markdownlint-test-worker.mjs b/test/markdownlint-test-worker.mjs index a2c7a9db1..7678aa357 100644 --- a/test/markdownlint-test-worker.mjs +++ b/test/markdownlint-test-worker.mjs @@ -1,10 +1,9 @@ // @ts-check import { parentPort, workerData } from "node:worker_threads"; -import library from "../lib/markdownlint.mjs"; -const { markdownlint } = library.promises; +import { lint } from "markdownlint/promise"; -const lintResults = await markdownlint(workerData); +const lintResults = await lint(workerData); // @ts-ignore parentPort // eslint-disable-next-line unicorn/require-post-message-target-origin diff --git a/test/markdownlint-test.mjs b/test/markdownlint-test.mjs index 99431b90b..d37d9b4a6 100644 --- a/test/markdownlint-test.mjs +++ b/test/markdownlint-test.mjs @@ -13,7 +13,10 @@ import pluginInline from "markdown-it-for-inline"; import pluginSub from "markdown-it-sub"; import pluginSup from "markdown-it-sup"; import test from "ava"; -import markdownlint from "../lib/markdownlint.mjs"; +import { getVersion } from "markdownlint"; +import { lint as lintAsync } from "markdownlint/async"; +import { lint as lintPromise } from "markdownlint/promise"; +import { lint as lintSync } from "markdownlint/sync"; import * as constants from "../lib/constants.mjs"; import rules from "../lib/rules.mjs"; import customRules from "./rules/rules.cjs"; @@ -36,7 +39,7 @@ test("simpleAsync", (t) => new Promise((resolve) => { }; const expected = "content: 1: MD047/single-trailing-newline " + "Files should end with a single newline character"; - markdownlint(options, (err, actual) => { + lintAsync(options, (err, actual) => { t.falsy(err); // @ts-ignore t.is(actual.toString(), expected, "Unexpected results."); @@ -53,7 +56,7 @@ test("simpleSync", (t) => { }; const expected = "content: 1: MD047/single-trailing-newline " + "Files should end with a single newline character"; - const actual = markdownlint.sync(options).toString(); + const actual = lintSync(options).toString(); t.is(actual, expected, "Unexpected results."); }); @@ -66,7 +69,7 @@ test("simplePromise", (t) => { }; const expected = "content: 1: MD047/single-trailing-newline " + "Files should end with a single newline character"; - return markdownlint.promises.markdownlint(options).then((actual) => { + return lintPromise(options).then((actual) => { t.is(actual.toString(), expected, "Unexpected results."); }); }); @@ -90,7 +93,7 @@ test("projectFiles", (t) => { "config": require("../.markdownlint.json") }; // @ts-ignore - return markdownlint.promises.markdownlint(options).then((actual) => { + return lintPromise(options).then((actual) => { const expected = {}; for (const file of files) { expected[file] = []; @@ -118,7 +121,7 @@ test("projectFilesExtendedAscii", (t) => { "customRules": [ require("markdownlint-rule-extended-ascii") ] }; // @ts-ignore - return markdownlint.promises.markdownlint(options).then((actual) => { + return lintPromise(options).then((actual) => { const expected = {}; for (const file of files) { expected[file] = []; @@ -142,7 +145,7 @@ test("stringInputLineEndings", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "cr": { "MD018": [ 3 ] }, @@ -168,7 +171,7 @@ test("inputOnlyNewline", (t) => new Promise((resolve) => { "default": false } }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "cr": [], @@ -193,7 +196,7 @@ test("defaultTrue", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -224,7 +227,7 @@ test("defaultFalse", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": {}, @@ -247,7 +250,7 @@ test("defaultUndefined", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -279,7 +282,7 @@ test("disableRules", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -308,7 +311,7 @@ test("enableRules", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -340,7 +343,7 @@ test("enableRulesMixedCase", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -371,7 +374,7 @@ test("disableTag", (t) => new Promise((resolve) => { "noInlineConfig": true, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -401,7 +404,7 @@ test("enableTag", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -430,7 +433,7 @@ test("enableTagMixedCase", (t) => new Promise((resolve) => { }, "resultVersion": 0 }; - markdownlint(options, function callback(err, actualResult) { + lintAsync(options, function callback(err, actualResult) { t.falsy(err); const expectedResult = { "./test/atx_heading_spacing.md": { @@ -464,7 +467,7 @@ test("styleAll", async(t) => { "noInlineConfig": true, "resultVersion": 0 }; - const actualResult = await markdownlint.promises.markdownlint(options); + const actualResult = await lintPromise(options); const expectedResult = { "./test/break-all-the-rules.md": { "MD001": [ 3 ], @@ -527,7 +530,7 @@ test("styleRelaxed", async(t) => { "noInlineConfig": true, "resultVersion": 0 }; - const actualResult = await markdownlint.promises.markdownlint(options); + const actualResult = await lintPromise(options); const expectedResult = { "./test/break-all-the-rules.md": { "MD001": [ 3 ], @@ -569,7 +572,7 @@ test("styleRelaxed", async(t) => { test("nullFrontMatter", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "strings": { "content": "---\n\t\n---\n# Heading\n" }, @@ -592,7 +595,7 @@ test("nullFrontMatter", (t) => new Promise((resolve) => { test("customFrontMatter", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "strings": { "content": "\n\t\n\n# Heading\n" }, @@ -613,7 +616,7 @@ test("customFrontMatter", (t) => new Promise((resolve) => { test("noInlineConfig", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "strings": { "content": [ "# Heading", @@ -646,7 +649,7 @@ test("noInlineConfig", (t) => new Promise((resolve) => { test("readmeHeadings", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "files": "README.md", "noInlineConfig": true, "config": { @@ -713,7 +716,7 @@ test("filesArrayNotModified", (t) => new Promise((resolve) => { "./test/first_heading_bad_atx.md" ]; const expectedFiles = [ ...files ]; - markdownlint({ "files": files }, function callback(err) { + lintAsync({ "files": files }, function callback(err) { t.falsy(err); t.deepEqual(files, expectedFiles, "Files modified."); resolve(); @@ -722,7 +725,7 @@ test("filesArrayNotModified", (t) => new Promise((resolve) => { test("filesArrayAsString", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "files": "README.md", "noInlineConfig": true, "config": { @@ -739,7 +742,7 @@ test("filesArrayAsString", (t) => new Promise((resolve) => { test("missingOptions", (t) => new Promise((resolve) => { t.plan(2); - markdownlint(null, function callback(err, result) { + lintAsync(null, function callback(err, result) { t.falsy(err); t.deepEqual( result, @@ -752,7 +755,7 @@ test("missingOptions", (t) => new Promise((resolve) => { test("missingFilesAndStrings", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({}, function callback(err, result) { + lintAsync({}, function callback(err, result) { t.falsy(err); t.truthy(result, "Did not get result for missing files/strings."); resolve(); @@ -762,12 +765,12 @@ test("missingFilesAndStrings", (t) => new Promise((resolve) => { test("missingCallback", (t) => { t.plan(0); // @ts-ignore - markdownlint(); + lintAsync(); }); test("badFile", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ + lintAsync({ "files": [ "./badFile" ] }, function callback(err, result) { t.truthy(err, "Did not get an error for bad file."); @@ -783,7 +786,7 @@ test("badFileSync", (t) => { t.plan(1); t.throws( function badFileCall() { - markdownlint.sync({ + lintSync({ "files": [ "./badFile" ] }); }, @@ -796,7 +799,7 @@ test("badFileSync", (t) => { test("badFilePromise", (t) => new Promise((resolve) => { t.plan(3); - markdownlint.promises.markdownlint({ + lintPromise({ "files": [ "./badFile" ] }).then( null, @@ -811,7 +814,7 @@ test("badFilePromise", (t) => new Promise((resolve) => { test("missingStringValue", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "strings": { // @ts-ignore "undefined": undefined, @@ -840,7 +843,7 @@ test("customFileSystemSync", (t) => { return "# Heading"; } }; - const result = markdownlint.sync({ + const result = lintSync({ "files": file, "fs": fsApi }); @@ -856,7 +859,7 @@ test("customFileSystemAsync", (t) => new Promise((resolve) => { cb(null, "# Heading"); } }; - markdownlint({ + lintAsync({ "files": file, "fs": fsApi }, function callback(err, result) { @@ -1101,7 +1104,7 @@ test("someCustomRulesHaveValidUrl", (t) => { test("markdownItPluginsSingle", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ + lintAsync({ "strings": { "string": "# Heading\n\nText\n" }, @@ -1120,7 +1123,7 @@ test("markdownItPluginsSingle", (t) => new Promise((resolve) => { test("markdownItPluginsMultiple", (t) => new Promise((resolve) => { t.plan(4); - markdownlint({ + lintAsync({ "strings": { "string": "# Heading\n\nText H~2~0 text 29^th^ text\n" }, @@ -1142,7 +1145,7 @@ test("markdownItPluginsMultiple", (t) => new Promise((resolve) => { test("markdownItPluginsNoMarkdownIt", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "strings": { "string": "# Heading\n\nText\n" }, @@ -1159,7 +1162,7 @@ test("markdownItPluginsNoMarkdownIt", (t) => new Promise((resolve) => { test("markdownItPluginsUnusedUncalled", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "config": { "default": false }, @@ -1181,7 +1184,7 @@ test("markdownItPluginsUnusedUncalled", (t) => new Promise((resolve) => { test("Pandoc footnote", (t) => new Promise((resolve) => { t.plan(2); - markdownlint({ + lintAsync({ "strings": { "string": `# Heading @@ -1206,7 +1209,7 @@ Text with: [^footnote] test("token-map-spans", (t) => { t.plan(38); - /** @type {import("../lib/markdownlint.mjs").Options} */ + /** @type {import("markdownlint").Options} */ const options = { "customRules": [ { @@ -1239,7 +1242,7 @@ test("token-map-spans", (t) => { ], "files": [ "./test/token-map-spans.md" ] }; - markdownlint.sync(options); + lintSync(options); }); test("configParsersInvalid", async(t) => { @@ -1258,7 +1261,7 @@ test("configParsersInvalid", async(t) => { }; const expected = "content: 1: MD041/first-line-heading/first-line-h1 " + "First line in a file should be a top-level heading [Context: \"Text\"]"; - const actual = await markdownlint.promises.markdownlint(options); + const actual = await lintPromise(options); t.is(actual.toString(), expected, "Unexpected results."); }); @@ -1278,7 +1281,7 @@ test("configParsersJSON", async(t) => { ].join("\n") } }; - const actual = await markdownlint.promises.markdownlint(options); + const actual = await lintPromise(options); t.is(actual.toString(), "", "Unexpected results."); }); @@ -1300,7 +1303,7 @@ test("configParsersJSONC", async(t) => { }, "configParsers": [ jsoncParser.parse ] }; - const actual = await markdownlint.promises.markdownlint(options); + const actual = await lintPromise(options); t.is(actual.toString(), "", "Unexpected results."); }); @@ -1321,7 +1324,7 @@ test("configParsersYAML", async(t) => { "configParsers": [ jsYaml.load ] }; // @ts-ignore - const actual = await markdownlint.promises.markdownlint(options); + const actual = await lintPromise(options); t.is(actual.toString(), "", "Unexpected results."); }); @@ -1344,13 +1347,13 @@ test("configParsersTOML", async(t) => { require("toml").parse ] }; - const actual = await markdownlint.promises.markdownlint(options); + const actual = await lintPromise(options); t.is(actual.toString(), "", "Unexpected results."); }); test("getVersion", (t) => { t.plan(1); - const actual = markdownlint.getVersion(); + const actual = getVersion(); const expected = packageJson.version; t.is(actual, expected, "Version string not correct."); }); @@ -1364,7 +1367,10 @@ test("constants", (t) => { }); const exportMappings = new Map([ - [ ".", "../lib/markdownlint.mjs" ], + [ ".", "../lib/exports.mjs" ], + [ "./async", "../lib/exports-async.mjs" ], + [ "./promise", "../lib/exports-promise.mjs" ], + [ "./sync", "../lib/exports-sync.mjs" ], [ "./helpers", "../helpers/helpers.cjs" ], [ "./style/all", "../style/all.json" ], [ "./style/cirosantilli", "../style/cirosantilli.json" ], diff --git a/test/profile-fixture.mjs b/test/profile-fixture.mjs index ca191235d..7a00cdcff 100644 --- a/test/profile-fixture.mjs +++ b/test/profile-fixture.mjs @@ -1,6 +1,5 @@ import { readFile } from "node:fs/promises"; -import library from "../lib/markdownlint.mjs"; -const markdownlint = library.promises.markdownlint; +import { lint } from "markdownlint/promise"; const strings = { "CHANGELOG": await readFile("CHANGELOG.md", "utf8"), @@ -14,7 +13,7 @@ const strings = { const start = new Date(); for (let i = 0; i < 250; i++) { // eslint-disable-next-line no-await-in-loop - await markdownlint({ strings }); + await lint({ strings }); } const end = new Date(); // eslint-disable-next-line no-console diff --git a/test/rules/any-blockquote.cjs b/test/rules/any-blockquote.cjs index f1b16085f..5e4f5f1b9 100644 --- a/test/rules/any-blockquote.cjs +++ b/test/rules/any-blockquote.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type {import("../../lib/markdownlint.mjs").Rule[]} */ +/** @type {import("markdownlint").Rule[]} */ module.exports = [ // micromark parser (preferred) diff --git a/test/rules/every-n-lines.cjs b/test/rules/every-n-lines.cjs index 5f579f61d..e44ce3ba4 100644 --- a/test/rules/every-n-lines.cjs +++ b/test/rules/every-n-lines.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type {import("../../lib/markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "every-n-lines" ], "description": "Rule that reports an error every N lines", diff --git a/test/rules/first-line.cjs b/test/rules/first-line.cjs index 8b979d16e..56e536c10 100644 --- a/test/rules/first-line.cjs +++ b/test/rules/first-line.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type {import("../../lib/markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "first-line" ], "description": "Rule that reports an error for the first line", diff --git a/test/rules/letters-E-X.cjs b/test/rules/letters-E-X.cjs index 45733d6f4..c90233401 100644 --- a/test/rules/letters-E-X.cjs +++ b/test/rules/letters-E-X.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type {import("../../lib/markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ], "description": "Rule that reports an error for lines with the letters 'EX'", diff --git a/test/rules/lint-javascript.cjs b/test/rules/lint-javascript.cjs index 911c78f7a..d9ae1a524 100644 --- a/test/rules/lint-javascript.cjs +++ b/test/rules/lint-javascript.cjs @@ -7,7 +7,7 @@ const eslint = require("eslint"); const linter = new eslint.Linter(); const languageJavaScript = /js|javascript/i; -/** @type {import("../../lib/markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "lint-javascript" ], "description": "Rule that lints JavaScript code", diff --git a/test/rules/validate-json.cjs b/test/rules/validate-json.cjs index 11c8ed7b2..9dd1c6682 100644 --- a/test/rules/validate-json.cjs +++ b/test/rules/validate-json.cjs @@ -4,7 +4,7 @@ const { parse, printParseErrorCode } = require("jsonc-parser"); -/** @type {import("../../lib/markdownlint.mjs").Rule} */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "validate-json" ], "description": "Rule that validates JSON code",