forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrection.ts
More file actions
82 lines (77 loc) · 1.49 KB
/
correction.ts
File metadata and controls
82 lines (77 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { Action } from './';
export interface CorrectionOptions {
line?: number;
column?: number;
lineEnd?: number;
columnEnd?: number;
path: string;
payload?: Object;
severity: 'warning' | 'notice';
source?: string;
}
export interface CorrectionAction extends Action {
message: string;
line?: number;
column?: number;
lineEnd?: number;
columnEnd?: number;
path: string;
payload?: Object;
severity: 'warning' | 'notice';
source: string;
}
export interface CorrectionClearAction extends Action {
type: 'action';
action: 'clear-corrections';
path: string;
source: string;
}
/**
* Returns an action that describes to show a correction
* in the code of the editor (with the yellow/blue squiggles)
*
* @export
* @param {string} title
* @param {string} message
* @param {CorrectionOptions} { line, column, payload }
* @returns {CorrectionAction}
*/
export function show(
message: string,
{
line,
column,
lineEnd,
columnEnd,
path,
payload,
severity = 'warning',
source = '',
}: CorrectionOptions = {
path: '',
severity: 'warning',
source: '',
}
): CorrectionAction {
return {
message,
line,
column,
lineEnd,
columnEnd,
path,
payload,
severity,
source,
type: 'action',
action: 'show-correction',
};
}
export function clear(path: string, source: 'all' | string): CorrectionClearAction {
return {
type: 'action',
action: 'clear-corrections',
path,
source,
};
}