forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.markdownlint-cli2.js
138 lines (132 loc) · 4.46 KB
/
.markdownlint-cli2.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
/*!
* 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": { // custom
"style": "*",
},
"first-line-heading": { // MD041
"level": 2,
},
"github-internal-links": { // custom
"verbose": false,
},
"heading-style": { // MD003
"style": "atx",
},
"line-length": false, // MD013
// "line-length": { // MD013
// "code_blocks": true,
// "line_length": 120,
// "tables": false,
// },
"no-empty-links": true, // MD042
"no-inline-html": false, //MD033
"no-multiple-blanks": { // MD012
"maximum": 2,
},
"proper-names": { // MD044
"code_blocks": false,
"names": [
"Azure AD",
"Azure Active Directory",
"Azure Fluid Relay",
"Fluid container",
"Fluid containers",
"Fluid Framework",
"JavaScript",
"JSON",
"Microsoft",
"npm",
"Routerlicious",
"Tinylicious",
// Without the following entries, markdownlint incorrectly flags various correct usages of tinylicious.
"tinylicious.md",
"tinylicious-client",
]
}
},
"globs": [
"content/**/*.md",
"!content/docs/apis",
"!node_modules",
]
};