mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Address new @ts-check warnings in markdownlint-test.js.
This commit is contained in:
parent
3bf4bb1cda
commit
64159fa456
4 changed files with 24 additions and 19 deletions
|
|
@ -1906,7 +1906,7 @@ function newResults(ruleList) {
|
|||
* Remove front matter (if present at beginning of content).
|
||||
*
|
||||
* @param {string} content Markdown content.
|
||||
* @param {RegExp} frontMatter Regular expression to match front matter.
|
||||
* @param {RegExp | null} frontMatter Regular expression to match front matter.
|
||||
* @returns {Object} Trimmed content and front matter lines.
|
||||
*/
|
||||
function removeFrontMatter(content, frontMatter) {
|
||||
|
|
@ -2368,7 +2368,7 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
|
|||
* @param {Object} md Instance of markdown-it.
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
||||
* @param {RegExp} frontMatter Regular expression for front matter.
|
||||
* @param {RegExp | null} frontMatter Regular expression for front matter.
|
||||
* @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
|
||||
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
||||
* @param {number} resultVersion Version of the LintResults object to return.
|
||||
|
|
@ -2629,7 +2629,7 @@ function lintContent(ruleList, name, content, md, config, configParsers, frontMa
|
|||
* @param {Object} md Instance of markdown-it.
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
||||
* @param {RegExp} frontMatter Regular expression for front matter.
|
||||
* @param {RegExp | null} frontMatter Regular expression for front matter.
|
||||
* @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
|
||||
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
||||
* @param {number} resultVersion Version of the LintResults object to return.
|
||||
|
|
@ -2657,7 +2657,7 @@ function lintFile(ruleList, file, md, config, configParsers, frontMatter, handle
|
|||
/**
|
||||
* Lint files and strings specified in the Options object.
|
||||
*
|
||||
* @param {Options} options Options object.
|
||||
* @param {Options | null} options Options object.
|
||||
* @param {boolean} synchronous Whether to execute synchronously.
|
||||
* @param {Function} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
|
|
@ -2766,7 +2766,7 @@ function lintInput(options, synchronous, callback) {
|
|||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
|
@ -2789,7 +2789,7 @@ function markdownlintPromise(options) {
|
|||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
function markdownlintSync(options) {
|
||||
|
|
@ -3085,7 +3085,7 @@ module.exports = markdownlint;
|
|||
* @property {ConfigurationParser[]} [configParsers] Configuration parsers.
|
||||
* @property {Rule[] | Rule} [customRules] Custom rules.
|
||||
* @property {string[] | string} [files] Files to lint.
|
||||
* @property {RegExp} [frontMatter] Front matter pattern.
|
||||
* @property {RegExp | null} [frontMatter] Front matter pattern.
|
||||
* @property {Object} [fs] File system implementation.
|
||||
* @property {boolean} [handleRuleFailures] True to catch exceptions.
|
||||
* @property {Plugin[]} [markdownItPlugins] Additional plugins.
|
||||
|
|
|
|||
10
lib/markdownlint.d.ts
vendored
10
lib/markdownlint.d.ts
vendored
|
|
@ -2,11 +2,11 @@ export = markdownlint;
|
|||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function markdownlint(options: Options, callback: LintCallback): void;
|
||||
declare function markdownlint(options: Options | null, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ type Options = {
|
|||
/**
|
||||
* Front matter pattern.
|
||||
*/
|
||||
frontMatter?: RegExp;
|
||||
frontMatter?: RegExp | null;
|
||||
/**
|
||||
* File system implementation.
|
||||
*/
|
||||
|
|
@ -68,10 +68,10 @@ type LintCallback = (err: Error | null, results?: LintResults) => void;
|
|||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
declare function markdownlintSync(options: Options): LintResults;
|
||||
declare function markdownlintSync(options: Options | null): LintResults;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ function newResults(ruleList) {
|
|||
* Remove front matter (if present at beginning of content).
|
||||
*
|
||||
* @param {string} content Markdown content.
|
||||
* @param {RegExp} frontMatter Regular expression to match front matter.
|
||||
* @param {RegExp | null} frontMatter Regular expression to match front matter.
|
||||
* @returns {Object} Trimmed content and front matter lines.
|
||||
*/
|
||||
function removeFrontMatter(content, frontMatter) {
|
||||
|
|
@ -514,7 +514,7 @@ function getEnabledRulesPerLineNumber(
|
|||
* @param {Object} md Instance of markdown-it.
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
||||
* @param {RegExp} frontMatter Regular expression for front matter.
|
||||
* @param {RegExp | null} frontMatter Regular expression for front matter.
|
||||
* @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
|
||||
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
||||
* @param {number} resultVersion Version of the LintResults object to return.
|
||||
|
|
@ -796,7 +796,7 @@ function lintContent(
|
|||
* @param {Object} md Instance of markdown-it.
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {ConfigurationParser[] | null} configParsers Configuration parsers.
|
||||
* @param {RegExp} frontMatter Regular expression for front matter.
|
||||
* @param {RegExp | null} frontMatter Regular expression for front matter.
|
||||
* @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
|
||||
* @param {boolean} noInlineConfig Whether to allow inline configuration.
|
||||
* @param {number} resultVersion Version of the LintResults object to return.
|
||||
|
|
@ -848,7 +848,7 @@ function lintFile(
|
|||
/**
|
||||
* Lint files and strings specified in the Options object.
|
||||
*
|
||||
* @param {Options} options Options object.
|
||||
* @param {Options | null} options Options object.
|
||||
* @param {boolean} synchronous Whether to execute synchronously.
|
||||
* @param {Function} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
|
|
@ -971,7 +971,7 @@ function lintInput(options, synchronous, callback) {
|
|||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
|
@ -995,7 +995,7 @@ function markdownlintPromise(options) {
|
|||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
function markdownlintSync(options) {
|
||||
|
|
@ -1307,7 +1307,7 @@ module.exports = markdownlint;
|
|||
* @property {ConfigurationParser[]} [configParsers] Configuration parsers.
|
||||
* @property {Rule[] | Rule} [customRules] Custom rules.
|
||||
* @property {string[] | string} [files] Files to lint.
|
||||
* @property {RegExp} [frontMatter] Front matter pattern.
|
||||
* @property {RegExp | null} [frontMatter] Front matter pattern.
|
||||
* @property {Object} [fs] File system implementation.
|
||||
* @property {boolean} [handleRuleFailures] True to catch exceptions.
|
||||
* @property {Plugin[]} [markdownItPlugins] Additional plugins.
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ test("simpleAsync", (t) => new Promise((resolve) => {
|
|||
"Files should end with a single newline character";
|
||||
markdownlint(options, (err, actual) => {
|
||||
t.falsy(err);
|
||||
// @ts-ignore
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
resolve();
|
||||
});
|
||||
|
|
@ -784,7 +785,9 @@ test("missingStringValue", (t) => new Promise((resolve) => {
|
|||
t.plan(2);
|
||||
markdownlint({
|
||||
"strings": {
|
||||
// @ts-ignore
|
||||
"undefined": undefined,
|
||||
// @ts-ignore
|
||||
"null": null,
|
||||
"empty": ""
|
||||
}
|
||||
|
|
@ -830,6 +833,7 @@ test("customFileSystemAsync", (t) => new Promise((resolve) => {
|
|||
"fs": fsApi
|
||||
}, function callback(err, result) {
|
||||
t.falsy(err);
|
||||
// @ts-ignore
|
||||
t.deepEqual(result[file].length, 1, "Did not report violations.");
|
||||
resolve();
|
||||
});
|
||||
|
|
@ -1291,6 +1295,7 @@ test("configParsersYAML", async(t) => {
|
|||
},
|
||||
"configParsers": [ jsYaml.load ]
|
||||
};
|
||||
// @ts-ignore
|
||||
const actual = await markdownlint.promises.markdownlint(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue