redput 4.0.2 → 4.1.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/get-report/plugin-get-report/index.js +1 -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 +5 -1
- package/package.json +3 -3
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2026.02.11, v4.1.1
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- b639c8d redput: get-report: template
|
|
5
|
+
|
|
6
|
+
2026.02.11, v4.1.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- ed3b186 redput: write: nested: get-report: escape
|
|
10
|
+
- 6bf87a9 redput: add-index-to-import: add from @putout/esm (https://github.com/coderaiser/putout/commit/41ea5055e45d0276d37112399e4d010dc278b134)
|
|
11
|
+
- 039b2ce redput: eslint v10.0.0
|
|
12
|
+
- bbaba55 redput: @putout/plugin-esm v9.7.0
|
|
13
|
+
|
|
1
14
|
2026.01.26, v4.0.2
|
|
2
15
|
|
|
3
16
|
feature:
|
|
@@ -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,11 @@ 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;
|
|
14
|
+
|
|
11
15
|
const strTest = `
|
|
12
16
|
test('plugin-${plugin}: transform: ${rule}', (t) => {
|
|
13
17
|
t.transform('${rule}');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redput",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "CLI tool to convert source from 🐊Putout Editor to files",
|
|
5
5
|
"main": "lib/redput.js",
|
|
6
6
|
"bin": {
|
|
@@ -57,7 +57,7 @@
|
|
|
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": "^
|
|
60
|
+
"@putout/plugin-esm": "^9.7.0",
|
|
61
61
|
"@putout/plugin-nodejs": "^20.0.0",
|
|
62
62
|
"@putout/plugin-putout": "^28.2.0",
|
|
63
63
|
"@putout/plugin-variables": "^1.3.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@putout/test": "^15.0.0",
|
|
73
73
|
"c8": "^10.1.2",
|
|
74
|
-
"eslint": "^
|
|
74
|
+
"eslint": "^10.0.0",
|
|
75
75
|
"eslint-plugin-putout": "^30.0.1",
|
|
76
76
|
"madrun": "^12.1.0",
|
|
77
77
|
"montag": "^1.2.1",
|