-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
106 lines (96 loc) · 2.45 KB
/
types.ts
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { ISSUE_TYPES } from "./constants.ts";
import type { MarkdownIt } from "./deps/markdown-it/mod.ts";
export type MarkdownItToken = ReturnType<
InstanceType<typeof MarkdownIt>["parse"]
>[number];
export type FetchOptions = Parameters<typeof fetch>[1];
interface BaseIssue {
type: typeof ISSUE_TYPES[number];
reference: string;
}
interface UnknownLinkFormatIssue extends BaseIssue {
type: "unknown_link_format";
}
interface EmptyDOMIssue extends BaseIssue {
type: "empty_dom";
}
interface EmptyAnchorIssue extends BaseIssue {
type: "empty_anchor";
}
interface NoResponseIssue extends BaseIssue {
type: "no_response";
}
interface NotOKResponseIssue extends BaseIssue {
type: "not_ok_response";
status: number;
statusText: string;
}
interface DisallowExtensionIssue extends BaseIssue {
type: "disallow_extension";
extension: "html" | "md";
}
interface WrongExtensionIssue extends BaseIssue {
type: "wrong_extension";
actual: string;
expected: string;
}
interface LinkedFileNotFoundIssue {
type: "linked_file_not_found";
filepath: string;
reference: string;
}
interface RedirectedIssue {
type: "redirected";
from: string;
to: string;
}
export interface MissingAnchorIssue extends BaseIssue {
type: "missing_anchor";
anchor: string;
allAnchors: Set<string>;
}
interface PreferLocalLinkIssue extends BaseIssue {
type: "local_alt_available";
reference: string;
reason: string;
}
interface InaccessibleLinkIssue extends BaseIssue {
type: "inaccessible";
reference: string;
reason: string;
}
export type ExternalLinkIssue =
| RedirectedIssue
| NotOKResponseIssue
| NoResponseIssue
| MissingAnchorIssue
| EmptyDOMIssue
| PreferLocalLinkIssue
| InaccessibleLinkIssue;
export type FixableIssue =
| RedirectedIssue
| EmptyAnchorIssue
| MissingAnchorIssue
| WrongExtensionIssue
| DisallowExtensionIssue;
export type Issue =
| ExternalLinkIssue
| DisallowExtensionIssue
| WrongExtensionIssue
| LinkedFileNotFoundIssue
| UnknownLinkFormatIssue
| EmptyAnchorIssue;
export interface ResponseInfo {
response?: Response | null;
redirected: boolean;
redirectedUrl: string; // may become useful later.
}
export interface Location {
line: number;
columns: number[];
}
export interface Stack {
filepath: string;
locations: Location[];
}
export type IssueWithStack = Issue & { stack: Stack[] };