redput 4.7.0 → 4.8.1
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 +13 -0
- package/lib/compile-rule/compile-rule.d.ts +4 -0
- package/lib/run-rule/run-rule.js +1 -1
- package/lib/write/nested/nested.js +2 -2
- package/lib/write/nested/write-readme/README.md +4 -0
- package/lib/write/nested/write-readme/insert-rule-config/insert-rule-config.js +28 -0
- package/lib/write/nested/write-readme/insert-rule-link/index.js +0 -1
- package/lib/write/nested/write-readme/write-readme.js +5 -2
- package/package.json +9 -3
package/ChangeLog
CHANGED
package/lib/run-rule/run-rule.js
CHANGED
|
@@ -37,7 +37,7 @@ export const writeNestedFixtures = async (name, data, ext, correct, overrides =
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
await write(`./${name}/fixture/${name}.${ext}`, data);
|
|
40
|
-
await write(`./${name}/fixture/${name}-fix.${ext}`, correct
|
|
40
|
+
await write(`./${name}/fixture/${name}-fix.${ext}`, correct || data);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export const writeNestedTests = async (name, report) => {
|
|
@@ -95,5 +95,5 @@ export const updateOverallNestedFixtures = async (name, data, ext, correct, over
|
|
|
95
95
|
const {write = writeFile} = overrides;
|
|
96
96
|
|
|
97
97
|
await write(`../test/fixture/${name}.${ext}`, data);
|
|
98
|
-
await write(`../test/fixture/${name}-fix.${ext}`, correct
|
|
98
|
+
await write(`../test/fixture/${name}-fix.${ext}`, correct || data);
|
|
99
99
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# Rules
|
|
2
|
+
|
|
3
|
+
- ✅ [insert-rule-link](https://putout.cloudcmd.io/#/gist/8626a1a61f46226f315eac8d6e08e61c/2898e049b8b2664e10eca1ddc2373feb45b67c85);
|
|
4
|
+
- ✅ [insert-rule-section](https://putout.cloudcmd.io/#/gist/4a0650e6b06735128cc2eaf4ad060c33/7ad2a3a767918b3a7d6bac77113b1ce2e3ff72c2);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {stringify} = JSON;
|
|
4
|
+
const {assign, keys} = Object;
|
|
5
|
+
const {fromJS, toJS} = operator;
|
|
6
|
+
|
|
7
|
+
export function maybeInsertRuleToJson(name, json) {
|
|
8
|
+
if (!json)
|
|
9
|
+
return [];
|
|
10
|
+
|
|
11
|
+
if (json.extension !== 'json')
|
|
12
|
+
return [];
|
|
13
|
+
|
|
14
|
+
const result = toJS(insertRuleToJson(name, fromJS(json.source)));
|
|
15
|
+
|
|
16
|
+
return [result];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function insertRuleToJson(name, json) {
|
|
20
|
+
const object = JSON.parse(json);
|
|
21
|
+
const [plugin] = keys(object.rules)[0].split('/');
|
|
22
|
+
|
|
23
|
+
assign(object.rules, {
|
|
24
|
+
[`${plugin}/${name}`]: 'on',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return stringify(object, null, 4);
|
|
28
|
+
}
|
|
@@ -5,6 +5,7 @@ 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
7
|
import * as insertRuleLink from './insert-rule-link/index.js';
|
|
8
|
+
import {maybeInsertRuleToJson} from './insert-rule-config/insert-rule-config.js';
|
|
8
9
|
|
|
9
10
|
const README = 'README.md';
|
|
10
11
|
const getSource = (a) => a.source;
|
|
@@ -20,7 +21,8 @@ export const writeReadme = async (name, link, correct, incorrect, overrides = {}
|
|
|
20
21
|
const readme = await read(readmePath, 'utf8');
|
|
21
22
|
|
|
22
23
|
const list = await branch(readme);
|
|
23
|
-
const [
|
|
24
|
+
const [markdown, json] = list;
|
|
25
|
+
const {source} = markdown;
|
|
24
26
|
|
|
25
27
|
const {code} = putout(source, {
|
|
26
28
|
rules: {
|
|
@@ -42,8 +44,9 @@ export const writeReadme = async (name, link, correct, incorrect, overrides = {}
|
|
|
42
44
|
|
|
43
45
|
const newList = [
|
|
44
46
|
code,
|
|
47
|
+
...maybeInsertRuleToJson(name, json),
|
|
45
48
|
...list
|
|
46
|
-
.slice(
|
|
49
|
+
.slice(2)
|
|
47
50
|
.map(getSource),
|
|
48
51
|
incorrect,
|
|
49
52
|
correct,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redput",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "CLI tool to convert source from 🐊Putout Editor to files",
|
|
5
5
|
"main": "lib/redput.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
10
|
"./plugin/get-report": "./lib/get-report/plugin-get-report/index.js",
|
|
11
|
-
"./compile-rule":
|
|
11
|
+
"./compile-rule": {
|
|
12
|
+
"types": "./lib/compile-rule/compile-rule.d.ts",
|
|
13
|
+
"default": "./lib/compile-rule/compile-rule.js"
|
|
14
|
+
}
|
|
12
15
|
},
|
|
13
16
|
"type": "module",
|
|
14
17
|
"scripts": {
|
|
@@ -17,6 +20,7 @@
|
|
|
17
20
|
"lint:fresh": "madrun lint:fresh",
|
|
18
21
|
"fix:lint": "madrun fix:lint",
|
|
19
22
|
"test": "madrun test",
|
|
23
|
+
"test:dts": "madrun test:dts",
|
|
20
24
|
"watch:test": "madrun watch:test",
|
|
21
25
|
"watch:tape": "madrun watch:tape",
|
|
22
26
|
"watch:lint": "madrun watch:lint",
|
|
@@ -76,6 +80,7 @@
|
|
|
76
80
|
},
|
|
77
81
|
"devDependencies": {
|
|
78
82
|
"@putout/test": "^15.0.0",
|
|
83
|
+
"check-dts": "^1.0.0",
|
|
79
84
|
"eslint": "^10.0.0",
|
|
80
85
|
"eslint-plugin-putout": "^31.0.0",
|
|
81
86
|
"madrun": "^13.0.0",
|
|
@@ -83,7 +88,8 @@
|
|
|
83
88
|
"nodemon": "^3.0.1",
|
|
84
89
|
"redlint": "^6.0.0",
|
|
85
90
|
"superc8": "^12.2.4",
|
|
86
|
-
"supertape": "^13.0.0"
|
|
91
|
+
"supertape": "^13.0.0",
|
|
92
|
+
"typescript": "^6.0.0"
|
|
87
93
|
},
|
|
88
94
|
"publishConfig": {
|
|
89
95
|
"access": "public"
|