From ddd226908e4f0979a2842e9752e2366e11587fd0 Mon Sep 17 00:00:00 2001 From: David Anson Date: Thu, 12 Dec 2024 19:52:24 -0800 Subject: [PATCH] Convert to an ECMAScript module. --- .gitattributes | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/sarif.yml | 2 +- .gitignore | 4 +- append-to-array.js => append-to-array.mjs | 5 +- doc/OutputFormatters.md | 2 +- eslint.config.mjs | 22 +- export-markdownlint-helpers.js | 5 - export-markdownlint-helpers.mjs | 3 + export-markdownlint-promise.mjs | 3 + export-markdownlint.js | 5 - export-markdownlint.mjs | 3 + markdownlint-cli2-bin.mjs | 16 ++ markdownlint-cli2.js => markdownlint-cli2.mjs | 144 ++++-------- merge-options.js => merge-options.mjs | 4 +- package.json | 48 ++-- parsers/{jsonc-parse.js => jsonc-parse.mjs} | 6 +- parsers/parsers.js | 16 -- parsers/parsers.mjs | 14 ++ parsers/{yaml-parse.js => yaml-parse.mjs} | 6 +- ...-and-require.js => resolve-and-require.mjs | 4 +- schema/markdownlint-cli2-config-schema.json | 4 +- schema/markdownlint-config-schema.json | 212 +++++++++--------- ...array-test.js => append-to-array-test.mjs} | 7 +- .../config/any-blockquote.cjs | 2 +- .../config/any-blockquote.mjs | 2 +- .../.markdownlint-cli2.jsonc | 2 +- .../.markdownlint-cli2.cjs | 2 +- .../rules/any-blockquote.cjs} | 2 +- .../.markdownlint-cli2.jsonc | 2 +- .../rules/{throws.js => throws.cjs} | 0 test/customRules/.markdownlint-cli2.jsonc | 6 +- .../dir/subdir/.markdownlint-cli2.jsonc | 2 +- .../customRules/dir3/.markdownlint-cli2.jsonc | 2 +- test/customRules/rules/all-rules.cjs | 10 + test/customRules/rules/all-rules.js | 10 - .../rules/any-blockquote.cjs} | 2 +- .../{every-n-lines.js => every-n-lines.cjs} | 0 .../rules/{first-line.js => first-line.cjs} | 0 .../rules/{second-line.js => second-line.cjs} | 0 test/esm-helpers.mjs | 35 +++ test/{fs-mock-test.js => fs-mock-test.mjs} | 28 +-- test/{fs-mock.js => fs-mock.mjs} | 14 +- ...fs-virtual-test.js => fs-virtual-test.mjs} | 15 +- ...es.js => markdownlint-cli2-test-cases.mjs} | 27 ++- ...xec.js => markdownlint-cli2-test-exec.mjs} | 32 ++- test/markdownlint-cli2-test-exports.js | 31 --- test/markdownlint-cli2-test-exports.mjs | 34 +++ ...st-fs.js => markdownlint-cli2-test-fs.mjs} | 10 +- ...ain.js => markdownlint-cli2-test-main.mjs} | 8 +- ...li2-test.js => markdownlint-cli2-test.mjs} | 68 +++--- ...options-test.js => merge-options-test.mjs} | 6 +- .../dir/dir/.markdownlint-cli2.jsonc | 2 +- .../dir/dir/.markdownlint-cli2.jsonc | 2 +- .../dir/dir/.markdownlint-cli2.jsonc | 2 +- .../dir/dir/.markdownlint-cli2.jsonc | 2 +- .../{first-line.js => first-line.cjs} | 0 .../.markdownlint-cli2.jsonc | 2 +- .../.markdownlint-cli2.jsonc | 2 +- .../.markdownlint-cli2.jsonc | 2 +- .../.markdownlint-cli2.jsonc | 2 +- ...e-test.js => resolve-and-require-test.mjs} | 34 +-- ....md => markdownlint-cli2-test-exec.mjs.md} | 4 +- ...p => markdownlint-cli2-test-exec.mjs.snap} | Bin ...js.md => markdownlint-cli2-test-fs.mjs.md} | 4 +- ...nap => markdownlint-cli2-test-fs.mjs.snap} | Bin ....md => markdownlint-cli2-test-main.mjs.md} | 4 +- ...p => markdownlint-cli2-test-main.mjs.snap} | Bin .../scripts/any-blockquote.cjs | 2 +- .../scripts/any-blockquote.mjs | 2 +- webworker/{fs-virtual.js => fs-virtual.cjs} | 0 webworker/index.html | 8 +- webworker/index.js | 5 - .../{module-empty.js => module-empty.cjs} | 0 webworker/module-stub.cjs | 8 + webworker/{os-stub.js => os-stub.cjs} | 0 .../{process-stub.js => process-stub.cjs} | 1 + ...n-magic-stub.js => unicorn-magic-stub.cjs} | 0 .../{webpack.config.js => webpack.config.cjs} | 25 ++- .../{webworker-test.js => webworker-test.cjs} | 0 80 files changed, 499 insertions(+), 505 deletions(-) rename append-to-array.js => append-to-array.mjs (87%) delete mode 100644 export-markdownlint-helpers.js create mode 100644 export-markdownlint-helpers.mjs create mode 100644 export-markdownlint-promise.mjs delete mode 100644 export-markdownlint.js create mode 100644 export-markdownlint.mjs create mode 100644 markdownlint-cli2-bin.mjs rename markdownlint-cli2.js => markdownlint-cli2.mjs (90%) rename merge-options.js => merge-options.mjs (92%) rename parsers/{jsonc-parse.js => jsonc-parse.mjs} (84%) delete mode 100644 parsers/parsers.js create mode 100644 parsers/parsers.mjs rename parsers/{yaml-parse.js => yaml-parse.mjs} (74%) rename resolve-and-require.js => resolve-and-require.mjs (91%) rename test/{append-to-array-test.js => append-to-array-test.mjs} (94%) rename test/{customRules/rules/any-blockquote.js => customRules-pre-imported/rules/any-blockquote.cjs} (94%) rename test/customRules-throws/rules/{throws.js => throws.cjs} (100%) create mode 100644 test/customRules/rules/all-rules.cjs delete mode 100644 test/customRules/rules/all-rules.js rename test/{customRules-pre-imported/rules/any-blockquote.js => customRules/rules/any-blockquote.cjs} (94%) rename test/customRules/rules/{every-n-lines.js => every-n-lines.cjs} (100%) rename test/customRules/rules/{first-line.js => first-line.cjs} (100%) rename test/customRules/rules/{second-line.js => second-line.cjs} (100%) create mode 100644 test/esm-helpers.mjs rename test/{fs-mock-test.js => fs-mock-test.mjs} (73%) rename test/{fs-mock.js => fs-mock.mjs} (87%) rename test/{fs-virtual-test.js => fs-virtual-test.mjs} (88%) rename test/{markdownlint-cli2-test-cases.js => markdownlint-cli2-test-cases.mjs} (97%) rename test/{markdownlint-cli2-test-exec.js => markdownlint-cli2-test-exec.mjs} (86%) delete mode 100644 test/markdownlint-cli2-test-exports.js create mode 100644 test/markdownlint-cli2-test-exports.mjs rename test/{markdownlint-cli2-test-fs.js => markdownlint-cli2-test-fs.mjs} (81%) rename test/{markdownlint-cli2-test-main.js => markdownlint-cli2-test-main.mjs} (83%) rename test/{markdownlint-cli2-test.js => markdownlint-cli2-test.mjs} (90%) rename test/{merge-options-test.js => merge-options-test.mjs} (96%) rename test/nested-options-config/{first-line.js => first-line.cjs} (100%) rename test/{resolve-and-require-test.js => resolve-and-require-test.mjs} (69%) rename test/snapshots/{markdownlint-cli2-test-exec.js.md => markdownlint-cli2-test-exec.mjs.md} (99%) rename test/snapshots/{markdownlint-cli2-test-exec.js.snap => markdownlint-cli2-test-exec.mjs.snap} (100%) rename test/snapshots/{markdownlint-cli2-test-fs.js.md => markdownlint-cli2-test-fs.mjs.md} (99%) rename test/snapshots/{markdownlint-cli2-test-fs.js.snap => markdownlint-cli2-test-fs.mjs.snap} (100%) rename test/snapshots/{markdownlint-cli2-test-main.js.md => markdownlint-cli2-test-main.mjs.md} (99%) rename test/snapshots/{markdownlint-cli2-test-main.js.snap => markdownlint-cli2-test-main.mjs.snap} (100%) rename webworker/{fs-virtual.js => fs-virtual.cjs} (100%) delete mode 100644 webworker/index.js rename webworker/{module-empty.js => module-empty.cjs} (100%) create mode 100644 webworker/module-stub.cjs rename webworker/{os-stub.js => os-stub.cjs} (100%) rename webworker/{process-stub.js => process-stub.cjs} (89%) rename webworker/{unicorn-magic-stub.js => unicorn-magic-stub.cjs} (100%) rename webworker/{webpack.config.js => webpack.config.cjs} (70%) rename webworker/{webworker-test.js => webworker-test.cjs} (100%) diff --git a/.gitattributes b/.gitattributes index e86c06b0..770f3ca8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -markdownlint-cli2.js eol=lf +markdownlint-cli2-bin.mjs eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d4293e5..0a15be04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: - name: Install markdownlint-cli2 dependencies locally run: sudo npm install --no-package-lock --production - name: Lint with formatters - run: node ./markdownlint-cli2 CONTRIBUTING.md README.md + run: node ./markdownlint-cli2-bin.mjs CONTRIBUTING.md README.md lint-dockerfile: runs-on: ubuntu-latest diff --git a/.github/workflows/sarif.yml b/.github/workflows/sarif.yml index 2f23e04a..63466225 100644 --- a/.github/workflows/sarif.yml +++ b/.github/workflows/sarif.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: npm install --no-package-lock - - run: node markdownlint-cli2.js --config .github/sarif.markdownlint-cli2.jsonc '**/README.md' '#node_modules' + - run: node markdownlint-cli2-bin.mjs --config .github/sarif.markdownlint-cli2.jsonc '**/README.md' '#node_modules' continue-on-error: true - uses: github/codeql-action/upload-sarif@v3 with: diff --git a/.gitignore b/.gitignore index f09431b6..85f9fcd9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ npm-debug.log !test/customRules/node_modules !test/markdownItPlugins/module/node_modules !test/outputFormatters-module/node_modules -webworker/markdownlint-cli2-webworker.js -webworker/setImmediate.js +webworker/markdownlint-cli2-webworker.cjs +webworker/setImmediate.cjs diff --git a/append-to-array.js b/append-to-array.mjs similarity index 87% rename from append-to-array.js rename to append-to-array.mjs index 4002d699..1635cee2 100644 --- a/append-to-array.js +++ b/append-to-array.mjs @@ -1,7 +1,5 @@ // @ts-check -"use strict"; - const sliceSize = 1000; /** @@ -21,5 +19,4 @@ const appendToArray = (destination, source) => { } }; -appendToArray.sliceSize = sliceSize; -module.exports = appendToArray; +export { appendToArray as default, sliceSize }; diff --git a/doc/OutputFormatters.md b/doc/OutputFormatters.md index d7f9cacd..d518ac19 100644 --- a/doc/OutputFormatters.md +++ b/doc/OutputFormatters.md @@ -63,4 +63,4 @@ For a `.markdownlint-cli2.jsonc` like: [formatter-junit]: ../formatter-junit/markdownlint-cli2-formatter-junit.js [formatter-sarif]: ../formatter-sarif/markdownlint-cli2-formatter-sarif.js [markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter -[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.36.1/lib/markdownlint.d.ts +[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.37.0/lib/markdownlint.d.mts diff --git a/eslint.config.mjs b/eslint.config.mjs index 4255d5f4..da8ca728 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -21,14 +21,11 @@ export default [ { "ignores": [ "test/*/**", - "webworker/markdownlint-cli2-webworker.js", - "webworker/setImmediate.js" + "webworker/markdownlint-cli2-webworker.cjs", + "webworker/setImmediate.cjs" ] }, { - "languageOptions": { - "sourceType": "commonjs" - }, "linterOptions": { "reportUnusedDisableDirectives": true }, @@ -60,7 +57,6 @@ export default [ "@stylistic/padded-blocks": "off", "unicorn/no-null": "off", - "unicorn/prefer-module": "off", "unicorn/prefer-string-raw": "off", "unicorn/prefer-string-replace-all": "off", "unicorn/prevent-abbreviations": "off" @@ -68,10 +64,20 @@ export default [ }, { "files": [ - "**/*.mjs" + "**/*-formatter-*.js", + "webworker/*.cjs" ], "languageOptions": { - "sourceType": "module" + "sourceType": "commonjs", + "globals": { + "__dirname": "readonly", + "__filename": "readonly", + "module": "readonly", + "require": "readonly" + } + }, + "rules": { + "unicorn/prefer-module": "off" } } ]; diff --git a/export-markdownlint-helpers.js b/export-markdownlint-helpers.js deleted file mode 100644 index 44cfe31a..00000000 --- a/export-markdownlint-helpers.js +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-check - -"use strict"; - -module.exports = require("markdownlint/helpers"); diff --git a/export-markdownlint-helpers.mjs b/export-markdownlint-helpers.mjs new file mode 100644 index 00000000..6598099d --- /dev/null +++ b/export-markdownlint-helpers.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export { default } from "markdownlint/helpers"; diff --git a/export-markdownlint-promise.mjs b/export-markdownlint-promise.mjs new file mode 100644 index 00000000..105e36da --- /dev/null +++ b/export-markdownlint-promise.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export * from "markdownlint/promise"; diff --git a/export-markdownlint.js b/export-markdownlint.js deleted file mode 100644 index b3f98eb0..00000000 --- a/export-markdownlint.js +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-check - -"use strict"; - -module.exports = require("markdownlint"); diff --git a/export-markdownlint.mjs b/export-markdownlint.mjs new file mode 100644 index 00000000..89310996 --- /dev/null +++ b/export-markdownlint.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export * from "markdownlint"; diff --git a/markdownlint-cli2-bin.mjs b/markdownlint-cli2-bin.mjs new file mode 100644 index 00000000..ba0bfdfd --- /dev/null +++ b/markdownlint-cli2-bin.mjs @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +import { "main" as markdownlintCli2 } from "./markdownlint-cli2.mjs"; + +const params = { + "argv": process.argv.slice(2), + "logMessage": console.log, + "logError": console.error, + "allowStdin": true +}; +try { + process.exitCode = await markdownlintCli2(params); +} catch (error) { + console.error(error); + process.exitCode = 2; +} diff --git a/markdownlint-cli2.js b/markdownlint-cli2.mjs similarity index 90% rename from markdownlint-cli2.js rename to markdownlint-cli2.mjs index 83685309..46c3cb72 100755 --- a/markdownlint-cli2.js +++ b/markdownlint-cli2.mjs @@ -1,38 +1,30 @@ -#!/usr/bin/env node - -// @ts-check - -"use strict"; - // @ts-ignore -// eslint-disable-next-line camelcase, no-inline-comments, no-undef -const dynamicRequire = (typeof __non_webpack_require__ === "undefined") ? require : /* c8 ignore next */ __non_webpack_require__; -// Capture native require implementation for dynamic loading of modules // Requires -const pathDefault = require("node:path"); +import fsNode from "node:fs"; +import { createRequire } from "node:module"; +const dynamicRequire = createRequire(import.meta.url); +import os from "node:os"; +import pathDefault from "node:path"; const pathPosix = pathDefault.posix; -const { pathToFileURL } = require("node:url"); -const markdownlintLibrary = require("markdownlint"); -const { - applyFixes, - "getVersion": getLibraryVersion, - "promises": markdownlintPromises -} = markdownlintLibrary; -const { - markdownlint, - "extendConfig": markdownlintExtendConfig, - "readConfig": markdownlintReadConfig -} = markdownlintPromises; -const appendToArray = require("./append-to-array"); -const mergeOptions = require("./merge-options"); -const resolveAndRequire = require("./resolve-and-require"); +import { pathToFileURL } from "node:url"; +import { globby } from "globby"; +import micromatch from "micromatch"; +import { applyFixes, getVersion } from "markdownlint"; +import { lint, extendConfig, readConfig } from "markdownlint/promise"; +import { expandTildePath } from "markdownlint/helpers"; +import appendToArray from "./append-to-array.mjs"; +import mergeOptions from "./merge-options.mjs"; +import resolveAndRequire from "./resolve-and-require.mjs"; +import parsers from "./parsers/parsers.mjs"; +import jsoncParse from "./parsers/jsonc-parse.mjs"; +import yamlParse from "./parsers/yaml-parse.mjs"; // Variables const packageName = "markdownlint-cli2"; const packageVersion = "0.16.0"; const libraryName = "markdownlint"; -const libraryVersion = getLibraryVersion(); +const libraryVersion = getVersion(); const bannerMessage = `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`; const dotOnlySubstitute = "*.{md,markdown}"; const utf8 = "utf8"; @@ -40,15 +32,6 @@ const utf8 = "utf8"; // No-op function const noop = () => null; -// Gets a JSONC parser -const getJsoncParse = () => require("./parsers/jsonc-parse.js"); - -// Gets a YAML parser -const getYamlParse = () => require("./parsers/yaml-parse.js"); - -// Gets an ordered array of parsers -const getParsers = () => require("./parsers/parsers.js"); - // Negates a glob const negateGlob = (glob) => `!${glob}`; @@ -63,25 +46,19 @@ const throwForConfigurationFile = (file, error) => { // Return a posix path (even on Windows) const posixPath = (p) => p.split(pathDefault.sep).join(pathPosix.sep); -// Expands a path with a tilde to an absolute path -const expandTildePath = (id) => { - const markdownlintRuleHelpers = require("markdownlint/helpers"); - return markdownlintRuleHelpers.expandTildePath(id, require("node:os")); -}; - // Resolves module paths relative to the specified directory const resolveModulePaths = (dir, modulePaths) => ( - modulePaths.map((path) => pathDefault.resolve(dir, expandTildePath(path))) + modulePaths.map((path) => pathDefault.resolve(dir, expandTildePath(path, os))) ); // Read a JSON(C) or YAML file and return the object -const readConfig = (fs, dir, name, otherwise) => () => { +const readConfigFile = (fs, dir, name, otherwise) => () => { const file = pathPosix.join(dir, name); return fs.promises.access(file). then( - () => markdownlintReadConfig( + () => readConfig( file, - getParsers(), + parsers, fs ), otherwise @@ -95,7 +72,7 @@ const importOrRequireResolve = async (dirOrDirs, id, noRequire) => { return null; } const dirs = Array.isArray(dirOrDirs) ? dirOrDirs : [ dirOrDirs ]; - const expandId = expandTildePath(id); + const expandId = expandTildePath(id, os); const errors = []; // Try to load via require(...) try { @@ -162,10 +139,10 @@ const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => () => { // Extend a config object if it has 'extends' property const getExtendedConfig = (config, configPath, fs) => { if (config.extends) { - return markdownlintExtendConfig( + return extendConfig( config, configPath, - getParsers(), + parsers, fs ); } @@ -181,9 +158,9 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => { let config = null; try { if (basename.endsWith(".markdownlint-cli2.jsonc")) { - options = getJsoncParse()(await fs.promises.readFile(configPath, utf8)); + options = jsoncParse(await fs.promises.readFile(configPath, utf8)); } else if (basename.endsWith(".markdownlint-cli2.yaml")) { - options = getYamlParse()(await fs.promises.readFile(configPath, utf8)); + options = yamlParse(await fs.promises.readFile(configPath, utf8)); } else if ( basename.endsWith(".markdownlint-cli2.cjs") || basename.endsWith(".markdownlint-cli2.mjs") @@ -195,7 +172,7 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => { basename.endsWith(".markdownlint.yaml") || basename.endsWith(".markdownlint.yml") ) { - config = await markdownlintReadConfig(configPath, getParsers(), fs); + config = await readConfig(configPath, parsers, fs); } else if ( basename.endsWith(".markdownlint.cjs") || basename.endsWith(".markdownlint.mjs") @@ -221,13 +198,12 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => { }; // Filter a list of files to ignore by glob -const removeIgnoredFiles = (dir, files, ignores) => { - const micromatch = require("micromatch"); - return micromatch( +const removeIgnoredFiles = (dir, files, ignores) => ( + micromatch( files.map((file) => pathPosix.relative(dir, file)), ignores - ).map((file) => pathPosix.join(dir, file)); -}; + ).map((file) => pathPosix.join(dir, file)) +); // Process/normalize command-line arguments and return glob patterns const processArgv = (argv) => { @@ -340,10 +316,10 @@ const getAndProcessDirInfo = ( tasks.push( fs.promises.access(captureFile(markdownlintCli2Jsonc)). then( - () => fs.promises.readFile(file, utf8).then(getJsoncParse()), + () => fs.promises.readFile(file, utf8).then(jsoncParse), () => fs.promises.access(captureFile(markdownlintCli2Yaml)). then( - () => fs.promises.readFile(file, utf8).then(getYamlParse()), + () => fs.promises.readFile(file, utf8).then(yamlParse), () => fs.promises.access(captureFile(markdownlintCli2Cjs)). then( () => importOrRequireResolve(dir, file, noRequire), @@ -358,7 +334,7 @@ const getAndProcessDirInfo = ( then( () => fs.promises. readFile(file, utf8). - then(getJsoncParse()). + then(jsoncParse). then((obj) => obj[packageName]), noop ) @@ -387,19 +363,19 @@ const getAndProcessDirInfo = ( // Load markdownlint object(s) const readConfigs = - readConfig( + readConfigFile( fs, dir, ".markdownlint.jsonc", - readConfig( + readConfigFile( fs, dir, ".markdownlint.json", - readConfig( + readConfigFile( fs, dir, ".markdownlint.yaml", - readConfig( + readConfigFile( fs, dir, ".markdownlint.yml", @@ -548,8 +524,6 @@ const enumerateFiles = async ( }) ); // Process glob patterns - // eslint-disable-next-line no-inline-comments - const { globby } = await import(/* webpackMode: "eager" */ "globby"); const files = [ ...await globby(expandedDirectories, globbyOptions), ...filteredLiteralFiles @@ -797,7 +771,7 @@ const lintFiles = (fs, dirInfos, fileContents) => { "files": filteredFiles, "strings": filteredStrings, "config": markdownlintConfig || markdownlintOptions.config, - "configParsers": getParsers(), + "configParsers": parsers, "customRules": markdownlintOptions.customRules, "frontMatter": markdownlintOptions.frontMatter ? new RegExp(markdownlintOptions.frontMatter, "u") @@ -805,11 +779,10 @@ const lintFiles = (fs, dirInfos, fileContents) => { "handleRuleFailures": true, "markdownItPlugins": markdownlintOptions.markdownItPlugins, "noInlineConfig": Boolean(markdownlintOptions.noInlineConfig), - "resultVersion": 3, fs }; // Invoke markdownlint - let task = markdownlint(options); + let task = lint(options); // For any fixable errors, read file, apply fixes, and write it back if (markdownlintOptions.fix) { task = task.then((results) => { @@ -832,7 +805,7 @@ const lintFiles = (fs, dirInfos, fileContents) => { } } return Promise.all(subTasks). - then(() => markdownlint(options)). + then(() => lint(options)). then((fixResults) => ({ ...results, ...fixResults @@ -899,7 +872,8 @@ const outputSummary = async ( const dirs = [ dir, ...modulePaths ]; const formattersAndParams = outputFormatters ? await importOrRequireIdsAndParams(dirs, outputFormatters, noRequire) - : [ [ require("markdownlint-cli2-formatter-default") ] ]; + // eslint-disable-next-line no-inline-comments, unicorn/no-await-expression-member + : [ [ (await import(/* webpackMode: "eager" */ "markdownlint-cli2-formatter-default")).default ] ]; await Promise.all(formattersAndParams.map((formatterAndParams) => { const [ formatter, ...formatterParams ] = formatterAndParams; return formatter(formatterOptions, ...formatterParams); @@ -909,7 +883,7 @@ const outputSummary = async ( }; // Main function -const main = async (params) => { +export const main = async (params) => { // Capture parameters const { directory, @@ -926,7 +900,7 @@ const main = async (params) => { } = params; const logMessage = params.logMessage || noop; const logError = params.logError || noop; - const fs = params.fs || require("node:fs"); + const fs = params.fs || fsNode; const baseDirSystem = (directory && pathDefault.resolve(directory)) || process.cwd(); @@ -1003,7 +977,7 @@ const main = async (params) => { // Add stdin as a non-file input if necessary if (useStdin) { const key = pathPosix.join(baseDir, "stdin"); - const { text } = require("node:stream/consumers"); + const { text } = await import("node:stream/consumers"); nonFileContents = { ...nonFileContents, [key]: await text(process.stdin) @@ -1089,27 +1063,3 @@ const main = async (params) => { // Return result return errorsPresent ? 1 : 0; }; - -// Export functions -module.exports = { - main -}; - -// Run if invoked as a CLI -if (require.main === module) { - const params = { - "argv": process.argv.slice(2), - "logMessage": console.log, - "logError": console.error, - "allowStdin": true - }; - main(params). - then((exitCode) => { - process.exitCode = exitCode; - }). - // eslint-disable-next-line unicorn/prefer-top-level-await - catch((error) => { - console.error(error); - process.exitCode = 2; - }); -} diff --git a/merge-options.js b/merge-options.mjs similarity index 92% rename from merge-options.js rename to merge-options.mjs index 915f5e45..8c294188 100644 --- a/merge-options.js +++ b/merge-options.mjs @@ -1,7 +1,5 @@ // @ts-check -"use strict"; - /** * Merges two options objects by combining config and replacing properties. * @param {object} first First options object. @@ -24,4 +22,4 @@ const mergeOptions = (first, second) => { return merged; }; -module.exports = mergeOptions; +export default mergeOptions; diff --git a/package.json b/package.json index 130d3053..f4c244be 100644 --- a/package.json +++ b/package.json @@ -7,18 +7,18 @@ "url": "https://dlaa.me/" }, "license": "MIT", - "type": "commonjs", - "main": "./markdownlint-cli2.js", + "type": "module", "exports": { - ".": "./markdownlint-cli2.js", - "./markdownlint": "./export-markdownlint.js", - "./markdownlint/helpers": "./export-markdownlint-helpers.js", - "./parsers": "./parsers/parsers.js", - "./parsers/jsonc": "./parsers/jsonc-parse.js", - "./parsers/yaml": "./parsers/yaml-parse.js" + ".": "./markdownlint-cli2.mjs", + "./markdownlint": "./export-markdownlint.mjs", + "./markdownlint/helpers": "./export-markdownlint-helpers.mjs", + "./markdownlint/promise": "./export-markdownlint-promise.mjs", + "./parsers": "./parsers/parsers.mjs", + "./parsers/jsonc": "./parsers/jsonc-parse.mjs", + "./parsers/yaml": "./parsers/yaml-parse.mjs" }, "bin": { - "markdownlint-cli2": "markdownlint-cli2.js" + "markdownlint-cli2": "markdownlint-cli2-bin.mjs" }, "homepage": "https://github.com/DavidAnson/markdownlint-cli2", "repository": { @@ -39,7 +39,7 @@ "playwright-test": "playwright test --config ./webworker/playwright.config.mjs", "playwright-test-docker": "docker run --rm --volume $PWD:/home/workdir --workdir /home/workdir --ipc=host mcr.microsoft.com/playwright:v1.49.1 npm run playwright-test", "schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat", - "test": "ava --timeout=1m test/append-to-array-test.js test/fs-mock-test.js test/fs-virtual-test.js test/markdownlint-cli2-test.js test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-exports.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js test/merge-options-test.js test/resolve-and-require-test.js", + "test": "ava --timeout=1m test/append-to-array-test.mjs test/fs-mock-test.mjs test/fs-virtual-test.mjs test/markdownlint-cli2-test.mjs test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-exports.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs test/merge-options-test.mjs test/resolve-and-require-test.mjs", "test-cover": "c8 --100 npm test", "test-docker-hub-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2:v$VERSION davidanson/markdownlint-cli2:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:latest \"*.md\"", "test-docker-hub-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2-rules:v$VERSION davidanson/markdownlint-cli2-rules:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:latest \"*.md\"", @@ -47,26 +47,28 @@ "test-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\"", "test-invoke-as-cli": "markdownlint-cli2 CHANGELOG.md", "test-watch": "git ls-files | entr npm run test", - "update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js", + "update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs", "webworker": "cd webworker && webpack --mode none", - "webworker-install": "npm install --no-package-lock --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.js ./webworker --flat" + "webworker-install": "npm install --no-package-lock --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.js ./webworker --flat --rename=setImmediate.cjs" }, "engines": { "node": ">=18" }, "files": [ - "append-to-array.js", + "append-to-array.mjs", "CHANGELOG.md", - "export-markdownlint.js", - "export-markdownlint-helpers.js", + "export-markdownlint.mjs", + "export-markdownlint-helpers.mjs", + "export-markdownlint-promise.mjs", "LICENSE", - "markdownlint-cli2.js", - "merge-options.js", - "parsers/parsers.js", - "parsers/jsonc-parse.js", - "parsers/yaml-parse.js", + "markdownlint-cli2.mjs", + "markdownlint-cli2-bin.mjs", + "merge-options.mjs", + "parsers/parsers.mjs", + "parsers/jsonc-parse.mjs", + "parsers/yaml-parse.mjs", "README.md", - "resolve-and-require.js", + "resolve-and-require.mjs", "schema/markdownlint-cli2-config-schema.json", "schema/markdownlint-config-schema.json", "schema/ValidatingConfiguration.md" @@ -75,7 +77,7 @@ "globby": "14.0.2", "js-yaml": "4.1.0", "jsonc-parser": "3.3.1", - "markdownlint": "0.36.1", + "markdownlint": "0.37.0", "markdownlint-cli2-formatter-default": "0.0.5", "micromatch": "4.0.8" }, @@ -94,7 +96,6 @@ "eslint-plugin-jsdoc": "50.6.1", "eslint-plugin-n": "17.15.0", "eslint-plugin-unicorn": "56.0.1", - "nano-spawn": "0.2.0", "markdown-it-emoji": "3.0.0", "markdown-it-for-inline": "2.0.1", "markdownlint-cli2-formatter-codequality": "0.0.5", @@ -105,6 +106,7 @@ "markdownlint-cli2-formatter-summarize": "0.0.7", "markdownlint-cli2-formatter-template": "0.0.2", "markdownlint-rule-extended-ascii": "0.1.0", + "nano-spawn": "0.2.0", "npm-run-all": "4.1.5" }, "keywords": [ diff --git a/parsers/jsonc-parse.js b/parsers/jsonc-parse.mjs similarity index 84% rename from parsers/jsonc-parse.js rename to parsers/jsonc-parse.mjs index 3dd30300..446f1778 100644 --- a/parsers/jsonc-parse.js +++ b/parsers/jsonc-parse.mjs @@ -1,8 +1,6 @@ // @ts-check -"use strict"; - -const { parse, printParseErrorCode } = require("jsonc-parser"); +import { parse, printParseErrorCode } from "jsonc-parser"; /** * Parses a JSONC string, returning the corresponding object. @@ -21,4 +19,4 @@ const jsoncParse = (text) => { return result; }; -module.exports = jsoncParse; +export default jsoncParse; diff --git a/parsers/parsers.js b/parsers/parsers.js deleted file mode 100644 index 0676305d..00000000 --- a/parsers/parsers.js +++ /dev/null @@ -1,16 +0,0 @@ -// @ts-check - -"use strict"; - -const jsoncParse = require("./jsonc-parse"); -const yamlParse = require("./yaml-parse"); - -/** - * Array of parser objects ordered by priority. - */ -const parsers = [ - jsoncParse, - yamlParse -]; - -module.exports = parsers; diff --git a/parsers/parsers.mjs b/parsers/parsers.mjs new file mode 100644 index 00000000..8b89bb0c --- /dev/null +++ b/parsers/parsers.mjs @@ -0,0 +1,14 @@ +// @ts-check + +import jsoncParse from "./jsonc-parse.mjs"; +import yamlParse from "./yaml-parse.mjs"; + +/** + * Array of parser objects ordered by priority. + */ +const parsers = [ + jsoncParse, + yamlParse +]; + +export default parsers; diff --git a/parsers/yaml-parse.js b/parsers/yaml-parse.mjs similarity index 74% rename from parsers/yaml-parse.js rename to parsers/yaml-parse.mjs index 22ff335f..0cf404df 100644 --- a/parsers/yaml-parse.js +++ b/parsers/yaml-parse.mjs @@ -1,8 +1,6 @@ // @ts-check -"use strict"; - -const yaml = require("js-yaml"); +import yaml from "js-yaml"; /** * Parses a YAML string, returning the corresponding object. @@ -11,4 +9,4 @@ const yaml = require("js-yaml"); */ const yamlParse = (text) => yaml.load(text); -module.exports = yamlParse; +export default yamlParse; diff --git a/resolve-and-require.js b/resolve-and-require.mjs similarity index 91% rename from resolve-and-require.js rename to resolve-and-require.mjs index 9507698c..8650ee2e 100644 --- a/resolve-and-require.js +++ b/resolve-and-require.mjs @@ -1,7 +1,5 @@ // @ts-check -"use strict"; - /** * Wrapper for calling Node's require.resolve/require with an additional path. * @param {object} req Node's require implementation (or equivalent). @@ -16,4 +14,4 @@ const resolveAndRequire = (req, id, dirs) => { return req(resolved); }; -module.exports = resolveAndRequire; +export default resolveAndRequire; diff --git a/schema/markdownlint-cli2-config-schema.json b/schema/markdownlint-cli2-config-schema.json index 8807180a..af97593a 100644 --- a/schema/markdownlint-cli2-config-schema.json +++ b/schema/markdownlint-cli2-config-schema.json @@ -10,8 +10,8 @@ "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.16.0/schema/markdownlint-cli2-config-schema.json" }, "config": { - "description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/schema/.markdownlint.jsonc", - "$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.36.1/schema/markdownlint-config-schema.json", + "description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/schema/.markdownlint.jsonc", + "$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.37.0/schema/markdownlint-config-schema.json", "default": {} }, "customRules": { diff --git a/schema/markdownlint-config-schema.json b/schema/markdownlint-config-schema.json index 31753a70..cf7dea4f 100644 --- a/schema/markdownlint-config-schema.json +++ b/schema/markdownlint-config-schema.json @@ -1,13 +1,13 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.36.1/schema/markdownlint-config-schema.json", + "$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.37.0/schema/markdownlint-config-schema.json", "title": "markdownlint configuration schema", "type": "object", "properties": { "$schema": { "description": "JSON Schema URI (expected by some editors)", "type": "string", - "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.36.1/schema/markdownlint-config-schema.json" + "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.37.0/schema/markdownlint-config-schema.json" }, "default": { "description": "Default state for all rules", @@ -23,17 +23,17 @@ "default": null }, "MD001": { - "description": "MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md001.md", + "description": "MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md001.md", "type": "boolean", "default": true }, "heading-increment": { - "description": "MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md001.md", + "description": "MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md001.md", "type": "boolean", "default": true }, "MD003": { - "description": "MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md003.md", + "description": "MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md003.md", "type": [ "boolean", "object" @@ -57,7 +57,7 @@ "additionalProperties": false }, "heading-style": { - "description": "MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md003.md", + "description": "MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md003.md", "type": [ "boolean", "object" @@ -81,7 +81,7 @@ "additionalProperties": false }, "MD004": { - "description": "MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md004.md", + "description": "MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md004.md", "type": [ "boolean", "object" @@ -104,7 +104,7 @@ "additionalProperties": false }, "ul-style": { - "description": "MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md004.md", + "description": "MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md004.md", "type": [ "boolean", "object" @@ -127,17 +127,17 @@ "additionalProperties": false }, "MD005": { - "description": "MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md005.md", + "description": "MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md005.md", "type": "boolean", "default": true }, "list-indent": { - "description": "MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md005.md", + "description": "MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md005.md", "type": "boolean", "default": true }, "MD007": { - "description": "MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md007.md", + "description": "MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md007.md", "type": [ "boolean", "object" @@ -165,7 +165,7 @@ "additionalProperties": false }, "ul-indent": { - "description": "MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md007.md", + "description": "MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md007.md", "type": [ "boolean", "object" @@ -193,7 +193,7 @@ "additionalProperties": false }, "MD009": { - "description": "MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md009.md", + "description": "MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md009.md", "type": [ "boolean", "object" @@ -220,7 +220,7 @@ "additionalProperties": false }, "no-trailing-spaces": { - "description": "MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md009.md", + "description": "MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md009.md", "type": [ "boolean", "object" @@ -247,7 +247,7 @@ "additionalProperties": false }, "MD010": { - "description": "MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md010.md", + "description": "MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md010.md", "type": [ "boolean", "object" @@ -277,7 +277,7 @@ "additionalProperties": false }, "no-hard-tabs": { - "description": "MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md010.md", + "description": "MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md010.md", "type": [ "boolean", "object" @@ -307,17 +307,17 @@ "additionalProperties": false }, "MD011": { - "description": "MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md011.md", + "description": "MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md011.md", "type": "boolean", "default": true }, "no-reversed-links": { - "description": "MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md011.md", + "description": "MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md011.md", "type": "boolean", "default": true }, "MD012": { - "description": "MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md012.md", + "description": "MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md012.md", "type": [ "boolean", "object" @@ -334,7 +334,7 @@ "additionalProperties": false }, "no-multiple-blanks": { - "description": "MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md012.md", + "description": "MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md012.md", "type": [ "boolean", "object" @@ -351,7 +351,7 @@ "additionalProperties": false }, "MD013": { - "description": "MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md013.md", + "description": "MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md013.md", "type": [ "boolean", "object" @@ -405,7 +405,7 @@ "additionalProperties": false }, "line-length": { - "description": "MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md013.md", + "description": "MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md013.md", "type": [ "boolean", "object" @@ -459,57 +459,57 @@ "additionalProperties": false }, "MD014": { - "description": "MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md014.md", + "description": "MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md014.md", "type": "boolean", "default": true }, "commands-show-output": { - "description": "MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md014.md", + "description": "MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md014.md", "type": "boolean", "default": true }, "MD018": { - "description": "MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md018.md", + "description": "MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md018.md", "type": "boolean", "default": true }, "no-missing-space-atx": { - "description": "MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md018.md", + "description": "MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md018.md", "type": "boolean", "default": true }, "MD019": { - "description": "MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md019.md", + "description": "MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md019.md", "type": "boolean", "default": true }, "no-multiple-space-atx": { - "description": "MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md019.md", + "description": "MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md019.md", "type": "boolean", "default": true }, "MD020": { - "description": "MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md020.md", + "description": "MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md020.md", "type": "boolean", "default": true }, "no-missing-space-closed-atx": { - "description": "MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md020.md", + "description": "MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md020.md", "type": "boolean", "default": true }, "MD021": { - "description": "MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md021.md", + "description": "MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md021.md", "type": "boolean", "default": true }, "no-multiple-space-closed-atx": { - "description": "MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md021.md", + "description": "MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md021.md", "type": "boolean", "default": true }, "MD022": { - "description": "MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md022.md", + "description": "MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md022.md", "type": [ "boolean", "object" @@ -544,7 +544,7 @@ "additionalProperties": false }, "blanks-around-headings": { - "description": "MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md022.md", + "description": "MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md022.md", "type": [ "boolean", "object" @@ -579,17 +579,17 @@ "additionalProperties": false }, "MD023": { - "description": "MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md023.md", + "description": "MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md023.md", "type": "boolean", "default": true }, "heading-start-left": { - "description": "MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md023.md", + "description": "MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md023.md", "type": "boolean", "default": true }, "MD024": { - "description": "MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md024.md", + "description": "MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md024.md", "type": [ "boolean", "object" @@ -605,7 +605,7 @@ "additionalProperties": false }, "no-duplicate-heading": { - "description": "MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md024.md", + "description": "MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md024.md", "type": [ "boolean", "object" @@ -621,7 +621,7 @@ "additionalProperties": false }, "MD025": { - "description": "MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md025.md", + "description": "MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md025.md", "type": [ "boolean", "object" @@ -644,7 +644,7 @@ "additionalProperties": false }, "single-title": { - "description": "MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md025.md", + "description": "MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md025.md", "type": [ "boolean", "object" @@ -667,7 +667,7 @@ "additionalProperties": false }, "single-h1": { - "description": "MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md025.md", + "description": "MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md025.md", "type": [ "boolean", "object" @@ -690,7 +690,7 @@ "additionalProperties": false }, "MD026": { - "description": "MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md026.md", + "description": "MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md026.md", "type": [ "boolean", "object" @@ -706,7 +706,7 @@ "additionalProperties": false }, "no-trailing-punctuation": { - "description": "MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md026.md", + "description": "MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md026.md", "type": [ "boolean", "object" @@ -722,27 +722,27 @@ "additionalProperties": false }, "MD027": { - "description": "MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md027.md", + "description": "MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md027.md", "type": "boolean", "default": true }, "no-multiple-space-blockquote": { - "description": "MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md027.md", + "description": "MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md027.md", "type": "boolean", "default": true }, "MD028": { - "description": "MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md028.md", + "description": "MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md028.md", "type": "boolean", "default": true }, "no-blanks-blockquote": { - "description": "MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md028.md", + "description": "MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md028.md", "type": "boolean", "default": true }, "MD029": { - "description": "MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md029.md", + "description": "MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md029.md", "type": [ "boolean", "object" @@ -764,7 +764,7 @@ "additionalProperties": false }, "ol-prefix": { - "description": "MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md029.md", + "description": "MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md029.md", "type": [ "boolean", "object" @@ -786,7 +786,7 @@ "additionalProperties": false }, "MD030": { - "description": "MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md030.md", + "description": "MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md030.md", "type": [ "boolean", "object" @@ -821,7 +821,7 @@ "additionalProperties": false }, "list-marker-space": { - "description": "MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md030.md", + "description": "MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md030.md", "type": [ "boolean", "object" @@ -856,7 +856,7 @@ "additionalProperties": false }, "MD031": { - "description": "MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md031.md", + "description": "MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md031.md", "type": [ "boolean", "object" @@ -872,7 +872,7 @@ "additionalProperties": false }, "blanks-around-fences": { - "description": "MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md031.md", + "description": "MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md031.md", "type": [ "boolean", "object" @@ -888,17 +888,17 @@ "additionalProperties": false }, "MD032": { - "description": "MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md032.md", + "description": "MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md032.md", "type": "boolean", "default": true }, "blanks-around-lists": { - "description": "MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md032.md", + "description": "MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md032.md", "type": "boolean", "default": true }, "MD033": { - "description": "MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md033.md", + "description": "MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md033.md", "type": [ "boolean", "object" @@ -917,7 +917,7 @@ "additionalProperties": false }, "no-inline-html": { - "description": "MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md033.md", + "description": "MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md033.md", "type": [ "boolean", "object" @@ -936,17 +936,17 @@ "additionalProperties": false }, "MD034": { - "description": "MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md034.md", + "description": "MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md034.md", "type": "boolean", "default": true }, "no-bare-urls": { - "description": "MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md034.md", + "description": "MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md034.md", "type": "boolean", "default": true }, "MD035": { - "description": "MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md035.md", + "description": "MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md035.md", "type": [ "boolean", "object" @@ -962,7 +962,7 @@ "additionalProperties": false }, "hr-style": { - "description": "MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md035.md", + "description": "MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md035.md", "type": [ "boolean", "object" @@ -978,7 +978,7 @@ "additionalProperties": false }, "MD036": { - "description": "MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md036.md", + "description": "MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md036.md", "type": [ "boolean", "object" @@ -994,7 +994,7 @@ "additionalProperties": false }, "no-emphasis-as-heading": { - "description": "MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md036.md", + "description": "MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md036.md", "type": [ "boolean", "object" @@ -1010,37 +1010,37 @@ "additionalProperties": false }, "MD037": { - "description": "MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md037.md", + "description": "MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md037.md", "type": "boolean", "default": true }, "no-space-in-emphasis": { - "description": "MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md037.md", + "description": "MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md037.md", "type": "boolean", "default": true }, "MD038": { - "description": "MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md038.md", + "description": "MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md038.md", "type": "boolean", "default": true }, "no-space-in-code": { - "description": "MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md038.md", + "description": "MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md038.md", "type": "boolean", "default": true }, "MD039": { - "description": "MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md039.md", + "description": "MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md039.md", "type": "boolean", "default": true }, "no-space-in-links": { - "description": "MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md039.md", + "description": "MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md039.md", "type": "boolean", "default": true }, "MD040": { - "description": "MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md040.md", + "description": "MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md040.md", "type": [ "boolean", "object" @@ -1064,7 +1064,7 @@ "additionalProperties": false }, "fenced-code-language": { - "description": "MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md040.md", + "description": "MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md040.md", "type": [ "boolean", "object" @@ -1088,7 +1088,7 @@ "additionalProperties": false }, "MD041": { - "description": "MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md041.md", + "description": "MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md041.md", "type": [ "boolean", "object" @@ -1111,7 +1111,7 @@ "additionalProperties": false }, "first-line-heading": { - "description": "MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md041.md", + "description": "MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md041.md", "type": [ "boolean", "object" @@ -1134,7 +1134,7 @@ "additionalProperties": false }, "first-line-h1": { - "description": "MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md041.md", + "description": "MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md041.md", "type": [ "boolean", "object" @@ -1157,17 +1157,17 @@ "additionalProperties": false }, "MD042": { - "description": "MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md042.md", + "description": "MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md042.md", "type": "boolean", "default": true }, "no-empty-links": { - "description": "MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md042.md", + "description": "MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md042.md", "type": "boolean", "default": true }, "MD043": { - "description": "MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md043.md", + "description": "MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md043.md", "type": [ "boolean", "object" @@ -1192,7 +1192,7 @@ "additionalProperties": false }, "required-headings": { - "description": "MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md043.md", + "description": "MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md043.md", "type": [ "boolean", "object" @@ -1217,7 +1217,7 @@ "additionalProperties": false }, "MD044": { - "description": "MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md044.md", + "description": "MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md044.md", "type": [ "boolean", "object" @@ -1246,7 +1246,7 @@ "additionalProperties": false }, "proper-names": { - "description": "MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md044.md", + "description": "MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md044.md", "type": [ "boolean", "object" @@ -1275,17 +1275,17 @@ "additionalProperties": false }, "MD045": { - "description": "MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md045.md", + "description": "MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md045.md", "type": "boolean", "default": true }, "no-alt-text": { - "description": "MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md045.md", + "description": "MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md045.md", "type": "boolean", "default": true }, "MD046": { - "description": "MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md046.md", + "description": "MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md046.md", "type": [ "boolean", "object" @@ -1306,7 +1306,7 @@ "additionalProperties": false }, "code-block-style": { - "description": "MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md046.md", + "description": "MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md046.md", "type": [ "boolean", "object" @@ -1327,17 +1327,17 @@ "additionalProperties": false }, "MD047": { - "description": "MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md047.md", + "description": "MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md047.md", "type": "boolean", "default": true }, "single-trailing-newline": { - "description": "MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md047.md", + "description": "MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md047.md", "type": "boolean", "default": true }, "MD048": { - "description": "MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md048.md", + "description": "MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md048.md", "type": [ "boolean", "object" @@ -1358,7 +1358,7 @@ "additionalProperties": false }, "code-fence-style": { - "description": "MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md048.md", + "description": "MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md048.md", "type": [ "boolean", "object" @@ -1379,7 +1379,7 @@ "additionalProperties": false }, "MD049": { - "description": "MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md049.md", + "description": "MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md049.md", "type": [ "boolean", "object" @@ -1400,7 +1400,7 @@ "additionalProperties": false }, "emphasis-style": { - "description": "MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md049.md", + "description": "MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md049.md", "type": [ "boolean", "object" @@ -1421,7 +1421,7 @@ "additionalProperties": false }, "MD050": { - "description": "MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md050.md", + "description": "MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md050.md", "type": [ "boolean", "object" @@ -1442,7 +1442,7 @@ "additionalProperties": false }, "strong-style": { - "description": "MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md050.md", + "description": "MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md050.md", "type": [ "boolean", "object" @@ -1463,7 +1463,7 @@ "additionalProperties": false }, "MD051": { - "description": "MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md051.md", + "description": "MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md051.md", "type": [ "boolean", "object" @@ -1479,7 +1479,7 @@ "additionalProperties": false }, "link-fragments": { - "description": "MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md051.md", + "description": "MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md051.md", "type": [ "boolean", "object" @@ -1495,7 +1495,7 @@ "additionalProperties": false }, "MD052": { - "description": "MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md052.md", + "description": "MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md052.md", "type": [ "boolean", "object" @@ -1511,7 +1511,7 @@ "additionalProperties": false }, "reference-links-images": { - "description": "MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md052.md", + "description": "MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md052.md", "type": [ "boolean", "object" @@ -1527,7 +1527,7 @@ "additionalProperties": false }, "MD053": { - "description": "MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md053.md", + "description": "MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md053.md", "type": [ "boolean", "object" @@ -1548,7 +1548,7 @@ "additionalProperties": false }, "link-image-reference-definitions": { - "description": "MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md053.md", + "description": "MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md053.md", "type": [ "boolean", "object" @@ -1569,7 +1569,7 @@ "additionalProperties": false }, "MD054": { - "description": "MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md054.md", + "description": "MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md054.md", "type": [ "boolean", "object" @@ -1610,7 +1610,7 @@ "additionalProperties": false }, "link-image-style": { - "description": "MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md054.md", + "description": "MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md054.md", "type": [ "boolean", "object" @@ -1651,7 +1651,7 @@ "additionalProperties": false }, "MD055": { - "description": "MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md055.md", + "description": "MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md055.md", "type": [ "boolean", "object" @@ -1674,7 +1674,7 @@ "additionalProperties": false }, "table-pipe-style": { - "description": "MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md055.md", + "description": "MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md055.md", "type": [ "boolean", "object" @@ -1697,22 +1697,22 @@ "additionalProperties": false }, "MD056": { - "description": "MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md056.md", + "description": "MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md056.md", "type": "boolean", "default": true }, "table-column-count": { - "description": "MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md056.md", + "description": "MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md056.md", "type": "boolean", "default": true }, "MD058": { - "description": "MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md058.md", + "description": "MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md058.md", "type": "boolean", "default": true }, "blanks-around-tables": { - "description": "MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md058.md", + "description": "MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.37.0/doc/md058.md", "type": "boolean", "default": true }, diff --git a/test/append-to-array-test.js b/test/append-to-array-test.mjs similarity index 94% rename from test/append-to-array-test.js rename to test/append-to-array-test.mjs index aca4c704..9540dbce 100644 --- a/test/append-to-array-test.js +++ b/test/append-to-array-test.mjs @@ -1,10 +1,7 @@ // @ts-check -"use strict"; - -const test = require("ava").default; -const appendToArray = require("../append-to-array"); -const { sliceSize } = appendToArray; +import test from "ava"; +import appendToArray, { sliceSize } from "../append-to-array.mjs"; const makeArray = (minimum, maximum) => { const length = maximum - minimum + 1; diff --git a/test/config-relative-commonjs/config/any-blockquote.cjs b/test/config-relative-commonjs/config/any-blockquote.cjs index 7e10e220..2de8e13a 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 210715cf..c9c83709 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-invalid/.markdownlint-cli2.jsonc b/test/customRules-invalid/.markdownlint-cli2.jsonc index f6719bd5..e198464b 100644 --- a/test/customRules-invalid/.markdownlint-cli2.jsonc +++ b/test/customRules-invalid/.markdownlint-cli2.jsonc @@ -1,5 +1,5 @@ { "customRules": [ - "markdownlint" + "micromatch" ] } diff --git a/test/customRules-pre-imported/.markdownlint-cli2.cjs b/test/customRules-pre-imported/.markdownlint-cli2.cjs index 98fa5da8..5ba88bee 100644 --- a/test/customRules-pre-imported/.markdownlint-cli2.cjs +++ b/test/customRules-pre-imported/.markdownlint-cli2.cjs @@ -2,7 +2,7 @@ "use strict"; -const anyBlockquote = require("./rules/any-blockquote.js"); +const anyBlockquote = require("./rules/any-blockquote.cjs"); module.exports = { "customRules": [ diff --git a/test/customRules/rules/any-blockquote.js b/test/customRules-pre-imported/rules/any-blockquote.cjs similarity index 94% rename from test/customRules/rules/any-blockquote.js rename to test/customRules-pre-imported/rules/any-blockquote.cjs index 7e10e220..2de8e13a 100644 --- a/test/customRules/rules/any-blockquote.js +++ 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-throws/.markdownlint-cli2.jsonc b/test/customRules-throws/.markdownlint-cli2.jsonc index 59e833f9..5d41a132 100644 --- a/test/customRules-throws/.markdownlint-cli2.jsonc +++ b/test/customRules-throws/.markdownlint-cli2.jsonc @@ -1,5 +1,5 @@ { "customRules": [ - "./rules/throws.js" + "./rules/throws.cjs" ] } diff --git a/test/customRules-throws/rules/throws.js b/test/customRules-throws/rules/throws.cjs similarity index 100% rename from test/customRules-throws/rules/throws.js rename to test/customRules-throws/rules/throws.cjs diff --git a/test/customRules/.markdownlint-cli2.jsonc b/test/customRules/.markdownlint-cli2.jsonc index 1350bd58..599aee08 100644 --- a/test/customRules/.markdownlint-cli2.jsonc +++ b/test/customRules/.markdownlint-cli2.jsonc @@ -1,8 +1,8 @@ { "customRules": [ - "./rules/any-blockquote.js", - "./rules/every-n-lines.js", - "./rules/first-line.js" + "./rules/any-blockquote.cjs", + "./rules/every-n-lines.cjs", + "./rules/first-line.cjs" ], "config": { "every-n-lines": { diff --git a/test/customRules/dir/subdir/.markdownlint-cli2.jsonc b/test/customRules/dir/subdir/.markdownlint-cli2.jsonc index ab641367..66c3cb4b 100644 --- a/test/customRules/dir/subdir/.markdownlint-cli2.jsonc +++ b/test/customRules/dir/subdir/.markdownlint-cli2.jsonc @@ -1,6 +1,6 @@ { "customRules": [ - "../../rules/first-line.js", + "../../rules/first-line.cjs", "../../node_modules/markdownlint-rule-sample-commonjs", "../../node_modules/markdownlint-rule-sample-module/sample-rule.mjs", "markdownlint-rule-extended-ascii" diff --git a/test/customRules/dir3/.markdownlint-cli2.jsonc b/test/customRules/dir3/.markdownlint-cli2.jsonc index 0fed617e..e9a71c6c 100644 --- a/test/customRules/dir3/.markdownlint-cli2.jsonc +++ b/test/customRules/dir3/.markdownlint-cli2.jsonc @@ -1,6 +1,6 @@ { "customRules": [ - "../rules/all-rules", + "../rules/all-rules.cjs", "../node_modules/markdownlint-rule-sample-commonjs", "../node_modules/markdownlint-rule-sample-module/sample-rule.mjs" ] diff --git a/test/customRules/rules/all-rules.cjs b/test/customRules/rules/all-rules.cjs new file mode 100644 index 00000000..b333a173 --- /dev/null +++ b/test/customRules/rules/all-rules.cjs @@ -0,0 +1,10 @@ +// @ts-check + +"use strict"; + +module.exports = [ + require("./any-blockquote.cjs"), + require("./every-n-lines.cjs"), + require("./first-line.cjs"), + require("./second-line.cjs") +]; diff --git a/test/customRules/rules/all-rules.js b/test/customRules/rules/all-rules.js deleted file mode 100644 index 32817133..00000000 --- a/test/customRules/rules/all-rules.js +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-check - -"use strict"; - -module.exports = [ - require("./any-blockquote"), - require("./every-n-lines"), - require("./first-line"), - require("./second-line") -]; diff --git a/test/customRules-pre-imported/rules/any-blockquote.js b/test/customRules/rules/any-blockquote.cjs similarity index 94% rename from test/customRules-pre-imported/rules/any-blockquote.js rename to test/customRules/rules/any-blockquote.cjs index 7e10e220..2de8e13a 100644 --- a/test/customRules-pre-imported/rules/any-blockquote.js +++ 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/customRules/rules/every-n-lines.js b/test/customRules/rules/every-n-lines.cjs similarity index 100% rename from test/customRules/rules/every-n-lines.js rename to test/customRules/rules/every-n-lines.cjs diff --git a/test/customRules/rules/first-line.js b/test/customRules/rules/first-line.cjs similarity index 100% rename from test/customRules/rules/first-line.js rename to test/customRules/rules/first-line.cjs diff --git a/test/customRules/rules/second-line.js b/test/customRules/rules/second-line.cjs similarity index 100% rename from test/customRules/rules/second-line.js rename to test/customRules/rules/second-line.cjs diff --git a/test/esm-helpers.mjs b/test/esm-helpers.mjs new file mode 100644 index 00000000..093e202f --- /dev/null +++ b/test/esm-helpers.mjs @@ -0,0 +1,35 @@ +// @ts-check + +import fs from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +/** + * 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); + +/** + * 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)); + +/** + * 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(meta), file))) +); diff --git a/test/fs-mock-test.js b/test/fs-mock-test.mjs similarity index 73% rename from test/fs-mock-test.js rename to test/fs-mock-test.mjs index f9734e64..4b25de9b 100644 --- a/test/fs-mock-test.js +++ b/test/fs-mock-test.mjs @@ -1,19 +1,19 @@ // @ts-check -"use strict"; - -const path = require("node:path"); -const { promisify } = require("node:util"); -const test = require("ava").default; -const FsMock = require("./fs-mock"); +import fsNodePromises from "node:fs/promises"; +import path from "node:path"; +import { promisify } from "node:util"; +import test from "ava"; +import { __dirname, __filename } from "./esm-helpers.mjs"; +import FsMock from "./fs-mock.mjs"; const mockPath = "/mock"; -const thisFile = path.basename(__filename); +const thisFile = path.basename(__filename(import.meta)); const testFile = path.join(mockPath, thisFile); test("fsMock.stat", async (t) => { t.plan(2); - const fs = new FsMock(__dirname); + const fs = new FsMock(__dirname(import.meta)); const fsStat = promisify(fs.stat); // @ts-ignore const stat = await fsStat(testFile); @@ -23,7 +23,7 @@ test("fsMock.stat", async (t) => { test("fsMock.lstat", async (t) => { t.plan(3); - const fs = new FsMock(__dirname); + const fs = new FsMock(__dirname(import.meta)); const fsLstat = promisify(fs.lstat); // @ts-ignore const stat = await fsLstat(testFile); @@ -34,7 +34,7 @@ test("fsMock.lstat", async (t) => { test("fsMock.lstat symbolic links", async (t) => { t.plan(3); - const fs = new FsMock(__dirname, true); + const fs = new FsMock(__dirname(import.meta), true); const fsLstat = promisify(fs.lstat); // @ts-ignore const stat = await fsLstat(testFile); @@ -45,7 +45,7 @@ test("fsMock.lstat symbolic links", async (t) => { test("fsMock.readdir", async (t) => { t.plan(3); - const fs = new FsMock(__dirname); + const fs = new FsMock(__dirname(import.meta)); const fsReaddir = promisify(fs.readdir); // @ts-ignore const files = await fsReaddir(mockPath); @@ -56,7 +56,7 @@ test("fsMock.readdir", async (t) => { test("fsMock.*", async (t) => { t.plan(1); - const fs = new FsMock(__dirname); + const fs = new FsMock(__dirname(import.meta)); const fsAccess = promisify(fs.access); // @ts-ignore await fsAccess(testFile); @@ -74,7 +74,7 @@ test("fsMock.*", async (t) => { test("fsMock.promises.*", async (t) => { t.plan(2); - const fs = new FsMock(__dirname); + const fs = new FsMock(__dirname(import.meta)); const tempName = "fs-mock.tmp"; const tempFile = path.join(mockPath, tempName); await t.throwsAsync(() => fs.promises.access(tempFile)); @@ -82,5 +82,5 @@ test("fsMock.promises.*", async (t) => { await fs.promises.access(tempFile); await fs.promises.stat(tempFile); t.is(await fs.promises.readFile(tempFile, "utf8"), tempFile); - await require("node:fs").promises.unlink(path.join(__dirname, tempName)); + await fsNodePromises.unlink(path.join(__dirname(import.meta), tempName)); }); diff --git a/test/fs-mock.js b/test/fs-mock.mjs similarity index 87% rename from test/fs-mock.js rename to test/fs-mock.mjs index ad3a4580..655b5d88 100644 --- a/test/fs-mock.js +++ b/test/fs-mock.mjs @@ -1,13 +1,11 @@ // @ts-check -"use strict"; +import fs from "node:fs"; +import nodePath from "node:path"; -const fs = require("node:fs"); - -const mapPath = (base, mockPath) => { - const path = require("node:path"); - return path.resolve(base, path.relative("/mock", mockPath)); -}; +const mapPath = (base, mockPath) => ( + nodePath.resolve(base, nodePath.relative("/mock", mockPath)) +); class fsMock { constructor(base, symbolicLinks) { @@ -56,4 +54,4 @@ class fsMock { } } -module.exports = fsMock; +export default fsMock; diff --git a/test/fs-virtual-test.js b/test/fs-virtual-test.mjs similarity index 88% rename from test/fs-virtual-test.js rename to test/fs-virtual-test.mjs index 1887bc70..ac33a79a 100644 --- a/test/fs-virtual-test.js +++ b/test/fs-virtual-test.mjs @@ -1,19 +1,18 @@ // @ts-check -"use strict"; - -const path = require("node:path"); -const { promisify } = require("node:util"); -const test = require("ava").default; -const FsVirtual = require("../webworker/fs-virtual"); +import path from "node:path"; +import { promisify } from "node:util"; +import test from "ava"; +import { __filename } from "./esm-helpers.mjs"; +import FsVirtual from "../webworker/fs-virtual.cjs"; const mockPath = "/mock"; -const thisFile = path.basename(__filename); +const thisFile = path.basename(__filename(import.meta)); const testFile = path.join(mockPath, thisFile); const missingFile = `${mockPath}/missing`; const virtualFiles = [ - [ "/mock/fs-virtual-test.js", "// content" ] + [ "/mock/fs-virtual-test.mjs", "// content" ] ]; test("fsVirtual.stat", async (t) => { diff --git a/test/markdownlint-cli2-test-cases.js b/test/markdownlint-cli2-test-cases.mjs similarity index 97% rename from test/markdownlint-cli2-test-cases.js rename to test/markdownlint-cli2-test-cases.mjs index 11fdfad6..ac654fac 100644 --- a/test/markdownlint-cli2-test-cases.js +++ b/test/markdownlint-cli2-test-cases.mjs @@ -1,11 +1,10 @@ // @ts-check -"use strict"; - -const fs = require("node:fs").promises; -const os = require("node:os"); -const path = require("node:path"); -const test = require("ava").default; +import fs from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import test from "ava"; +import { __dirname } from "./esm-helpers.mjs"; const noop = () => null; const empty = () => ""; @@ -13,7 +12,7 @@ const sanitize = (str) => str. replace(/\r/gu, ""). replace(/\bv\d+\.\d+\.\d+\b/gu, "vX.Y.Z"). replace(/ :.+[/\\]sentinel/gu, " :[PATH]"); -const sameFileSystem = (path.relative(os.homedir(), __dirname) !== __dirname); +const sameFileSystem = (path.relative(os.homedir(), __dirname(import.meta)) !== __dirname(import.meta)); const isModule = (file) => file.endsWith(".cjs") || file.endsWith(".mjs"); const testCases = ({ @@ -57,7 +56,7 @@ const testCases = ({ } test(`${name} (${host})`, (t) => { t.plan(3); - const directory = path.join(__dirname, cwd || name); + const directory = path.join(__dirname(import.meta), cwd || name); return ((pre || noop)(name, shadow) || Promise.resolve()). then(invoke(directory, args, noRequire, env, script)). then((result) => Promise.all([ @@ -143,13 +142,13 @@ const testCases = ({ const copyDirectory = (dir, alt) => import("cpy").then((cpy) => ( cpy.default( - path.join(__dirname, (alt || dir), "**"), - path.join(__dirname, directoryName(dir)) + path.join(__dirname(import.meta), (alt || dir), "**"), + path.join(__dirname(import.meta), directoryName(dir)) ) )); const deleteDirectory = (dir) => import("del").then((del) => ( - del.deleteAsync(path.join(__dirname, directoryName(dir))) + del.deleteAsync(path.join(__dirname(import.meta), directoryName(dir))) )); testCase({ @@ -588,7 +587,7 @@ const testCases = ({ }); const literalFilesAbsoluteFile = absolute( - path.join(__dirname, "literal-files"), + path.join(__dirname(import.meta), "literal-files"), "sentinel/dir(1)/(view)me.md" ). split(path.sep). @@ -670,7 +669,7 @@ const testCases = ({ "name": `config-files-${configFile}-absolute-arg`, "args": [ "--config", - path.join(__dirname, "config-files", `cfg/${configFile}`), + path.join(__dirname(import.meta), "config-files", `cfg/${configFile}`), "**/*.md" ], "exitCode": 1, @@ -1161,4 +1160,4 @@ const testCases = ({ }; -module.exports = testCases; +export default testCases; diff --git a/test/markdownlint-cli2-test-exec.js b/test/markdownlint-cli2-test-exec.mjs similarity index 86% rename from test/markdownlint-cli2-test-exec.js rename to test/markdownlint-cli2-test-exec.mjs index 394262f5..25749219 100644 --- a/test/markdownlint-cli2-test-exec.js +++ b/test/markdownlint-cli2-test-exec.mjs @@ -1,22 +1,21 @@ // @ts-check -"use strict"; - -const fs = require("node:fs/promises"); -const path = require("node:path"); -const test = require("ava").default; -const testCases = require("./markdownlint-cli2-test-cases"); +import fs from "node:fs/promises"; +import path from "node:path"; +import test from "ava"; +import spawn from "nano-spawn"; +import testCases from "./markdownlint-cli2-test-cases.mjs"; +import { __dirname } from "./esm-helpers.mjs"; const absolute = (rootDir, file) => path.join(rootDir, file); -const repositoryPath = (name) => path.join(__dirname, "..", name); +const repositoryPath = (name) => path.join(__dirname(import.meta), "..", name); const invoke = (directory, args, noRequire, env, script) => async () => { await fs.access(directory); - const { "default": spawn } = await import("nano-spawn"); return spawn( "node", [ - repositoryPath(script || "markdownlint-cli2.js"), + repositoryPath(script || "markdownlint-cli2-bin.mjs"), ...args ], { @@ -42,20 +41,19 @@ testCases({ "includeAbsolute": true }); -const invokeStdin = async (args, stdin, cwd) => { - const { "default": spawn } = await import("nano-spawn"); - return spawn( +const invokeStdin = (args, stdin, cwd) => ( + spawn( "node", [ - repositoryPath("markdownlint-cli2.js"), + repositoryPath("markdownlint-cli2-bin.mjs"), ...args ], { cwd, "stdin": { "string": stdin } } - ); -}; + ) +); const validInput = "# Heading\n\nText\n"; const invalidInput = "# Heading\n\nText"; @@ -160,7 +158,7 @@ test("- parameter uses base directory configuration", (t) => { return invokeStdin( [ "-" ], invalidInput, - path.join(__dirname, "stdin") + path.join(__dirname(import.meta), "stdin") ). then(() => t.fail()). catch((error) => { @@ -174,7 +172,7 @@ test("- parameter not treated as stdin in configuration file globs", (t) => { return invokeStdin( [], invalidInput, - path.join(__dirname, "stdin-globs") + path.join(__dirname(import.meta), "stdin-globs") ). then(() => t.pass()). catch(() => t.fail()); diff --git a/test/markdownlint-cli2-test-exports.js b/test/markdownlint-cli2-test-exports.js deleted file mode 100644 index de1713c1..00000000 --- a/test/markdownlint-cli2-test-exports.js +++ /dev/null @@ -1,31 +0,0 @@ -// @ts-check - -"use strict"; - -const test = require("ava").default; -const packageJson = require("../package.json"); - -const exportMappings = new Map([ - [ ".", ".." ], - [ "./markdownlint", "markdownlint" ], - [ "./markdownlint/helpers", "markdownlint/helpers" ], - [ "./parsers", "../parsers/parsers.js" ], - [ "./parsers/jsonc", "../parsers/jsonc-parse.js" ], - [ "./parsers/yaml", "../parsers/yaml-parse.js" ] -]); - -test("exportMappings", (t) => { - t.deepEqual( - Object.keys(packageJson.exports), - [ ...exportMappings.keys() ] - ); -}); - -for (const [ exportName, exportPath ] of exportMappings) { - test(exportName, (t) => { - t.is( - require(exportName.replace(/^\./u, packageJson.name)), - require(exportPath) - ); - }); -} diff --git a/test/markdownlint-cli2-test-exports.mjs b/test/markdownlint-cli2-test-exports.mjs new file mode 100644 index 00000000..a5ef3561 --- /dev/null +++ b/test/markdownlint-cli2-test-exports.mjs @@ -0,0 +1,34 @@ +// @ts-check + +import test from "ava"; +import { importWithTypeJson } from "./esm-helpers.mjs"; +const packageJson = await importWithTypeJson(import.meta, "../package.json"); + +const exportMappings = new Map([ + [ ".", "../markdownlint-cli2.mjs" ], + [ "./markdownlint", "markdownlint" ], + [ "./markdownlint/helpers", "markdownlint/helpers" ], + [ "./markdownlint/promise", "markdownlint/promise" ], + [ "./parsers", "../parsers/parsers.mjs" ], + [ "./parsers/jsonc", "../parsers/jsonc-parse.mjs" ], + [ "./parsers/yaml", "../parsers/yaml-parse.mjs" ] +]); + +test("exportMappings", (t) => { + t.deepEqual( + Object.keys(packageJson.exports), + [ ...exportMappings.keys() ] + ); +}); + +for (const [ exportName, exportPath ] of exportMappings) { + test(exportName, async (t) => { + const commonJs = exportPath.includes("helpers"); + const importExportName = await import(exportName.replace(/^\./u, packageJson.name)); + const importExportPath = await import(exportPath); + t.deepEqual( + commonJs ? importExportName.default : importExportName, + commonJs ? importExportPath.default : importExportPath + ); + }); +} diff --git a/test/markdownlint-cli2-test-fs.js b/test/markdownlint-cli2-test-fs.mjs similarity index 81% rename from test/markdownlint-cli2-test-fs.js rename to test/markdownlint-cli2-test-fs.mjs index d2b703af..8306a1c2 100644 --- a/test/markdownlint-cli2-test-fs.js +++ b/test/markdownlint-cli2-test-fs.mjs @@ -1,11 +1,9 @@ // @ts-check -"use strict"; - -const path = require("node:path"); -const { "main": markdownlintCli2 } = require("../markdownlint-cli2.js"); -const testCases = require("./markdownlint-cli2-test-cases"); -const FsMock = require("./fs-mock"); +import path from "node:path"; +import { "main" as markdownlintCli2 } from "../markdownlint-cli2.mjs"; +import testCases from "./markdownlint-cli2-test-cases.mjs"; +import FsMock from "./fs-mock.mjs"; const mockDirectory = "/mock"; const linesEndingWithNewLine = diff --git a/test/markdownlint-cli2-test-main.js b/test/markdownlint-cli2-test-main.mjs similarity index 83% rename from test/markdownlint-cli2-test-main.js rename to test/markdownlint-cli2-test-main.mjs index 80e61ca7..067e3bec 100644 --- a/test/markdownlint-cli2-test-main.js +++ b/test/markdownlint-cli2-test-main.mjs @@ -1,10 +1,8 @@ // @ts-check -"use strict"; - -const path = require("node:path"); -const { "main": markdownlintCli2 } = require("../markdownlint-cli2.js"); -const testCases = require("./markdownlint-cli2-test-cases"); +import path from "node:path"; +import { "main" as markdownlintCli2 } from "../markdownlint-cli2.mjs"; +import testCases from "./markdownlint-cli2-test-cases.mjs"; const linesEndingWithNewLine = (lines) => lines.map((line) => `${line}\n`).join(""); diff --git a/test/markdownlint-cli2-test.js b/test/markdownlint-cli2-test.mjs similarity index 90% rename from test/markdownlint-cli2-test.js rename to test/markdownlint-cli2-test.mjs index 43c3f4b7..5e56419e 100644 --- a/test/markdownlint-cli2-test.js +++ b/test/markdownlint-cli2-test.mjs @@ -1,20 +1,23 @@ // @ts-check -"use strict"; - -const fs = require("node:fs/promises"); -const path = require("node:path"); -const Ajv = require("ajv"); -const test = require("ava").default; -const { "main": markdownlintCli2 } = require("../markdownlint-cli2.js"); -const jsoncParse = require("../parsers/jsonc-parse.js"); -const yamlParse = require("../parsers/yaml-parse.js"); -const FsMock = require("./fs-mock"); -const FsVirtual = require("../webworker/fs-virtual"); +import nodeFs from "node:fs"; +import fs from "node:fs/promises"; +import path from "node:path"; +import Ajv from "ajv"; +import test from "ava"; +import { globby } from "globby"; +import { __dirname, importWithTypeJson } from "./esm-helpers.mjs"; +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"; +import FsMock from "./fs-mock.mjs"; +import FsVirtual from "../webworker/fs-virtual.cjs"; +import firstLine from "./customRules/rules/first-line.cjs"; const schemaIdVersionRe = /^.*v(?\d+\.\d+\.\d+).*$/u; -const markdownlintConfigSchemaDefinition = require("../schema/markdownlint-config-schema.json"); -const markdownlintCli2ConfigSchemaDefinition = require("../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; @@ -23,7 +26,6 @@ const outputFormatterLengthIs = (t, length) => (options) => { test("name and version", (t) => { t.plan(3); - const packageJson = require("../package.json"); const logMessage = (msg) => { const match = (/^(?\S+)\sv(?\S+)\s/u).exec(msg); if (match) { @@ -77,7 +79,7 @@ test("validateMarkdownlintConfigSchema", async (t) => { const validateConfigSchema = ajv.compile(markdownlintConfigSchemaDefinition); t.is( markdownlintConfigSchemaDefinition.$id.replace(schemaIdVersionRe, "$"), - require("../package.json").dependencies.markdownlint + packageJson.dependencies.markdownlint ); t.is( markdownlintConfigSchemaDefinition.$id, @@ -85,7 +87,6 @@ test("validateMarkdownlintConfigSchema", async (t) => { ); // Validate instances - const { globby } = await import("globby"); const files = await globby( [ "**/*.markdownlint.(json|jsonc)", @@ -123,7 +124,7 @@ test("validateMarkdownlintCli2ConfigSchema", async (t) => { const validateConfigSchema = ajv.compile(markdownlintCli2ConfigSchemaDefinition); t.is( markdownlintCli2ConfigSchemaDefinition.$id.replace(schemaIdVersionRe, "$"), - require("../package.json").version + packageJson.version ); t.is( markdownlintCli2ConfigSchemaDefinition.$id, @@ -131,7 +132,6 @@ test("validateMarkdownlintCli2ConfigSchema", async (t) => { ); // Validate instances - const { globby } = await import("globby"); const files = await globby( [ "**/*.markdownlint-cli2.(json|jsonc)", @@ -200,7 +200,7 @@ test("main options default", (t) => { "directory": "test/main-options-default", "argv": [ "info.md" ], "optionsDefault": { - "customRules": [ require("./customRules/rules/first-line") ] + "customRules": [ firstLine ] } }) ]). @@ -294,7 +294,7 @@ test("alternate file contents with ignores", (t) => { test("extension scenario, file, no changes", (t) => { t.plan(2); return markdownlintCli2({ - "directory": __dirname, + "directory": __dirname(import.meta), "argv": [ ":./markdownlint-json/viewme.md" ], "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 4) ] ] @@ -306,7 +306,7 @@ test("extension scenario, file, no changes", (t) => { test("extension scenario, file, changes", (t) => { t.plan(2); return markdownlintCli2({ - "directory": __dirname, + "directory": __dirname(import.meta), "argv": [ ":./markdownlint-json/viewme.md" ], "fileContents": { "./markdownlint-json/viewme.md": "# Title\n\n> Tagline \n\n\n" @@ -321,7 +321,7 @@ test("extension scenario, file, changes", (t) => { test("extension scenario, no file", (t) => { t.plan(2); return markdownlintCli2({ - "directory": __dirname, + "directory": __dirname(import.meta), "argv": [], "nonFileContents": { "untitled-1": "# Title\n\nText\t\n" @@ -336,7 +336,7 @@ test("extension scenario, no file", (t) => { test("extension scenario, no file, empty", (t) => { t.plan(2); return markdownlintCli2({ - "directory": __dirname, + "directory": __dirname(import.meta), "argv": [], "nonFileContents": { "untitled-1": "" @@ -360,7 +360,7 @@ test("extension scenario, ignores handled", (t) => { }; const argv = Object.keys(fileContents).map((key) => `:${key}`); return markdownlintCli2({ - "directory": path.join(__dirname, "extension-scenario-ignores"), + "directory": path.join(__dirname(import.meta), "extension-scenario-ignores"), argv, fileContents, "optionsOverride": { @@ -372,7 +372,7 @@ test("extension scenario, ignores handled", (t) => { test("extension scenario, ignores handled, absolute paths", (t) => { t.plan(2); - const directory = path.join(__dirname, "extension-scenario-ignores"); + const directory = path.join(__dirname(import.meta), "extension-scenario-ignores"); const fileContents = Object.fromEntries( Object.entries({ "viewme.md": "Heading", @@ -401,7 +401,7 @@ test("extension scenario, ignores handled, absolute paths", (t) => { test("extension scenario, globs ignored/filtered", (t) => { t.plan(2); return markdownlintCli2({ - "directory": path.join(__dirname, "extension-scenario-globs"), + "directory": path.join(__dirname(import.meta), "extension-scenario-globs"), "argv": [ ":viewme.md", ":dir/viewme.md", @@ -425,14 +425,14 @@ test("extension scenario, globs ignored/filtered", (t) => { test("backslash translation", (t) => { t.plan(2); return markdownlintCli2({ - "directory": __dirname, + "directory": __dirname(import.meta), "argv": [ "./markdownlint-json/viewme.md", "markdownlint-jsonc/viewme.md", - path.join(__dirname, "markdownlint-cli2-jsonc/viewme.md"), + path.join(__dirname(import.meta), "markdownlint-cli2-jsonc/viewme.md"), ".\\markdownlint-yml\\viewme.md", "markdownlint-yaml\\viewme.md", - path.join(__dirname, "markdownlint-cli2-yaml\\viewme.md") + path.join(__dirname(import.meta), "markdownlint-cli2-yaml\\viewme.md") ], "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 24) ] ] @@ -563,7 +563,7 @@ test("custom fs, using node:fs", (t) => { "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ] }, - "fs": require("node:fs") + "fs": nodeFs }). then((exitCode) => { t.is(exitCode, 1); @@ -578,7 +578,7 @@ test("custom fs, using node:fs and noRequire=false", (t) => { "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 11) ] ] }, - "fs": require("node:fs"), + "fs": nodeFs, "noRequire": false }). then((exitCode) => { @@ -594,7 +594,7 @@ test("custom fs, using node:fs and noRequire=true", (t) => { "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 14) ] ] }, - "fs": require("node:fs"), + "fs": nodeFs, "noRequire": true }). then((exitCode) => { @@ -610,7 +610,7 @@ test("custom fs, using fsMock", (t) => { "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ] }, - "fs": new FsMock(path.join(__dirname, "markdownlint-cli2-jsonc")), + "fs": new FsMock(path.join(__dirname(import.meta), "markdownlint-cli2-jsonc")), "noRequire": true }). then((exitCode) => { @@ -626,7 +626,7 @@ test("custom fs, using fsMock simulating symbolic links", (t) => { "optionsOverride": { "outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ] }, - "fs": new FsMock(path.join(__dirname, "markdownlint-cli2-jsonc"), true), + "fs": new FsMock(path.join(__dirname(import.meta), "markdownlint-cli2-jsonc"), true), "noRequire": true }). then((exitCode) => { diff --git a/test/merge-options-test.js b/test/merge-options-test.mjs similarity index 96% rename from test/merge-options-test.js rename to test/merge-options-test.mjs index a13ade7f..ada5c695 100644 --- a/test/merge-options-test.js +++ b/test/merge-options-test.mjs @@ -1,9 +1,7 @@ // @ts-check -"use strict"; - -const test = require("ava").default; -const mergeOptions = require("../merge-options"); +import test from "ava"; +import mergeOptions from "../merge-options.mjs"; test("null/null", (t) => { t.plan(1); diff --git a/test/nested-options-config/config-options-disjoint-empty/dir/dir/.markdownlint-cli2.jsonc b/test/nested-options-config/config-options-disjoint-empty/dir/dir/.markdownlint-cli2.jsonc index 3b0219dc..9f3778dd 100644 --- a/test/nested-options-config/config-options-disjoint-empty/dir/dir/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/config-options-disjoint-empty/dir/dir/.markdownlint-cli2.jsonc @@ -1,5 +1,5 @@ { "customRules": [ - "../../../first-line.js" + "../../../first-line.cjs" ] } diff --git a/test/nested-options-config/config-options-disjoint/dir/dir/.markdownlint-cli2.jsonc b/test/nested-options-config/config-options-disjoint/dir/dir/.markdownlint-cli2.jsonc index 3b0219dc..9f3778dd 100644 --- a/test/nested-options-config/config-options-disjoint/dir/dir/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/config-options-disjoint/dir/dir/.markdownlint-cli2.jsonc @@ -1,5 +1,5 @@ { "customRules": [ - "../../../first-line.js" + "../../../first-line.cjs" ] } diff --git a/test/nested-options-config/config-options-overlap-empty/dir/dir/.markdownlint-cli2.jsonc b/test/nested-options-config/config-options-overlap-empty/dir/dir/.markdownlint-cli2.jsonc index 4569433e..c8e78b72 100644 --- a/test/nested-options-config/config-options-overlap-empty/dir/dir/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/config-options-overlap-empty/dir/dir/.markdownlint-cli2.jsonc @@ -1,6 +1,6 @@ { "customRules": [ - "../../../first-line.js" + "../../../first-line.cjs" ], "config": { "no-space-in-code": false diff --git a/test/nested-options-config/config-options-overlap/dir/dir/.markdownlint-cli2.jsonc b/test/nested-options-config/config-options-overlap/dir/dir/.markdownlint-cli2.jsonc index 4569433e..c8e78b72 100644 --- a/test/nested-options-config/config-options-overlap/dir/dir/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/config-options-overlap/dir/dir/.markdownlint-cli2.jsonc @@ -1,6 +1,6 @@ { "customRules": [ - "../../../first-line.js" + "../../../first-line.cjs" ], "config": { "no-space-in-code": false diff --git a/test/nested-options-config/first-line.js b/test/nested-options-config/first-line.cjs similarity index 100% rename from test/nested-options-config/first-line.js rename to test/nested-options-config/first-line.cjs diff --git a/test/nested-options-config/options-config-disjoint-empty/.markdownlint-cli2.jsonc b/test/nested-options-config/options-config-disjoint-empty/.markdownlint-cli2.jsonc index 37174581..07bd66bb 100644 --- a/test/nested-options-config/options-config-disjoint-empty/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/options-config-disjoint-empty/.markdownlint-cli2.jsonc @@ -1,5 +1,5 @@ { "customRules": [ - "../first-line.js" + "../first-line.cjs" ] } diff --git a/test/nested-options-config/options-config-disjoint/.markdownlint-cli2.jsonc b/test/nested-options-config/options-config-disjoint/.markdownlint-cli2.jsonc index 37174581..07bd66bb 100644 --- a/test/nested-options-config/options-config-disjoint/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/options-config-disjoint/.markdownlint-cli2.jsonc @@ -1,5 +1,5 @@ { "customRules": [ - "../first-line.js" + "../first-line.cjs" ] } diff --git a/test/nested-options-config/options-config-overlap-empty/.markdownlint-cli2.jsonc b/test/nested-options-config/options-config-overlap-empty/.markdownlint-cli2.jsonc index 8c0936d0..ee852567 100644 --- a/test/nested-options-config/options-config-overlap-empty/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/options-config-overlap-empty/.markdownlint-cli2.jsonc @@ -1,6 +1,6 @@ { "customRules": [ - "../first-line.js" + "../first-line.cjs" ], "config": { "no-space-in-code": false diff --git a/test/nested-options-config/options-config-overlap/.markdownlint-cli2.jsonc b/test/nested-options-config/options-config-overlap/.markdownlint-cli2.jsonc index 8c0936d0..ee852567 100644 --- a/test/nested-options-config/options-config-overlap/.markdownlint-cli2.jsonc +++ b/test/nested-options-config/options-config-overlap/.markdownlint-cli2.jsonc @@ -1,6 +1,6 @@ { "customRules": [ - "../first-line.js" + "../first-line.cjs" ], "config": { "no-space-in-code": false diff --git a/test/resolve-and-require-test.js b/test/resolve-and-require-test.mjs similarity index 69% rename from test/resolve-and-require-test.js rename to test/resolve-and-require-test.mjs index 49038b38..54049592 100644 --- a/test/resolve-and-require-test.js +++ b/test/resolve-and-require-test.mjs @@ -1,37 +1,37 @@ // @ts-check -"use strict"; +import test from "ava"; +import path from "node:path"; +import { __dirname } from "./esm-helpers.mjs"; +import resolveAndRequire from "../resolve-and-require.mjs"; -const test = require("ava").default; -const path = require("node:path"); -const resolveAndRequire = require("../resolve-and-require"); - -/* eslint-disable n/no-missing-require */ +import { createRequire } from "node:module"; +const require = createRequire(import.meta.url); test("built-in module", (t) => { t.plan(1); t.deepEqual( require("node:fs"), - resolveAndRequire(require, "fs", [ __dirname ]) + resolveAndRequire(require, "fs", [ __dirname(import.meta) ]) ); }); test("locally-installed module", (t) => { t.plan(1); t.deepEqual( - require("markdownlint"), - resolveAndRequire(require, "markdownlint", [ __dirname ]) + require("micromatch"), + resolveAndRequire(require, "micromatch", [ __dirname(import.meta) ]) ); }); -test("relative (to __dirname) path to module", (t) => { +test("relative (to __dirname(import.meta)) path to module", (t) => { t.plan(1); t.deepEqual( require("./customRules/node_modules/markdownlint-rule-sample-commonjs"), resolveAndRequire( require, "./customRules/node_modules/markdownlint-rule-sample-commonjs", - [ __dirname ] + [ __dirname(import.meta) ] ) ); }); @@ -48,7 +48,7 @@ test("module in alternate node_modules", (t) => { resolveAndRequire( require, "markdownlint-rule-sample-commonjs", - [ path.join(__dirname, "customRules") ] + [ path.join(__dirname(import.meta), "customRules") ] ) ); }); @@ -67,7 +67,7 @@ test("module in alternate node_modules and no require.resolve.paths", (t) => { resolveAndRequire( require, "markdownlint-rule-sample-commonjs", - [ path.join(__dirname, "customRules") ] + [ path.join(__dirname(import.meta), "customRules") ] ) ); }); @@ -75,12 +75,12 @@ test("module in alternate node_modules and no require.resolve.paths", (t) => { test("module local, relative, and in alternate node_modules", (t) => { t.plan(3); const dirs = [ - __dirname, - path.join(__dirname, "customRules") + __dirname(import.meta), + path.join(__dirname(import.meta), "customRules") ]; t.deepEqual( - require("markdownlint"), - resolveAndRequire(require, "markdownlint", dirs) + require("micromatch"), + resolveAndRequire(require, "micromatch", dirs) ); t.deepEqual( require("./customRules/node_modules/markdownlint-rule-sample-commonjs"), diff --git a/test/snapshots/markdownlint-cli2-test-exec.js.md b/test/snapshots/markdownlint-cli2-test-exec.mjs.md similarity index 99% rename from test/snapshots/markdownlint-cli2-test-exec.js.md rename to test/snapshots/markdownlint-cli2-test-exec.mjs.md index 9981bbff..a0eb78ec 100644 --- a/test/snapshots/markdownlint-cli2-test-exec.js.md +++ b/test/snapshots/markdownlint-cli2-test-exec.mjs.md @@ -1,6 +1,6 @@ -# Snapshot report for `test/markdownlint-cli2-test-exec.js` +# Snapshot report for `test/markdownlint-cli2-test-exec.mjs` -The actual snapshot is saved in `markdownlint-cli2-test-exec.js.snap`. +The actual snapshot is saved in `markdownlint-cli2-test-exec.mjs.snap`. Generated by [AVA](https://avajs.dev). diff --git a/test/snapshots/markdownlint-cli2-test-exec.js.snap b/test/snapshots/markdownlint-cli2-test-exec.mjs.snap similarity index 100% rename from test/snapshots/markdownlint-cli2-test-exec.js.snap rename to test/snapshots/markdownlint-cli2-test-exec.mjs.snap diff --git a/test/snapshots/markdownlint-cli2-test-fs.js.md b/test/snapshots/markdownlint-cli2-test-fs.mjs.md similarity index 99% rename from test/snapshots/markdownlint-cli2-test-fs.js.md rename to test/snapshots/markdownlint-cli2-test-fs.mjs.md index 47abcbb8..d76a9c20 100644 --- a/test/snapshots/markdownlint-cli2-test-fs.js.md +++ b/test/snapshots/markdownlint-cli2-test-fs.mjs.md @@ -1,6 +1,6 @@ -# Snapshot report for `test/markdownlint-cli2-test-fs.js` +# Snapshot report for `test/markdownlint-cli2-test-fs.mjs` -The actual snapshot is saved in `markdownlint-cli2-test-fs.js.snap`. +The actual snapshot is saved in `markdownlint-cli2-test-fs.mjs.snap`. Generated by [AVA](https://avajs.dev). diff --git a/test/snapshots/markdownlint-cli2-test-fs.js.snap b/test/snapshots/markdownlint-cli2-test-fs.mjs.snap similarity index 100% rename from test/snapshots/markdownlint-cli2-test-fs.js.snap rename to test/snapshots/markdownlint-cli2-test-fs.mjs.snap diff --git a/test/snapshots/markdownlint-cli2-test-main.js.md b/test/snapshots/markdownlint-cli2-test-main.mjs.md similarity index 99% rename from test/snapshots/markdownlint-cli2-test-main.js.md rename to test/snapshots/markdownlint-cli2-test-main.mjs.md index 2262b32b..d5683840 100644 --- a/test/snapshots/markdownlint-cli2-test-main.js.md +++ b/test/snapshots/markdownlint-cli2-test-main.mjs.md @@ -1,6 +1,6 @@ -# Snapshot report for `test/markdownlint-cli2-test-main.js` +# Snapshot report for `test/markdownlint-cli2-test-main.mjs` -The actual snapshot is saved in `markdownlint-cli2-test-main.js.snap`. +The actual snapshot is saved in `markdownlint-cli2-test-main.mjs.snap`. Generated by [AVA](https://avajs.dev). diff --git a/test/snapshots/markdownlint-cli2-test-main.js.snap b/test/snapshots/markdownlint-cli2-test-main.mjs.snap similarity index 100% rename from test/snapshots/markdownlint-cli2-test-main.js.snap rename to test/snapshots/markdownlint-cli2-test-main.mjs.snap diff --git a/test/tilde-paths-commonjs/scripts/any-blockquote.cjs b/test/tilde-paths-commonjs/scripts/any-blockquote.cjs index 7e10e220..2de8e13a 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 210715cf..c9c83709 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", diff --git a/webworker/fs-virtual.js b/webworker/fs-virtual.cjs similarity index 100% rename from webworker/fs-virtual.js rename to webworker/fs-virtual.cjs diff --git a/webworker/index.html b/webworker/index.html index e6f2ec36..93697b1c 100644 --- a/webworker/index.html +++ b/webworker/index.html @@ -10,9 +10,9 @@
- - - - + + + + diff --git a/webworker/index.js b/webworker/index.js deleted file mode 100644 index 0f19a768..00000000 --- a/webworker/index.js +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-check - -"use strict"; - -module.exports = require("../markdownlint-cli2.js"); diff --git a/webworker/module-empty.js b/webworker/module-empty.cjs similarity index 100% rename from webworker/module-empty.js rename to webworker/module-empty.cjs diff --git a/webworker/module-stub.cjs b/webworker/module-stub.cjs new file mode 100644 index 00000000..fec94871 --- /dev/null +++ b/webworker/module-stub.cjs @@ -0,0 +1,8 @@ +// @ts-check + +"use strict"; + +module.exports = { + // @ts-ignore + "createRequire": () => require +}; diff --git a/webworker/os-stub.js b/webworker/os-stub.cjs similarity index 100% rename from webworker/os-stub.js rename to webworker/os-stub.cjs diff --git a/webworker/process-stub.js b/webworker/process-stub.cjs similarity index 89% rename from webworker/process-stub.js rename to webworker/process-stub.cjs index f4245d09..6db93931 100644 --- a/webworker/process-stub.js +++ b/webworker/process-stub.cjs @@ -3,6 +3,7 @@ "use strict"; module.exports = { + "argv": [], "cwd": () => "/", "env": {}, "versions": { diff --git a/webworker/unicorn-magic-stub.js b/webworker/unicorn-magic-stub.cjs similarity index 100% rename from webworker/unicorn-magic-stub.js rename to webworker/unicorn-magic-stub.cjs diff --git a/webworker/webpack.config.js b/webworker/webpack.config.cjs similarity index 70% rename from webworker/webpack.config.js rename to webworker/webpack.config.cjs index 2fcc75ee..ae385325 100644 --- a/webworker/webpack.config.js +++ b/webworker/webpack.config.cjs @@ -7,12 +7,13 @@ const webpack = require("webpack"); const nodeModulePrefixRe = /^node:/u; +/** @type {import("webpack").Configuration} */ module.exports = { "target": "webworker", - "entry": "./index.js", + "entry": "../markdownlint-cli2.mjs", "output": { "path": __dirname, - "filename": "markdownlint-cli2-webworker.js", + "filename": "markdownlint-cli2-webworker.cjs", "library": { "name": "markdownlintCli2", "type": "var" @@ -31,14 +32,14 @@ module.exports = { new webpack.NormalModuleReplacementPlugin( /^stream\/(?:consumers|promises)$/u, (resource) => { - resource.request = require.resolve("./module-empty.js"); + resource.request = require.resolve("./module-empty.cjs"); } ), // Intercept existing "unicorn-magic" package to provide missing import new webpack.NormalModuleReplacementPlugin( /^unicorn-magic$/u, (resource) => { - resource.request = require.resolve("./unicorn-magic-stub.js"); + resource.request = require.resolve("./unicorn-magic-stub.cjs"); } ), // Intercept use of "process" to provide implementation @@ -50,12 +51,18 @@ module.exports = { "fallback": { "buffer": false, "fs": false, - "os": require.resolve("./os-stub.js"), + "module": require.resolve("./module-stub.cjs"), + "os": require.resolve("./os-stub.cjs"), "path": require.resolve("path-browserify"), - "process": require.resolve("./process-stub.js"), - "process-wrapper": require.resolve("./process-stub.js"), + "process": require.resolve("./process-stub.cjs"), + "process-wrapper": require.resolve("./process-stub.cjs"), "stream": require.resolve("stream-browserify"), - "url": require.resolve("./module-empty.js") + "url": require.resolve("./module-empty.cjs") } - } + }, + "ignoreWarnings": [ + { + "message": /dependencies cannot be statically extracted/u + } + ] }; diff --git a/webworker/webworker-test.js b/webworker/webworker-test.cjs similarity index 100% rename from webworker/webworker-test.js rename to webworker/webworker-test.cjs