mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-22 17:00:13 +01:00
Introduce type declaration file for project after updating typescript dependency to 3.7.2.
This commit is contained in:
parent
37307d0764
commit
0a9ac73524
9 changed files with 703 additions and 18 deletions
343
lib/markdownlint.d.ts
vendored
Normal file
343
lib/markdownlint.d.ts
vendored
Normal file
|
|
@ -0,0 +1,343 @@
|
|||
export = markdownlint;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function markdownlint(options: Options, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync, readConfig, readConfigSync, RuleFunction, RuleParams, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback };
|
||||
}
|
||||
/**
|
||||
* Configuration options.
|
||||
*/
|
||||
type Options = {
|
||||
/**
|
||||
* Files to lint.
|
||||
*/
|
||||
files?: string | string[];
|
||||
/**
|
||||
* Strings to lint.
|
||||
*/
|
||||
strings?: {
|
||||
[x: string]: string;
|
||||
};
|
||||
/**
|
||||
* Configuration object.
|
||||
*/
|
||||
config?: {
|
||||
[x: string]: any;
|
||||
};
|
||||
/**
|
||||
* Custom rules.
|
||||
*/
|
||||
customRules?: Rule | Rule[];
|
||||
/**
|
||||
* Front matter pattern.
|
||||
*/
|
||||
frontMatter?: RegExp;
|
||||
/**
|
||||
* True to catch exceptions.
|
||||
*/
|
||||
handleRuleFailures?: boolean;
|
||||
/**
|
||||
* True to ignore HTML directives.
|
||||
*/
|
||||
noInlineConfig?: boolean;
|
||||
/**
|
||||
* Results object version.
|
||||
*/
|
||||
resultVersion?: number;
|
||||
/**
|
||||
* Additional plugins.
|
||||
*/
|
||||
markdownItPlugins?: any[][];
|
||||
};
|
||||
/**
|
||||
* Called with the result of the lint operation.
|
||||
*/
|
||||
type LintCallback = (err: Error, results?: {
|
||||
[x: string]: LintError[];
|
||||
}) => void;
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
declare function markdownlintSync(options: Options): {
|
||||
[x: string]: LintError[];
|
||||
};
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | null} parsers Parsing function(s).
|
||||
* @param {ReadConfigCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function readConfig(file: string, parsers: ConfigurationParser[], callback: ReadConfigCallback): void;
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @returns {Configuration} Configuration object.
|
||||
*/
|
||||
declare function readConfigSync(file: string, parsers?: ConfigurationParser[]): {
|
||||
[x: string]: any;
|
||||
};
|
||||
/**
|
||||
* Function to implement rule logic.
|
||||
*/
|
||||
type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
/**
|
||||
* Rule parameters.
|
||||
*/
|
||||
type RuleParams = {
|
||||
/**
|
||||
* File/string name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* markdown-it token objects.
|
||||
*/
|
||||
tokens: MarkdownItToken[];
|
||||
/**
|
||||
* File/string lines.
|
||||
*/
|
||||
lines: string[];
|
||||
/**
|
||||
* Front matter lines.
|
||||
*/
|
||||
frontMatterLines: string[];
|
||||
/**
|
||||
* Rule configuration.
|
||||
*/
|
||||
config: any;
|
||||
};
|
||||
/**
|
||||
* Markdown-It token.
|
||||
*/
|
||||
type MarkdownItToken = {
|
||||
/**
|
||||
* HTML attributes.
|
||||
*/
|
||||
attrs: string[][];
|
||||
/**
|
||||
* Block-level token.
|
||||
*/
|
||||
block: boolean;
|
||||
/**
|
||||
* Child nodes.
|
||||
*/
|
||||
children: MarkdownItToken[];
|
||||
/**
|
||||
* Tag contents.
|
||||
*/
|
||||
content: string;
|
||||
/**
|
||||
* Ignore element.
|
||||
*/
|
||||
hidden: boolean;
|
||||
/**
|
||||
* Fence info.
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* Nesting level.
|
||||
*/
|
||||
level: number;
|
||||
/**
|
||||
* Beginning/ending line numbers.
|
||||
*/
|
||||
map: number[];
|
||||
/**
|
||||
* Markup text.
|
||||
*/
|
||||
markup: string;
|
||||
/**
|
||||
* Arbitrary data.
|
||||
*/
|
||||
meta: any;
|
||||
/**
|
||||
* Level change.
|
||||
*/
|
||||
nesting: number;
|
||||
/**
|
||||
* HTML tag name.
|
||||
*/
|
||||
tag: string;
|
||||
/**
|
||||
* Token type.
|
||||
*/
|
||||
type: string;
|
||||
};
|
||||
/**
|
||||
* Error-reporting callback.
|
||||
*/
|
||||
type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
/**
|
||||
* Fix information for RuleOnError callback.
|
||||
*/
|
||||
type RuleOnErrorInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
lineNumber: number;
|
||||
/**
|
||||
* Details about the error.
|
||||
*/
|
||||
details?: string;
|
||||
/**
|
||||
* Context for the error.
|
||||
*/
|
||||
context?: string;
|
||||
/**
|
||||
* Column number (1-based) and length.
|
||||
*/
|
||||
range?: number[];
|
||||
/**
|
||||
* Fix information.
|
||||
*/
|
||||
fixInfo?: RuleOnErrorFixInfo;
|
||||
};
|
||||
/**
|
||||
* Fix information for RuleOnErrorInfo.
|
||||
*/
|
||||
type RuleOnErrorFixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
lineNumber?: number;
|
||||
/**
|
||||
* Column of the fix (1-based).
|
||||
*/
|
||||
editColumn?: number;
|
||||
/**
|
||||
* Count of characters to delete.
|
||||
*/
|
||||
deleteCount?: number;
|
||||
/**
|
||||
* Text to insert (after deleting).
|
||||
*/
|
||||
insertText?: string;
|
||||
};
|
||||
/**
|
||||
* Rule definition.
|
||||
*/
|
||||
type Rule = {
|
||||
/**
|
||||
* Rule name(s).
|
||||
*/
|
||||
names: string[];
|
||||
/**
|
||||
* Rule description.
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Link to more information.
|
||||
*/
|
||||
information?: URL;
|
||||
/**
|
||||
* Rule tag(s).
|
||||
*/
|
||||
tags: string[];
|
||||
/**
|
||||
* Rule implementation.
|
||||
*/
|
||||
function: RuleFunction;
|
||||
};
|
||||
/**
|
||||
* markdown-it plugin.
|
||||
*/
|
||||
type Plugin = any[];
|
||||
/**
|
||||
* Function to pretty-print lint results.
|
||||
*/
|
||||
type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
/**
|
||||
* Lint results (for resultVersion 3).
|
||||
*/
|
||||
type LintResults = {
|
||||
[x: string]: LintError[];
|
||||
};
|
||||
/**
|
||||
* Lint error.
|
||||
*/
|
||||
type LintError = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
lineNumber: number;
|
||||
/**
|
||||
* Rule name(s).
|
||||
*/
|
||||
ruleNames: string[];
|
||||
/**
|
||||
* Rule description.
|
||||
*/
|
||||
ruleDescription: string;
|
||||
/**
|
||||
* Link to more information.
|
||||
*/
|
||||
ruleInformation: string;
|
||||
/**
|
||||
* Detail about the error.
|
||||
*/
|
||||
errorDetail: string;
|
||||
/**
|
||||
* Context for the error.
|
||||
*/
|
||||
errorContext: string;
|
||||
/**
|
||||
* Column number (1-based) and length.
|
||||
*/
|
||||
errorRange: number[];
|
||||
/**
|
||||
* Fix information.
|
||||
*/
|
||||
fixInfo: FixInfo;
|
||||
};
|
||||
/**
|
||||
* Fix information.
|
||||
*/
|
||||
type FixInfo = {
|
||||
/**
|
||||
* Column of the fix (1-based).
|
||||
*/
|
||||
editColumn?: number;
|
||||
/**
|
||||
* Count of characters to delete.
|
||||
*/
|
||||
deleteCount?: number;
|
||||
/**
|
||||
* Text to insert (after deleting).
|
||||
*/
|
||||
insertText?: string;
|
||||
};
|
||||
/**
|
||||
* Configuration object for linting rules. For a detailed schema, see
|
||||
* {@link ../schema/markdownlint-config-schema.json}.
|
||||
*/
|
||||
type Configuration = {
|
||||
[x: string]: any;
|
||||
};
|
||||
/**
|
||||
* Rule configuration.
|
||||
*/
|
||||
type RuleConfiguration = any;
|
||||
/**
|
||||
* Parses a configuration string and returns a configuration object.
|
||||
*/
|
||||
type ConfigurationParser = (text: string) => {
|
||||
[x: string]: any;
|
||||
};
|
||||
/**
|
||||
* Called with the result of the readConfig operation.
|
||||
*/
|
||||
type ReadConfigCallback = (err: Error, config?: {
|
||||
[x: string]: any;
|
||||
}) => void;
|
||||
Loading…
Add table
Add a link
Reference in a new issue