redput 4.7.0 → 4.8.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
@@ -1,3 +1,8 @@
1
+ 2026.08.30, v4.8.0
2
+
3
+ feature:
4
+ - c2c4c2a redput: write-readme: insert-rule-config
5
+
1
6
  2026.08.30, v4.7.0
2
7
 
3
8
  feature:
@@ -14,7 +14,7 @@ export const runRule = (ruleSource, source) => {
14
14
  },
15
15
  });
16
16
 
17
- plugin.report = plugin.report ?? noop;
17
+ plugin.report = plugin.report || noop;
18
18
 
19
19
  const {code} = putout(source, {
20
20
  cache: false,
@@ -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 ?? data);
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 ?? data);
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
+ }
@@ -55,4 +55,3 @@ function parseElements(elements, name) {
55
55
  rules,
56
56
  };
57
57
  }
58
-
@@ -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 [{source}] = list;
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(1)
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.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "CLI tool to convert source from 🐊Putout Editor to files",
5
5
  "main": "lib/redput.js",
6
6
  "bin": {