forked from sindresorhus/awesome-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode-of-conduct.js
34 lines (29 loc) · 942 Bytes
/
code-of-conduct.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
import {find} from 'unist-util-find';
import {lintRule} from 'unified-lint-rule';
import findAuthorName from '../lib/find-author-name.js';
const authorName = 'sindresorhus';
const authorEmail = '[email protected]';
const codeOfConductRule = lintRule('remark-lint:awesome-code-of-conduct', (ast, file) => {
if (ast.children.length === 0) {
file.message('code-of-conduct.md file must not be empty');
return;
}
const placeholder = find(ast, node => (
node.type === 'linkReference'
&& node.label === 'INSERT EMAIL ADDRESS'
));
if (placeholder) {
file.message('The email placeholder must be replaced with yours', placeholder);
return;
}
if (findAuthorName(file) !== authorName) {
const email = find(ast, node => (
node.type === 'text'
&& node.value.includes(authorEmail)
));
if (email) {
file.message('The default email must be replaced with yours', email);
}
}
});
export default codeOfConductRule;