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 CHANGED
@@ -1,3 +1,16 @@
1
+ 2026.09.10, v4.8.1
2
+
3
+ fix:
4
+ - 348ff88 types
5
+
6
+ feature:
7
+ - 4ec5a27 redput: compileRule: types
8
+
9
+ 2026.08.30, v4.8.0
10
+
11
+ feature:
12
+ - c2c4c2a redput: write-readme: insert-rule-config
13
+
1
14
  2026.08.30, v4.7.0
2
15
 
3
16
  feature:
@@ -0,0 +1,4 @@
1
+ export type Rule = Record<string, unknown>;
2
+
3
+ export function compileRule(code: string, globals?: Record<string, unknown>): Rule;
4
+
@@ -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.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": "./lib/compile-rule/compile-rule.js"
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"