redput 4.0.1 → 4.1.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 +15 -0
- package/lib/get-report/plugin-get-report/index.js +3 -1
- package/lib/write/nested/add-rule/add-rule.js +2 -0
- package/lib/write/nested/add-rule/plugin-add-index-to-import/index.js +48 -0
- package/lib/write/nested/insert-test/plugin-insert-test/index.js +4 -1
- package/package.json +5 -5
package/ChangeLog
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
2026.02.11, v4.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ed3b186 redput: write: nested: get-report: escape
|
|
5
|
+
- 6bf87a9 redput: add-index-to-import: add from @putout/esm (https://github.com/coderaiser/putout/commit/41ea5055e45d0276d37112399e4d010dc278b134)
|
|
6
|
+
- 039b2ce redput: eslint v10.0.0
|
|
7
|
+
- bbaba55 redput: @putout/plugin-esm v9.7.0
|
|
8
|
+
|
|
9
|
+
2026.01.26, v4.0.2
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 799fc13 redput: eslint-plugin-putout v30.0.1
|
|
13
|
+
- 013d80e redput: @putout/plugin-nodejs v20.0.0
|
|
14
|
+
- c210145 redput: @putout/plugin-esm v8.0.0
|
|
15
|
+
|
|
1
16
|
2026.01.11, v4.0.1
|
|
2
17
|
|
|
3
18
|
feature:
|
|
@@ -46,7 +46,7 @@ const process = ({push, template}) => (path) => {
|
|
|
46
46
|
|
|
47
47
|
function parseValue(a) {
|
|
48
48
|
if (isStringLiteral(a))
|
|
49
|
-
return a.value;
|
|
49
|
+
return a.value.replaceAll('`', '\\`');
|
|
50
50
|
|
|
51
51
|
let value;
|
|
52
52
|
|
|
@@ -65,5 +65,7 @@ function parseValue(a) {
|
|
|
65
65
|
if (value.endsWith(';'))
|
|
66
66
|
value = value.slice(0, -2);
|
|
67
67
|
|
|
68
|
+
value = value.replaceAll('`', '\\\\`');
|
|
69
|
+
|
|
68
70
|
return value.replaceAll('${', '{');
|
|
69
71
|
}
|
|
@@ -5,6 +5,7 @@ import * as variables from '@putout/plugin-variables';
|
|
|
5
5
|
import * as esm from '@putout/plugin-esm';
|
|
6
6
|
import * as insertGetRulePlugin from './plugin-insert-get-rule/index.js';
|
|
7
7
|
import * as applyNamespace from './plugin-apply-namespace/index.js';
|
|
8
|
+
import * as addIndexToImportPlugin from './plugin-add-index-to-import/index.js';
|
|
8
9
|
|
|
9
10
|
export const addRule = (name, source, ruleOptions) => {
|
|
10
11
|
const {code} = putout(source, {
|
|
@@ -27,6 +28,7 @@ export const addRule = (name, source, ruleOptions) => {
|
|
|
27
28
|
['variables/remove-unused', variables.rules['remove-unused']],
|
|
28
29
|
['add-rule', insertGetRulePlugin],
|
|
29
30
|
['esm', esm],
|
|
31
|
+
['add-index-to-import', addIndexToImportPlugin],
|
|
30
32
|
],
|
|
31
33
|
});
|
|
32
34
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {setLiteralValue} = operator;
|
|
4
|
+
|
|
5
|
+
export const report = (path) => {
|
|
6
|
+
const {value} = path.node.source;
|
|
7
|
+
return `Add 'index.js' to import: '${value}' -> '${value}/index.js'`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const fix = (path) => {
|
|
11
|
+
const {source} = path.node;
|
|
12
|
+
const {value} = source;
|
|
13
|
+
|
|
14
|
+
if (value.endsWith('.js')) {
|
|
15
|
+
setLiteralValue(source, value.replace('.js', '/index.js'));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setLiteralValue(source, `${value}/index.js`);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const traverse = ({push, listStore}) => ({
|
|
23
|
+
'export const rules = __object': listStore,
|
|
24
|
+
'Program': {
|
|
25
|
+
exit: (path) => {
|
|
26
|
+
const rules = listStore();
|
|
27
|
+
|
|
28
|
+
if (!rules.length)
|
|
29
|
+
return;
|
|
30
|
+
|
|
31
|
+
operator.traverse(path, {
|
|
32
|
+
ImportDeclaration: createImportVisitor(push),
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const createImportVisitor = (push) => (path) => {
|
|
39
|
+
const {value} = path.node.source;
|
|
40
|
+
|
|
41
|
+
if (value.endsWith('.cjs'))
|
|
42
|
+
return;
|
|
43
|
+
|
|
44
|
+
if (value.endsWith('index.js'))
|
|
45
|
+
return;
|
|
46
|
+
|
|
47
|
+
push(path);
|
|
48
|
+
};
|
|
@@ -7,7 +7,10 @@ export const fix = ({path, nodeTest}) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const traverse = ({push, pathStore, options}) => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
plugin = 'github',
|
|
12
|
+
rule = 'insert-test',
|
|
13
|
+
} = options;
|
|
11
14
|
const strTest = `
|
|
12
15
|
test('plugin-${plugin}: transform: ${rule}', (t) => {
|
|
13
16
|
t.transform('${rule}');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redput",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "CLI tool to convert source from 🐊Putout Editor to files",
|
|
5
5
|
"main": "lib/redput.js",
|
|
6
6
|
"bin": {
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@putout/plugin-declare": "^7.1.0",
|
|
59
59
|
"@putout/plugin-declare-before-reference": "^9.0.0",
|
|
60
|
-
"@putout/plugin-esm": "^
|
|
61
|
-
"@putout/plugin-nodejs": "^
|
|
60
|
+
"@putout/plugin-esm": "^9.7.0",
|
|
61
|
+
"@putout/plugin-nodejs": "^20.0.0",
|
|
62
62
|
"@putout/plugin-putout": "^28.2.0",
|
|
63
63
|
"@putout/plugin-variables": "^1.3.1",
|
|
64
64
|
"node-fetch": "^3.3.2",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@putout/test": "^15.0.0",
|
|
73
73
|
"c8": "^10.1.2",
|
|
74
|
-
"eslint": "^
|
|
75
|
-
"eslint-plugin-putout": "^
|
|
74
|
+
"eslint": "^10.0.0",
|
|
75
|
+
"eslint-plugin-putout": "^30.0.1",
|
|
76
76
|
"madrun": "^12.1.0",
|
|
77
77
|
"montag": "^1.2.1",
|
|
78
78
|
"nodemon": "^3.0.1",
|