mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Add Promise-based APIs for markdownlint and readConfig, update declaration file.
This commit is contained in:
parent
1f6a2cdc96
commit
e9d63a6284
5 changed files with 201 additions and 45 deletions
|
@ -64,11 +64,14 @@ function assertLintResultsCallback(err: Error | null, results?: markdownlint.Lin
|
|||
assertConfiguration(markdownlint.readConfigSync(markdownlintJsonPath));
|
||||
assertConfiguration(markdownlint.readConfigSync(markdownlintJsonPath, [ JSON.parse ]));
|
||||
|
||||
// The following call is valid, but disallowed because TypeScript does not
|
||||
// currently propagate {ConfigurationParser[] | null} into the .d.ts file.
|
||||
// markdownlint.readConfig(markdownlintJsonPath, null, assertConfigCallback);
|
||||
markdownlint.readConfig(markdownlintJsonPath, assertConfigurationCallback);
|
||||
markdownlint.readConfig(markdownlintJsonPath, [ JSON.parse ], assertConfigurationCallback);
|
||||
|
||||
(async () => {
|
||||
assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath));
|
||||
assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath, [ JSON.parse ]))
|
||||
})();
|
||||
|
||||
let options: markdownlint.Options;
|
||||
options = {
|
||||
"files": [ "../bad.md" ],
|
||||
|
@ -91,10 +94,16 @@ options = {
|
|||
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
markdownlint(options, assertLintResultsCallback);
|
||||
(async () => {
|
||||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
})();
|
||||
|
||||
options.files = "../bad.md";
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
markdownlint(options, assertLintResultsCallback);
|
||||
(async () => {
|
||||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
})();
|
||||
|
||||
const testRule = {
|
||||
"names": [ "test-rule" ],
|
||||
|
@ -139,3 +148,6 @@ const testRule = {
|
|||
options.customRules = [ testRule ];
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
markdownlint(options, assertLintResultsCallback);
|
||||
(async () => {
|
||||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue