|
| 1 | +import { Range, Point, RangeCompatible, PointCompatible, TextEditor } from 'atom' |
| 2 | + |
| 3 | +export type MessageSolution = |
| 4 | + | { |
| 5 | + title?: string |
| 6 | + position: Range |
| 7 | + priority?: number |
| 8 | + currentText?: string |
| 9 | + replaceWith: string |
| 10 | + } |
| 11 | + | { |
| 12 | + title?: string |
| 13 | + position: Range |
| 14 | + priority?: number |
| 15 | + apply: () => any |
| 16 | + } |
| 17 | + |
| 18 | +export type Message = { |
| 19 | + // Automatically added by linter |
| 20 | + key: string |
| 21 | + version: 2 |
| 22 | + linterName: string |
| 23 | + |
| 24 | + // From providers |
| 25 | + location: { |
| 26 | + file: string |
| 27 | + position: Range |
| 28 | + } |
| 29 | + reference?: { |
| 30 | + file: string |
| 31 | + position?: Point |
| 32 | + } |
| 33 | + url?: string |
| 34 | + icon?: string |
| 35 | + excerpt: string |
| 36 | + severity: 'error' | 'warning' | 'info' |
| 37 | + solutions?: Array<MessageSolution> | (() => Promise<Array<MessageSolution>>) |
| 38 | + description?: string | (() => Promise<string> | string) |
| 39 | +} |
| 40 | + |
| 41 | +/** Alias for {Message} */ |
| 42 | +export type LinterMessage = Message |
| 43 | + |
| 44 | +/** |
| 45 | + * @deprecated Wrong but convertible message format which might some providers use by mistake. This is converted to |
| 46 | + * MessageSolution by Linter using `normalizeMessages` |
| 47 | + */ |
| 48 | +export type MessageSolutionLike = Omit<MessageSolution, 'position'> & { |
| 49 | + position: RangeCompatible |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * @deprecated Wrong but convertible message format which some providers might use. This is converted to MessageSolution by |
| 54 | + * Linter using `normalizeMessages` |
| 55 | + */ |
| 56 | +export type MessageLike = Omit<Message, 'location' | 'reference' | 'solutions'> & { |
| 57 | + location: { |
| 58 | + file: string |
| 59 | + position: RangeCompatible |
| 60 | + } |
| 61 | + reference?: { |
| 62 | + file: string |
| 63 | + position?: PointCompatible |
| 64 | + } |
| 65 | + solutions?: Array<MessageSolutionLike> | (() => Promise<Array<MessageSolutionLike>>) |
| 66 | +} |
| 67 | + |
| 68 | +export type LinterResult = Array<Message> | null | undefined |
| 69 | +export type Linter = { |
| 70 | + // Automatically added |
| 71 | + __$sb_linter_version: number |
| 72 | + __$sb_linter_activated: boolean |
| 73 | + __$sb_linter_request_latest: number |
| 74 | + __$sb_linter_request_last_received: number |
| 75 | + |
| 76 | + // From providers |
| 77 | + name: string |
| 78 | + scope: 'file' | 'project' |
| 79 | + lintOnFly?: boolean // <-- legacy |
| 80 | + lintsOnChange?: boolean |
| 81 | + grammarScopes: Array<string> |
| 82 | + lint(textEditor: TextEditor): LinterResult | Promise<LinterResult> |
| 83 | +} |
| 84 | + |
| 85 | +export type Indie = { |
| 86 | + name: string |
| 87 | +} |
| 88 | + |
| 89 | +export type MessagesPatch = { |
| 90 | + added: Array<Message> |
| 91 | + removed: Array<Message> |
| 92 | + messages: Array<Message> |
| 93 | +} |
0 commit comments