Skip to content

Commit

Permalink
Update code for new markdownlint library version.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Oct 29, 2024
1 parent 2ec8a3c commit e6fb323
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 121 deletions.
2 changes: 1 addition & 1 deletion doc/OutputFormatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.35.0/lib/markdownlint.d.ts
[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.36.1/lib/markdownlint.d.ts
20 changes: 12 additions & 8 deletions markdownlint-cli2.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ const pathDefault = require("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
} = markdownlintLibrary.promises;
const markdownlintRuleHelpers = require("markdownlint/helpers");
} = markdownlintPromises;
const appendToArray = require("./append-to-array");
const mergeOptions = require("./merge-options");
const resolveAndRequire = require("./resolve-and-require");
Expand All @@ -28,7 +32,7 @@ const resolveAndRequire = require("./resolve-and-require");
const packageName = "markdownlint-cli2";
const packageVersion = "0.14.0";
const libraryName = "markdownlint";
const libraryVersion = markdownlintLibrary.getVersion();
const libraryVersion = getLibraryVersion();
const bannerMessage = `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`;
const dotOnlySubstitute = "*.{md,markdown}";
const utf8 = "utf8";
Expand Down Expand Up @@ -61,9 +65,10 @@ const throwForConfigurationFile = (file, error) => {
const posixPath = (p) => p.split(pathDefault.sep).join(pathPosix.sep);

// Expands a path with a tilde to an absolute path
const expandTildePath = (id) => (
markdownlintRuleHelpers.expandTildePath(id, require("node:os"))
);
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) => (
Expand Down Expand Up @@ -811,8 +816,7 @@ const lintFiles = (fs, dirInfos, fileContents) => {
options.files.push(fileName);
subTasks.push(fs.promises.readFile(fileName, utf8).
then((original) => {
const fixed = markdownlintRuleHelpers.
applyFixes(original, errorInfos);
const fixed = applyFixes(original, errorInfos);
return fs.promises.writeFile(fileName, fixed, utf8);
})
);
Expand Down
4 changes: 2 additions & 2 deletions schema/markdownlint-cli2-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.14.0/schema/markdownlint-cli2-config-schema.json"
},
"config": {
"description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/schema/.markdownlint.jsonc",
"$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.35.0/schema/markdownlint-config-schema.json",
"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",
"default": {}
},
"customRules": {
Expand Down
Loading

0 comments on commit e6fb323

Please sign in to comment.