Replace all instances of JSDoc generic Function with detailed @callback definition (type-only changes).

This commit is contained in:
David Anson 2023-09-04 21:41:16 -07:00
parent 8bb97dadfe
commit 07f403173c
6 changed files with 199 additions and 38 deletions

View file

@ -8,7 +8,7 @@ export = markdownlint;
*/
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 };
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
}
/**
* Configuration options.
@ -64,7 +64,7 @@ type Options = {
/**
* Called with the result of the lint function.
*/
type LintCallback = (err: Error | null, results?: LintResults) => void;
type LintCallback = (error: Error | null, results?: LintResults) => void;
/**
* Lint specified Markdown files synchronously.
*
@ -353,6 +353,10 @@ type FixInfo = {
*/
insertText?: string;
};
/**
* Called with the result of linting a string or document.
*/
type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
/**
* Configuration object for linting rules. For a detailed schema, see
* {@link ../schema/markdownlint-config-schema.json}.

View file

@ -520,7 +520,7 @@ function getEnabledRulesPerLineNumber(
* @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.
* @param {Function} callback Callback (err, result) function.
* @param {LintContentCallback} callback Callback (err, result) function.
* @returns {void}
*/
function lintContent(
@ -809,7 +809,7 @@ function lintContent(
* @param {number} resultVersion Version of the LintResults object to return.
* @param {Object} fs File system implementation.
* @param {boolean} synchronous Whether to execute synchronously.
* @param {Function} callback Callback (err, result) function.
* @param {LintContentCallback} callback Callback (err, result) function.
* @returns {void}
*/
function lintFile(
@ -859,7 +859,7 @@ function lintFile(
*
* @param {Options | null} options Options object.
* @param {boolean} synchronous Whether to execute synchronously.
* @param {Function} callback Callback (err, result) function.
* @param {LintCallback} callback Callback (err, result) function.
* @returns {void}
*/
function lintInput(options, synchronous, callback) {
@ -1022,7 +1022,7 @@ function markdownlintPromise(options) {
* @returns {LintResults} Results object.
*/
function markdownlintSync(options) {
let results = {};
let results = null;
lintInput(options, true, function callback(error, res) {
if (error) {
throw error;
@ -1417,12 +1417,21 @@ module.exports = markdownlint;
* @property {string} [insertText] Text to insert (after deleting).
*/
/**
* Called with the result of linting a string or document.
*
* @callback LintContentCallback
* @param {Error | null} error Error iff failed.
* @param {LintError[]} [result] Result iff successful.
* @returns {void}
*/
/**
* Called with the result of the lint function.
*
* @callback LintCallback
* @param {Error | null} err Error object or null.
* @param {LintResults} [results] Lint results.
* @param {Error | null} error Error object iff failed.
* @param {LintResults} [results] Lint results iff succeeded.
* @returns {void}
*/