mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update to use named exports via / /async /promise /sync, simplify references via self-referencing, refine examples.
This commit is contained in:
parent
e41f034bef
commit
8da43dd246
96 changed files with 635 additions and 548 deletions
|
|
@ -1,6 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
import markdownlint from "markdownlint";
|
||||
import { applyFixes } from "markdownlint";
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
import { lint as lintPromise } from "markdownlint/promise";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
|
|
@ -10,27 +13,39 @@ const options = {
|
|||
}
|
||||
};
|
||||
|
||||
// Makes a synchronous call, using result.toString for pretty formatting
|
||||
const result = markdownlint.sync(options);
|
||||
console.log(result.toString());
|
||||
if (true) {
|
||||
|
||||
// Makes an asynchronous call
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
// @ts-ignore
|
||||
console.log(result.toString());
|
||||
}
|
||||
});
|
||||
// Makes a synchronous call, uses result.toString for pretty formatting
|
||||
const results = lintSync(options);
|
||||
console.log(results.toString());
|
||||
|
||||
// Displays the result object directly
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
console.dir(result, { "colors": true, "depth": null });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Fixes all supported violations in Markdown content
|
||||
const original = "# Heading";
|
||||
const fixResults = markdownlint.sync({ "strings": { "content": original } });
|
||||
const fixed = markdownlint.applyFixes(original, fixResults.content);
|
||||
console.log(fixed);
|
||||
if (true) {
|
||||
|
||||
// Makes an asynchronous call, uses result.toString for pretty formatting
|
||||
lintAsync(options, function callback(error, results) {
|
||||
if (!error && results) {
|
||||
console.log(results.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
||||
// Makes a Promise-based asynchronous call, displays the result object directly
|
||||
const results = await lintPromise(options);
|
||||
console.dir(results, { "colors": true, "depth": null });
|
||||
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
||||
// Fixes all supported violations in Markdown content
|
||||
const original = "# Heading";
|
||||
const results = lintSync({ "strings": { "content": original } });
|
||||
const fixed = applyFixes(original, results.content);
|
||||
console.log(fixed);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue