Skip to content

Commit 5a21a7d

Browse files
committed
feature: @putout/plugin-putout: convert-report-to-function: esm
1 parent 5e626ee commit 5a21a7d

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const report = () => 'hello';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const report = 'hello';

packages/plugin-putout/lib/convert-report-to-function/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ const {
55
isTemplateLiteral,
66
} = types;
77

8+
const check = ({__a}) => isStringLiteral(__a) || isTemplateLiteral(__a);
9+
810
export const report = () => `Typeof 'report' should be a 'function'`;
911

1012
export const match = () => ({
11-
'module.exports.report = __a': ({__a}) => isStringLiteral(__a) || isTemplateLiteral(__a),
13+
'module.exports.report = __a': check,
14+
'export const report = __a': check,
1215
});
1316

1417
export const replace = () => ({
1518
'module.exports.report = __a': 'module.exports.report = () => __a',
19+
'export const report = __a': 'export const report = () => __a',
1620
});

packages/plugin-putout/lib/convert-report-to-function/index.spec.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ const test = createTest(import.meta.url, {
77
],
88
});
99

10-
test('plugin-putout: convert report to function: report: convert-report-to-function', (t) => {
10+
test('plugin-putout: convert-report-to-function: report: convert-report-to-function', (t) => {
1111
t.report('convert-report-to-function', `Typeof 'report' should be a 'function'`);
1212
t.end();
1313
});
1414

15-
test('plugin-putout: convert report to function: transform: convert-report-to-function', (t) => {
15+
test('plugin-putout: convert-report-to-function: transform: convert-report-to-function', (t) => {
1616
t.transform('convert-report-to-function');
1717
t.end();
1818
});
1919

20-
test('plugin-putout: convert report to function: transform: template', (t) => {
20+
test('plugin-putout: convert-report-to-function: transform: template', (t) => {
2121
t.transform('template');
2222
t.end();
2323
});
24+
25+
test('plugin-putout: convert-report-to-function: transform: esm', (t) => {
26+
t.transform('esm');
27+
t.end();
28+
});

0 commit comments

Comments
 (0)