diff --git a/markdownlint-cli2.mjs b/markdownlint-cli2.mjs index eb7c2c7..c406f7e 100755 --- a/markdownlint-cli2.mjs +++ b/markdownlint-cli2.mjs @@ -788,7 +788,6 @@ const lintFiles = (fs, dirInfos, fileContents) => { "handleRuleFailures": true, "markdownItPlugins": markdownlintOptions.markdownItPlugins, "noInlineConfig": Boolean(markdownlintOptions.noInlineConfig), - "resultVersion": 3, fs }; // Invoke markdownlint diff --git a/test/config-relative-commonjs/config/any-blockquote.cjs b/test/config-relative-commonjs/config/any-blockquote.cjs index 7e10e22..2de8e13 100644 --- a/test/config-relative-commonjs/config/any-blockquote.cjs +++ b/test/config-relative-commonjs/config/any-blockquote.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type import("markdownlint").Rule */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "any-blockquote" ], "description": "Rule that reports an error for any blockquote", diff --git a/test/config-relative-module/config/any-blockquote.mjs b/test/config-relative-module/config/any-blockquote.mjs index 210715c..c9c8370 100644 --- a/test/config-relative-module/config/any-blockquote.mjs +++ b/test/config-relative-module/config/any-blockquote.mjs @@ -1,6 +1,6 @@ // @ts-check -/** @type import("markdownlint").Rule */ +/** @type {import("markdownlint").Rule} */ const rule = { "names": [ "any-blockquote" ], "description": "Rule that reports an error for any blockquote", diff --git a/test/customRules-pre-imported/rules/any-blockquote.cjs b/test/customRules-pre-imported/rules/any-blockquote.cjs index 7e10e22..2de8e13 100644 --- a/test/customRules-pre-imported/rules/any-blockquote.cjs +++ b/test/customRules-pre-imported/rules/any-blockquote.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type import("markdownlint").Rule */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "any-blockquote" ], "description": "Rule that reports an error for any blockquote", diff --git a/test/customRules/rules/any-blockquote.cjs b/test/customRules/rules/any-blockquote.cjs index 7e10e22..2de8e13 100644 --- a/test/customRules/rules/any-blockquote.cjs +++ b/test/customRules/rules/any-blockquote.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type import("markdownlint").Rule */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "any-blockquote" ], "description": "Rule that reports an error for any blockquote", diff --git a/test/esm-helpers.mjs b/test/esm-helpers.mjs index fdf0b6e..093e202 100644 --- a/test/esm-helpers.mjs +++ b/test/esm-helpers.mjs @@ -4,16 +4,32 @@ import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; -// Shims import.meta.filename on Node 18 +/** + * Gets the file name of the current module. + * Shims import.meta.filename for Node 18. + * @param {object} meta ESM import.meta object. + * @returns {string} File name. + */ // eslint-disable-next-line no-underscore-dangle export const __filename = (meta) => fileURLToPath(meta.url); -// Shims import.meta.dirname on Node 18 +/** + * Gets the directory name of the current module. + * Shims import.meta.dirname for Node 18. + * @param {object} meta ESM import.meta object. + * @returns {string} Directory name. + */ // eslint-disable-next-line no-underscore-dangle export const __dirname = (meta) => path.dirname(__filename(meta)); -// Avoids "ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time" -export const importWithTypeJson = async (file) => ( +/** + * Imports a file as JSON. + * Avoids "ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time". + * @param {object} meta ESM import.meta object. + * @param {string} file JSON file to import. + * @returns {Promise} JSON object. + */ +export const importWithTypeJson = async (meta, file) => ( // @ts-ignore - JSON.parse(await fs.readFile(path.resolve(__dirname(import.meta), file))) + JSON.parse(await fs.readFile(path.resolve(__dirname(meta), file))) ); diff --git a/test/markdownlint-cli2-test-exports.mjs b/test/markdownlint-cli2-test-exports.mjs index 0864160..a5ef356 100644 --- a/test/markdownlint-cli2-test-exports.mjs +++ b/test/markdownlint-cli2-test-exports.mjs @@ -2,7 +2,7 @@ import test from "ava"; import { importWithTypeJson } from "./esm-helpers.mjs"; -const packageJson = await importWithTypeJson("../package.json"); +const packageJson = await importWithTypeJson(import.meta, "../package.json"); const exportMappings = new Map([ [ ".", "../markdownlint-cli2.mjs" ], diff --git a/test/markdownlint-cli2-test.mjs b/test/markdownlint-cli2-test.mjs index 91301f9..5e56419 100644 --- a/test/markdownlint-cli2-test.mjs +++ b/test/markdownlint-cli2-test.mjs @@ -7,7 +7,7 @@ import Ajv from "ajv"; import test from "ava"; import { globby } from "globby"; import { __dirname, importWithTypeJson } from "./esm-helpers.mjs"; -const packageJson = await importWithTypeJson("../package.json"); +const packageJson = await importWithTypeJson(import.meta, "../package.json"); import { "main" as markdownlintCli2 } from "../markdownlint-cli2.mjs"; import jsoncParse from "../parsers/jsonc-parse.mjs"; import yamlParse from "../parsers/yaml-parse.mjs"; @@ -16,8 +16,8 @@ import FsVirtual from "../webworker/fs-virtual.cjs"; import firstLine from "./customRules/rules/first-line.cjs"; const schemaIdVersionRe = /^.*v(?\d+\.\d+\.\d+).*$/u; -const markdownlintConfigSchemaDefinition = await importWithTypeJson("../schema/markdownlint-config-schema.json"); -const markdownlintCli2ConfigSchemaDefinition = await importWithTypeJson("../schema/markdownlint-cli2-config-schema.json"); +const markdownlintConfigSchemaDefinition = await importWithTypeJson(import.meta, "../schema/markdownlint-config-schema.json"); +const markdownlintCli2ConfigSchemaDefinition = await importWithTypeJson(import.meta, "../schema/markdownlint-cli2-config-schema.json"); const outputFormatterLengthIs = (t, length) => (options) => { const { results } = options; diff --git a/test/tilde-paths-commonjs/scripts/any-blockquote.cjs b/test/tilde-paths-commonjs/scripts/any-blockquote.cjs index 7e10e22..2de8e13 100644 --- a/test/tilde-paths-commonjs/scripts/any-blockquote.cjs +++ b/test/tilde-paths-commonjs/scripts/any-blockquote.cjs @@ -2,7 +2,7 @@ "use strict"; -/** @type import("markdownlint").Rule */ +/** @type {import("markdownlint").Rule} */ module.exports = { "names": [ "any-blockquote" ], "description": "Rule that reports an error for any blockquote", diff --git a/test/tilde-paths-module/scripts/any-blockquote.mjs b/test/tilde-paths-module/scripts/any-blockquote.mjs index 210715c..c9c8370 100644 --- a/test/tilde-paths-module/scripts/any-blockquote.mjs +++ b/test/tilde-paths-module/scripts/any-blockquote.mjs @@ -1,6 +1,6 @@ // @ts-check -/** @type import("markdownlint").Rule */ +/** @type {import("markdownlint").Rule} */ const rule = { "names": [ "any-blockquote" ], "description": "Rule that reports an error for any blockquote",