-
Notifications
You must be signed in to change notification settings - Fork 66.9k
Expand file tree
/
Copy pathtypes.ts
More file actions
65 lines (59 loc) · 1.41 KB
/
types.ts
File metadata and controls
65 lines (59 loc) · 1.41 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
// Interfaces for content linter rule parameters and callbacks
export interface MarkdownToken {
type: string
tag?: string
attrs?: [string, string][]
content?: string
info?: string
lineNumber: number
line: string
children?: MarkdownToken[]
}
export interface RuleParams {
name: string // file path
lines: string[] // array of lines from the file
frontMatterLines: string[] // array of frontmatter lines
tokens?: MarkdownToken[] // markdown tokens (when using markdownit parser)
config?: {
[key: string]: any // rule-specific configuration
}
}
export interface RuleErrorCallback {
(
lineNumber: number,
detail?: string,
context?: string,
range?: [number, number],
fixInfo?: any,
): void
}
export type Rule = {
names: string[]
description: string
tags: string[]
information?: URL
parser?: 'markdownit' | 'micromark' | 'none'
asynchronous?: boolean
severity?: string
function: (params: RuleParams, onError: RuleErrorCallback) => void | Promise<void>
}
type RuleDetail = Rule & {
name: string
'partial-markdown-files': boolean
message: string
severity: string
searchPattern: string
searchScope: string
precommitSeverity?: string
}
export type Config = {
severity: string
'partial-markdown-files': boolean
allowed_languages?: string[]
style?: string
rules?: RuleDetail[]
context?: string
}
export type RuleConfig = {
[name: string]: Config
}