redput 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {template, operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
compare,
|
|
5
|
+
__markdown,
|
|
6
|
+
insertAfter,
|
|
7
|
+
} = operator;
|
|
8
|
+
|
|
9
|
+
export const report = ({name}) => `insert '#${name}' link to Rules`;
|
|
10
|
+
|
|
11
|
+
export const fix = ({name, rules}) => {
|
|
12
|
+
const nodeLink = template.ast(`ul(li('✅ ', link('${name}', '#${name}')))`);
|
|
13
|
+
insertAfter(rules, nodeLink);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const traverse = ({options, push}) => {
|
|
17
|
+
const {name = 'hello'} = options;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
[__markdown]: (path) => {
|
|
21
|
+
const elements = path.get('arguments.0.elements');
|
|
22
|
+
const {rules, link} = parseElements(elements, name);
|
|
23
|
+
|
|
24
|
+
if (link)
|
|
25
|
+
return;
|
|
26
|
+
|
|
27
|
+
if (!rules)
|
|
28
|
+
return;
|
|
29
|
+
|
|
30
|
+
push({
|
|
31
|
+
path,
|
|
32
|
+
name,
|
|
33
|
+
rules,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function parseElements(elements, name) {
|
|
40
|
+
let link;
|
|
41
|
+
let rules;
|
|
42
|
+
|
|
43
|
+
for (const element of elements) {
|
|
44
|
+
if (compare(element, `ul(li('✅ ', link('${name}', '#${name}')))`)) {
|
|
45
|
+
link = element;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (compare(element, `heading(2, 'Rules')`))
|
|
50
|
+
rules = element;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
link,
|
|
55
|
+
rules,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
@@ -4,6 +4,7 @@ import process from 'node:process';
|
|
|
4
4
|
import {putout} from 'putout';
|
|
5
5
|
import {branch, merge} from '@putout/processor-markdown';
|
|
6
6
|
import * as insertRuleSection from './insert-rule-section/index.js';
|
|
7
|
+
import * as insertRuleLink from './insert-rule-link/index.js';
|
|
7
8
|
|
|
8
9
|
const README = 'README.md';
|
|
9
10
|
const getSource = (a) => a.source;
|
|
@@ -29,9 +30,13 @@ export const writeReadme = async (name, link, correct, incorrect, overrides = {}
|
|
|
29
30
|
correct,
|
|
30
31
|
incorrect,
|
|
31
32
|
}],
|
|
33
|
+
'insert-rule-link': ['on', {
|
|
34
|
+
name,
|
|
35
|
+
}],
|
|
32
36
|
},
|
|
33
37
|
plugins: [
|
|
34
38
|
['insert-rule-section', insertRuleSection],
|
|
39
|
+
['insert-rule-link', insertRuleLink],
|
|
35
40
|
],
|
|
36
41
|
});
|
|
37
42
|
|