forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.markdownlint-cli2.cjs
164 lines (156 loc) · 3.75 KB
/
.markdownlint-cli2.cjs
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
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
const excludedTypography = [
["’", "'"],
["“", '"'],
["”", '"'],
["–", "-"],
];
const excludedWords = ["Azure Fluid Relay service", "Azure Relay Service", "FRS", "`Tinylicious`"];
const clamp = (number, min, max) => {
return Math.max(min, Math.min(number, max));
};
const extractContext = (line, column) => {
const contextPadding = 10;
return line.substr(clamp(column - contextPadding, 0, line.length - 1), contextPadding * 2);
};
module.exports = {
customRules: [
// "markdownlint-rule-emphasis-style",
"markdownlint-rule-github-internal-links",
{
names: ["ban-words"],
description: "Using a banned word",
tags: ["style"],
function: (params, onError) => {
forEachLine(getLineMetadata(params), (line, lineIndex) => {
for (const word of excludedWords) {
const column = line.indexOf(word);
if (column >= 0) {
onError({
lineNumber: lineIndex + 1,
detail: `Found banned word "${word}" at column ${column}`,
context: extractContext(line, column),
range: [column + 1, 1],
});
}
}
});
},
},
{
names: ["proper-typography"],
description: "Using improper typography",
tags: ["style"],
function: (params, onError) => {
forEachLine(getLineMetadata(params), (line, lineIndex) => {
for (const [character, replacement] of excludedTypography) {
const column = line.indexOf(character);
if (column >= 0) {
onError({
lineNumber: lineIndex + 1,
detail: `Found invalid character "${character}" at column ${column}`,
context: extractContext(line, column),
range: [column + 1, 1],
fixInfo: {
lineNumber: lineIndex + 1,
editColumn: column + 1,
deleteCount: 1,
insertText: replacement,
},
});
}
}
});
},
},
],
config: {
"code-block-style": {
// MD046
style: "fenced",
},
"code-fence-style": {
// MD048
style: "",
},
"emphasis-style": {
// MD049
style: "consistent",
},
"first-line-heading": {
// MD041
level: 2,
},
"github-internal-links": {
// custom
verbose: false,
},
"heading-style": {
// MD003
style: "atx",
},
"line-length": false, // MD013
// We intentionally have unused reference links in a lot of pages, so this rule is disabled
"link-image-reference-definitions": false, // MD053
"list-marker-space": {
// MD030
ul_multi: 3,
ul_single: 3,
},
"no-empty-links": true, // MD042
"no-bare-urls": false, // MD034
"no-hard-tabs": {
// MD010
code_blocks: false,
spaces_per_tab: 2,
},
"no-inline-html": false, //MD033
"no-multiple-blanks": {
// MD012
maximum: 2,
},
"no-trailing-spaces": {
// MD009
br_spaces: 0,
},
"proper-names": {
// MD044
code_blocks: false,
names: [
"Azure AD",
"Azure Active Directory",
"Azure Fluid Relay",
"Fluid container",
"Fluid containers",
"Fluid Framework",
"JavaScript",
"JSON",
"Microsoft",
"microsoft.com",
"npm",
"Routerlicious",
"Tinylicious",
// Without the following entries, markdownlint incorrectly flags various correct usages of tinylicious.
"tinylicious.md",
"tinylicious-client",
'{{< packageref "tinylicious" >}}',
],
},
"reference-links-images": false, // MD052
"ul-indent": {
// MD007
indent: 4,
},
},
globs: [
"content/**/*.md",
"!content/_index.md", // Markdown-lint doesn't like our use of Hugo's "highlight" shortcode for code blocks
"!content/docs/apis",
"!content/docs/api",
"!node_modules",
],
};