UNPKG

4.1 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as minimatch from 'minimatch';
3import * as cspell from 'cspell-lib';
4import { TraceResult, CheckTextInfo } from 'cspell-lib';
5export { TraceResult, IncludeExcludeFlag } from 'cspell-lib';
6import { GlobMatcher } from 'cspell-glob';
7export interface CSpellApplicationOptions extends BaseOptions {
8 /**
9 * Display verbose information
10 */
11 verbose?: boolean;
12 /**
13 * Show extensive output.
14 */
15 debug?: boolean;
16 /**
17 * a glob to exclude files from being checked.
18 */
19 exclude?: string;
20 /**
21 * Only report the words, no line numbers or file names.
22 */
23 wordsOnly?: boolean;
24 /**
25 * unique errors per file only.
26 */
27 unique?: boolean;
28 /**
29 * root directory, defaults to `cwd`
30 */
31 root?: string;
32}
33export interface TraceOptions extends BaseOptions {
34}
35export interface BaseOptions {
36 config?: string;
37 languageId?: string;
38 local?: string;
39}
40export interface AppError extends NodeJS.ErrnoException {
41}
42export interface RunResult {
43 files: number;
44 filesWithIssues: Set<string>;
45 issues: number;
46}
47export interface Issue extends cspell.TextDocumentOffset {
48}
49export interface GlobSrcInfo {
50 matcher: GlobMatcher;
51 source: string;
52}
53export declare type MessageType = 'Debug' | 'Info' | 'Progress';
54export declare type MessageTypeLookup = {
55 [key in MessageType]: key;
56};
57export declare const MessageTypes: MessageTypeLookup;
58export interface MessageEmitter {
59 (message: string, msgType: MessageType): void;
60}
61export interface DebugEmitter {
62 (message: string): void;
63}
64export interface ErrorEmitter {
65 (message: string, error: Error): Promise<void>;
66}
67export interface SpellingErrorEmitter {
68 (issue: Issue): void;
69}
70export interface Emitters {
71 issue: SpellingErrorEmitter;
72 info: MessageEmitter;
73 debug: DebugEmitter;
74 error: ErrorEmitter;
75}
76interface GlobOptions extends minimatch.IOptions {
77 cwd?: string;
78 root?: string;
79}
80export declare class CSpellApplicationConfiguration {
81 readonly files: string[];
82 readonly options: CSpellApplicationOptions;
83 readonly emitters: Emitters;
84 readonly info: MessageEmitter;
85 readonly debug: DebugEmitter;
86 readonly logIssue: SpellingErrorEmitter;
87 readonly uniqueFilter: (issue: Issue) => boolean;
88 readonly local: string;
89 readonly configGlob: string;
90 readonly configGlobOptions: minimatch.IOptions;
91 readonly excludes: GlobSrcInfo[];
92 readonly root: string;
93 constructor(files: string[], options: CSpellApplicationOptions, emitters: Emitters);
94}
95export declare function lint(files: string[], options: CSpellApplicationOptions, emitters: Emitters): Promise<RunResult>;
96export declare function trace(words: string[], options: TraceOptions): Promise<TraceResult[]>;
97export interface CheckTextResult extends CheckTextInfo {
98}
99export declare function checkText(filename: string, options: BaseOptions): Promise<CheckTextResult>;
100export declare function createInit(_: CSpellApplicationOptions): Promise<void>;
101/**
102 * Looks for matching glob patterns or stdin
103 * @param globPatterns patterns or stdin
104 */
105declare function findFiles(globPatterns: string[], options: GlobOptions): Promise<string[]>;
106interface PatternRoot {
107 pattern: string;
108 root: string;
109}
110/**
111 * Attempt to normalize a pattern based upon the root.
112 * If the pattern is absolute, check to see if it exists and adjust the root, otherwise it is assumed to be based upon the current root.
113 * If the pattern starts with a relative path, adjust the root to match.
114 * The challenge is with the patterns that begin with `/`. Is is an absolute path or relative pattern?
115 * @param pat glob pattern
116 * @param root absolute path | empty
117 * @returns the adjusted root and pattern.
118 */
119declare function normalizePattern(pat: string, root: string): PatternRoot;
120declare function _globP(pattern: string, options: GlobOptions): Promise<string[]>;
121export declare const _testing_: {
122 _globP: typeof _globP;
123 findFiles: typeof findFiles;
124 normalizePattern: typeof normalizePattern;
125};