Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-eslint / server / types.ts
1 import { WorkspaceFolder } from 'vscode-languageserver'
2 import { CLIEngine } from 'eslint'
3
4 export interface CodeActionSettings {
5   disableRuleComment: {
6     enable: boolean
7     location: 'separateLine' | 'sameLine'
8   }
9   showDocumentation: {
10     enable: boolean
11   }
12 }
13
14 export interface ESLintError extends Error {
15   messageTemplate?: string
16   messageData?: {
17     pluginName?: string
18   }
19 }
20
21 export interface ESLintAutoFixEdit {
22   range: [number, number]
23   text: string
24 }
25
26 export interface ESLintProblem {
27   line: number
28   column: number
29   endLine?: number
30   endColumn?: number
31   severity: number
32   ruleId: string
33   message: string
34   fix?: ESLintAutoFixEdit
35 }
36
37 export interface ESLintDocumentReport {
38   filePath: string
39   errorCount: number
40   warningCount: number
41   messages: ESLintProblem[]
42   output?: string
43 }
44
45 export interface ESLintReport {
46   errorCount: number
47   warningCount: number
48   results: ESLintDocumentReport[]
49 }
50
51 export interface CLIOptions {
52   cwd?: string
53   [index: string]: any
54 }
55
56 export interface ESLintConfig {
57   [index: string]: any
58 }
59
60 export interface FixResult {
61   fixed: boolean
62   output: string
63   messages: string[]
64 }
65
66 export interface ESLintLinter {
67   verifyAndFix(code: string, config: ESLintConfig, options: LinterOptions): FixResult
68   verify(code: string, config: ESLintConfig, options: { [index: string]: any }): any
69 }
70
71 export interface LinterOptions {
72   filename: string
73   allowInlineConfig: boolean
74   fix: boolean
75 }
76
77 export interface CLIEngineConstructor {
78   new(options: CLIOptions): CLIEngine
79 }
80
81 export interface LinterConstructor {
82   new(): ESLintLinter
83 }
84
85 export interface ESLintModule {
86   CLIEngine: CLIEngineConstructor
87   Linter: LinterConstructor
88   linter: ESLintLinter
89 }
90
91 type RunValues = 'onType' | 'onSave'
92
93 interface DirectoryItem {
94   directory: string
95   changeProcessCWD?: boolean
96 }
97
98 export namespace Is {
99   const toString = Object.prototype.toString
100
101   export function boolean(value: any): value is boolean {
102     return value === true || value === false
103   }
104
105   export function string(value: any): value is string {
106     return toString.call(value) === '[object String]'
107   }
108 }
109
110 export namespace DirectoryItem {
111   export function is(item: any): item is DirectoryItem {
112     let candidate = item as DirectoryItem
113     return (
114       candidate &&
115       Is.string(candidate.directory) &&
116       (Is.boolean(candidate.changeProcessCWD) ||
117         candidate.changeProcessCWD === void 0)
118     )
119   }
120 }
121
122 export interface TextDocumentSettings {
123   validate: boolean
124   packageManager: 'npm' | 'yarn'
125   quiet: boolean
126   autoFix: boolean
127   autoFixOnSave: boolean
128   autoFixSkipRules: string[]
129   options: any | undefined
130   run: RunValues
131   nodePath: string | undefined
132   workspaceFolder: WorkspaceFolder | undefined
133   workingDirectory: DirectoryItem | undefined
134   library: ESLintModule | undefined
135   resolvedGlobalPackageManagerPath: string | undefined
136   codeAction: CodeActionSettings
137 }