-
Notifications
You must be signed in to change notification settings - Fork 61.6k
/
Copy pathgithub-docs.js
314 lines (310 loc) · 7.81 KB
/
github-docs.js
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
const githubDocsConfig = {
'link-punctuation': {
// GHD001
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'internal-links-no-lang': {
// GHD002
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'internal-links-slash': {
// GHD003
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'image-file-kebab-case': {
// GHD004
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'hardcoded-data-variable': {
// GHD005
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'internal-links-old-version': {
// GHD006
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'code-annotations': {
// GHD007
severity: 'error',
'partial-markdown-files': false,
'yml-files': false,
},
'early-access-references': {
// GHD008
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'github-owned-action-references': {
// GHD013
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-data-references-defined': {
// GHD014
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-data-tag-format': {
// GHD015
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-quoted-conditional-arg': {
// GHD016
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-syntax': {
// GHD018
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-if-tags': {
// GHD019
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-ifversion-tags': {
// GHD020
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-ifversion-versions': {
// GHD022
severity: 'warning',
'partial-markdown-files': true,
},
'yaml-scheduled-jobs': {
// GHD021
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'image-alt-text-exclude-words': {
// GHD031
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'image-alt-text-end-punctuation': {
// GHD032
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'incorrect-alt-text-length': {
// GHD033
severity: 'warning',
'partial-markdown-files': true,
'yml-files': true,
},
'list-first-word-capitalization': {
// GHD034
severity: 'warning',
'partial-markdown-files': true,
'yml-files': true,
},
'rai-reusable-usage': {
// GHD035
severity: 'error',
'partial-markdown-files': true,
},
'image-no-gif': {
// GHD036
severity: 'error',
'partial-markdown-files': true,
},
'expired-content': {
// GHD038
severity: 'error',
'partial-markdown-files': true,
},
'expiring-soon': {
// GHD039
severity: 'warning',
'partial-markdown-files': true,
},
'table-liquid-versioning': {
// GH040
severity: 'error',
'partial-markdown-files': true,
},
'third-party-action-pinning': {
// GH041
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'liquid-tag-whitespace': {
// GHD042
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'link-quotation': {
// GHD043
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
}
export const githubDocsFrontmatterConfig = {
'frontmatter-early-access-references': {
// GHD009
severity: 'error',
'partial-markdown-files': false,
'yml-files': false,
},
'frontmatter-hidden-docs': {
// GHD010
severity: 'error',
'partial-markdown-files': false,
'yml-files': false,
},
'frontmatter-video-transcripts': {
// GHD011
severity: 'error',
'partial-markdown-files': false,
'yml-files': false,
},
'frontmatter-schema': {
// GHD012
severity: 'error',
'partial-markdown-files': false,
'yml-files': false,
},
'frontmatter-liquid-syntax': {
// GHD017
severity: 'error',
'partial-markdown-files': false,
'yml-files': false,
},
'liquid-ifversion-tags': {
// GHD020
severity: 'error',
'partial-markdown-files': false,
},
'liquid-ifversion-versions': {
// GHD022
severity: 'warning',
'partial-markdown-files': false,
},
'link-quotation': {
// GHD043
severity: 'error',
'partial-markdown-files': false,
},
}
// Configures rules from the `github/markdownlint-github` repo
// created by the accessibility team.
const githubMarkdownlintConfig = {
'no-default-alt-text': {
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
'no-generic-link-text': {
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
}
// Configures rules from the open-source Markdownlint extension
// search-replace:
// https://www.npmjs.com/package/markdownlint-rule-search-replace
export const searchReplaceConfig = {
'search-replace': {
rules: [
{
name: 'todocs-placeholder',
message: 'Catch occurrences of TODOCS placeholder.',
searchPattern: '/todocs/gi',
searchScope: 'all',
severity: 'error',
precommitSeverity: 'warning',
'partial-markdown-files': true,
'yml-files': true,
},
{
name: 'docs-domain',
message: 'Catch occurrences of docs.github.com domain.',
search: 'docs.github.com',
searchScope: 'all',
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
{
name: 'help-domain',
message: 'Catch occurrences of help.github.com domain.',
search: 'help.github.com',
searchScope: 'all',
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
{
name: 'developer-domain',
message: 'Catch occurrences of developer.github.com domain.',
// Do not match developer.github.com/changes or
// developer.github.com/enterprise/[0-9] or
// developer.github.com/enterprise/{{something}} (e.g. liquid).
// There are occurrences that will likely always remain in the content.
searchPattern: '/developer\\.github\\.com(?!\\/(changes|enterprise\\/([0-9]|{))).*/g',
searchScope: 'all',
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
{
// Catches usage of old liquid data reusable syntax. For example:
// {{ site.data.variables.product_releases }}
name: 'deprecated liquid syntax: site.data',
message: 'Catch occurrences of deprecated liquid data syntax.',
searchPattern: '/{{\\s*?site\\.data\\.([a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]+)+)\\s*?}}/g',
replace: '{% data $1 %}',
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
{
// Catches usage of old octicon variable syntax. For example:
// - {{ octicon-plus }}
// - {{ octicon-plus An example label }}
name: 'deprecated liquid syntax: octicon-<icon-name>',
message:
'The octicon liquid syntax used is deprecated. Use this format instead `octicon "<octicon-name>" aria-label="<Octicon aria label>"`',
searchPattern: '/{{\\s*?octicon-([a-z-]+)(\\s[\\w\\s\\d-]+)?\\s*?}}/g',
severity: 'error',
'partial-markdown-files': true,
'yml-files': true,
},
],
},
}
export const customConfig = {
...searchReplaceConfig,
...githubDocsConfig,
...githubMarkdownlintConfig,
...githubDocsFrontmatterConfig,
}