UNPKG

1.93 kBTypeScriptView Raw
1import { Linter, LintResult } from 'tslint';
2import { Program, Diagnostic } from 'typescript';
3import { BuildContext } from '../util/interfaces';
4export interface LinterOptions {
5 typeCheck?: boolean;
6}
7export interface LinterConfig {
8 [key: string]: any;
9}
10/**
11 * Lint a file according to config
12 * @param {Linter} linter
13 * @param {LinterConfig} config
14 * @param {string} filePath
15 * @param {string} fileContents
16 */
17export declare function lint(linter: Linter, config: LinterConfig, filePath: string, fileContents: string): void;
18/**
19 * Get the linter result
20 * @param {Linter} linter
21 * @return {LintResult}
22 */
23export declare function getLintResult(linter: Linter): LintResult;
24/**
25 * Type check a TS program
26 * @param {BuildContext} context
27 * @param {Program} program
28 * @param {LinterOptions} linterOptions
29 * @return {Promise<Diagnostic[]>}
30 */
31export declare function typeCheck(context: BuildContext, program: Program, linterOptions?: LinterOptions): Promise<Diagnostic[]>;
32/**
33 * Create a TS program based on the BuildContext {rootDir} or TS config file path (if provided)
34 * @param {BuildContext} context
35 * @param {string} tsConfig
36 * @return {Program}
37 */
38export declare function createProgram(context: BuildContext, tsConfig: string): Program;
39/**
40 * Get all files that are sourced in TS config
41 * @param {BuildContext} context
42 * @param {Program} program
43 * @return {Array<string>}
44 */
45export declare function getFileNames(context: BuildContext, program: Program): string[];
46/**
47 * Get lint configuration
48 * @param {string} tsLintConfig
49 * @param {LinterOptions} linterOptions
50 * @return {Linter}
51 */
52export declare function getTsLintConfig(tsLintConfig: string, linterOptions?: LinterOptions): LinterConfig;
53/**
54 * Create a TS linter
55 * @param {BuildContext} context
56 * @param {Program} program
57 * @return {Linter}
58 */
59export declare function createLinter(context: BuildContext, program: Program): Linter;