mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge pull request #22548 from ark120202/markdownlint
Add types for "markdownlint"
This commit is contained in:
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// Type definitions for markdownlint 0.6
|
||||
// Project: https://github.com/DavidAnson/markdownlint
|
||||
// Definitions by: ark120202 <https://github.com/ark120202>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function markdownlint(
|
||||
options: markdownlint.MarkdownlintOptions,
|
||||
callback: (err: Error | null, result: markdownlint.MarkdownlintResults) => any,
|
||||
): void;
|
||||
|
||||
declare namespace markdownlint {
|
||||
function sync(options: MarkdownlintOptions): MarkdownlintResults;
|
||||
|
||||
function readConfig(
|
||||
file: string,
|
||||
callback: (err: Error | null, result: MarkdownlintConfig) => any,
|
||||
): void;
|
||||
function readConfigSync(file: string): MarkdownlintConfig;
|
||||
|
||||
interface MarkdownlintConfig {
|
||||
[rule: string]: boolean | { [key: string]: any };
|
||||
}
|
||||
|
||||
interface MarkdownlintOptions {
|
||||
files?: ReadonlyArray<string> | string;
|
||||
strings?: { [identifier: string]: string };
|
||||
config?: MarkdownlintConfig;
|
||||
frontMatter?: RegExp;
|
||||
noInlineConfig?: boolean;
|
||||
resultVersion?: number;
|
||||
}
|
||||
|
||||
interface MarkdownlintResult {
|
||||
lineNumber: number;
|
||||
ruleName: string;
|
||||
ruleAlias: string;
|
||||
ruleDescription: string;
|
||||
errorDetail?: string;
|
||||
errorContext: string;
|
||||
errorRange?: [number, number];
|
||||
}
|
||||
|
||||
interface MarkdownlintResults {
|
||||
[source: string]: MarkdownlintResult[] | ((useAlias?: boolean) => string);
|
||||
toString(useAlias?: boolean): string;
|
||||
}
|
||||
}
|
||||
|
||||
export = markdownlint;
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as markdownlint from 'markdownlint';
|
||||
|
||||
const config: markdownlint.MarkdownlintConfig = {
|
||||
default: true,
|
||||
MD003: { style: 'atx_closed' },
|
||||
MD007: { indent: 4 },
|
||||
'no-hard-tabs': false,
|
||||
whitespace: false,
|
||||
};
|
||||
|
||||
const options: markdownlint.MarkdownlintOptions = {
|
||||
files: ['README.md'],
|
||||
strings: { 'file.md': 'Header' },
|
||||
config,
|
||||
noInlineConfig: false,
|
||||
resultVersion: 1,
|
||||
};
|
||||
|
||||
// $ExpectType MarkdownlintResults
|
||||
const results = markdownlint.sync(options);
|
||||
|
||||
markdownlint(options, (err, results) => {
|
||||
// $ExpectType Error | null
|
||||
err;
|
||||
|
||||
// $ExpectType MarkdownlintResults
|
||||
results;
|
||||
|
||||
const resultString: string = results.toString();
|
||||
// $ExpectError
|
||||
results.toString() as markdownlint.MarkdownlintResult[];
|
||||
|
||||
const fileErrors: markdownlint.MarkdownlintResult[] = results[
|
||||
'file.md'
|
||||
] as markdownlint.MarkdownlintResult[];
|
||||
const firstFileError: markdownlint.MarkdownlintResult = fileErrors[0];
|
||||
const firstFileErrorRule: string = firstFileError.ruleName;
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"markdownlint-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user