1 import { WorkspaceFolder } from 'vscode-languageserver'
2 import { CLIEngine } from 'eslint'
4 export interface CodeActionSettings {
7 location: 'separateLine' | 'sameLine'
14 export interface ESLintError extends Error {
15 messageTemplate?: string
21 export interface ESLintAutoFixEdit {
22 range: [number, number]
26 export interface ESLintProblem {
34 fix?: ESLintAutoFixEdit
37 export interface ESLintDocumentReport {
41 messages: ESLintProblem[]
45 export interface ESLintReport {
48 results: ESLintDocumentReport[]
51 export interface CLIOptions {
56 export interface ESLintConfig {
60 export interface FixResult {
66 export interface ESLintLinter {
67 verifyAndFix(code: string, config: ESLintConfig, options: LinterOptions): FixResult
68 verify(code: string, config: ESLintConfig, options: { [index: string]: any }): any
71 export interface LinterOptions {
73 allowInlineConfig: boolean
77 export interface CLIEngineConstructor {
78 new(options: CLIOptions): CLIEngine
81 export interface LinterConstructor {
85 export interface ESLintModule {
86 CLIEngine: CLIEngineConstructor
87 Linter: LinterConstructor
91 type RunValues = 'onType' | 'onSave'
93 interface DirectoryItem {
95 changeProcessCWD?: boolean
99 const toString = Object.prototype.toString
101 export function boolean(value: any): value is boolean {
102 return value === true || value === false
105 export function string(value: any): value is string {
106 return toString.call(value) === '[object String]'
110 export namespace DirectoryItem {
111 export function is(item: any): item is DirectoryItem {
112 let candidate = item as DirectoryItem
115 Is.string(candidate.directory) &&
116 (Is.boolean(candidate.changeProcessCWD) ||
117 candidate.changeProcessCWD === void 0)
122 export interface TextDocumentSettings {
124 packageManager: 'npm' | 'yarn'
127 autoFixOnSave: boolean
128 autoFixSkipRules: string[]
129 options: any | undefined
131 nodePath: string | undefined
132 workspaceFolder: WorkspaceFolder | undefined
133 workingDirectory: DirectoryItem | undefined
134 library: ESLintModule | undefined
135 resolvedGlobalPackageManagerPath: string | undefined
136 codeAction: CodeActionSettings