redput 3.3.0 → 3.5.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,16 @@
1
+ 2025.06.02, v3.5.0
2
+
3
+ feature:
4
+ - 81ec471 apply-namespace
5
+ - 7b40985 redput: octokit v5.0.3
6
+ - f5f6955 redput: @putout/plugin-remove-unused-variables v14.0.0
7
+ - 03cfc29 redput: eslint-plugin-putout v27.1.0
8
+
9
+ 2025.05.19, v3.4.0
10
+
11
+ feature:
12
+ - 92fe650 redput: isTSCode: add
13
+
1
14
  2025.05.08, v3.3.0
2
15
 
3
16
  feature:
@@ -52,7 +52,7 @@ function parseValue(a) {
52
52
 
53
53
  operator.traverse(a, {
54
54
  ReturnStatement(path) {
55
- value = print(path.get('argument'));
55
+ value = path.get('argument').toString();
56
56
  },
57
57
  });
58
58
 
@@ -13,6 +13,7 @@ import {
13
13
  writeRule,
14
14
  writeTests,
15
15
  } from './simple.js';
16
+ import {isTSCode} from './is-ts/index.js';
16
17
 
17
18
  export const writePlugin = async (name, {rule, fixture, report, options}) => {
18
19
  const [isNested] = await tryToCatch(access, './package.json');
@@ -33,19 +34,23 @@ export const writePlugin = async (name, {rule, fixture, report, options}) => {
33
34
  };
34
35
 
35
36
  export const writeNested = async (name, {rule, fixture, report, options}) => {
37
+ const isTS = isTSCode(fixture);
38
+ const ext = isTS ? 'ts' : 'js';
39
+
36
40
  await writeNestedRule(name, rule, options);
37
- await writeNestedFixtures(name, fixture);
41
+ await writeNestedFixtures(name, fixture, ext);
38
42
  await writeNestedTests(name, report);
39
43
 
40
44
  await tryToCatch(writeNestedOptional, name, {
41
45
  options,
42
46
  fixture,
47
+ ext,
43
48
  });
44
49
  };
45
50
 
46
- export const writeNestedOptional = async (name, {options, fixture}) => {
51
+ export const writeNestedOptional = async (name, {options, fixture, ext}) => {
47
52
  await updateNestedIndex(name, options);
48
- await updateOverallNestedFixtures(name, fixture);
53
+ await updateOverallNestedFixtures(name, fixture, ext);
49
54
  await updateOverallNestedTest(name);
50
55
  };
51
56
 
@@ -0,0 +1,10 @@
1
+ import {parse} from 'putout';
2
+ import tryCatch from 'try-catch';
3
+
4
+ export const isTSCode = (source) => {
5
+ const [error] = tryCatch(parse, source, {
6
+ isTS: false,
7
+ });
8
+
9
+ return Boolean(error);
10
+ };
@@ -4,6 +4,7 @@ import * as nodejs from '@putout/plugin-nodejs';
4
4
  import * as removeUnusedVariables from '@putout/plugin-remove-unused-variables';
5
5
  import * as esm from '@putout/plugin-esm';
6
6
  import * as insertGetRulePlugin from './plugin-insert-get-rule/index.js';
7
+ import * as applyNamespace from './plugin-apply-namespace/index.js';
7
8
 
8
9
  export const addRule = (name, source, ruleOptions) => {
9
10
  const {code} = putout(source, {
@@ -20,6 +21,7 @@ export const addRule = (name, source, ruleOptions) => {
20
21
  }],
21
22
  },
22
23
  plugins: [
24
+ ['apply-namespace', applyNamespace],
23
25
  ['nodejs', nodejs],
24
26
  ['putout', pluginPutout],
25
27
  ['remove-unused-variables', removeUnusedVariables],
@@ -0,0 +1,5 @@
1
+ export const report = () => `Apply namespace`;
2
+
3
+ export const replace = () => ({
4
+ 'import __a from "__b"': 'import * as __a from "__b"',
5
+ });
@@ -24,13 +24,13 @@ export const writeNestedRule = async (name, data) => {
24
24
  await writeFile(`./${name}/index.js`, code);
25
25
  };
26
26
 
27
- export const writeNestedFixtures = async (name, data) => {
27
+ export const writeNestedFixtures = async (name, data, ext) => {
28
28
  await mkdir(`./${name}/fixture`, {
29
29
  recursive: true,
30
30
  });
31
31
 
32
- await writeFile(`./${name}/fixture/${name}.js`, data);
33
- await writeFile(`./${name}/fixture/${name}-fix.js`, data);
32
+ await writeFile(`./${name}/fixture/${name}.${ext}`, data);
33
+ await writeFile(`./${name}/fixture/${name}-fix.${ext}`, data);
34
34
  };
35
35
 
36
36
  export const writeNestedTests = async (name, report) => {
@@ -63,7 +63,7 @@ export const updateOverallNestedTest = async (name) => {
63
63
  await writeFile(`../test/${plugin}.js`, code);
64
64
  };
65
65
 
66
- export const updateOverallNestedFixtures = async (name, data) => {
67
- await writeFile(`../test/fixture/${name}.js`, data);
68
- await writeFile(`../test/fixture/${name}-fix.js`, data);
66
+ export const updateOverallNestedFixtures = async (name, data, ext) => {
67
+ await writeFile(`../test/fixture/${name}.${ext}`, data);
68
+ await writeFile(`../test/fixture/${name}-fix.${ext}`, data);
69
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redput",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "CLI tool to convert source from 🐊Putout Editor to files",
5
5
  "main": "lib/redput.js",
6
6
  "bin": {
@@ -60,9 +60,9 @@
60
60
  "@putout/plugin-esm": "^4.0.0",
61
61
  "@putout/plugin-nodejs": "^16.1.0",
62
62
  "@putout/plugin-putout": "^25.0.0",
63
- "@putout/plugin-remove-unused-variables": "^12.0.0",
63
+ "@putout/plugin-remove-unused-variables": "^14.0.0",
64
64
  "node-fetch": "^3.3.2",
65
- "octokit": "^4.0.2",
65
+ "octokit": "^5.0.3",
66
66
  "putout": "^40.0.1",
67
67
  "rendy": "^4.1.3",
68
68
  "try-catch": "^3.0.1",
@@ -73,7 +73,7 @@
73
73
  "c8": "^10.1.2",
74
74
  "escover": "^4.0.1",
75
75
  "eslint": "^9.0.0",
76
- "eslint-plugin-putout": "^26.1.0",
76
+ "eslint-plugin-putout": "^27.1.0",
77
77
  "madrun": "^11.0.0",
78
78
  "montag": "^1.2.1",
79
79
  "nodemon": "^3.0.1",