Skip to content

Commit 52e17b1

Browse files
committed
feature: @putout/plugin-nodejs: convert-exports-to-module-exports: declared
1 parent 3e4a9e8 commit 52e17b1

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function x() {
2+
const exports = [];
3+
4+
return exports.join('');
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import {operator} from 'putout';
2+
3+
const {getBindingPath} = operator;
4+
15
export const report = () => `Use 'module.exports' instead of 'exports'`;
26

7+
export const match = () => ({
8+
'exports.__a': (vars, path) => {
9+
const bindingPath = getBindingPath(path, 'exports');
10+
11+
return !bindingPath;
12+
},
13+
});
14+
315
export const replace = () => ({
416
'exports.__a': 'module.exports.__a',
517
});

packages/plugin-nodejs/lib/convert-exports-to-module-exports/index.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ test('packages: convert-exports-to-module-exports: transform', (t) => {
1616
t.transform('convert-exports-to-module-exports');
1717
t.end();
1818
});
19+
20+
test('packages: convert-exports-to-module-exports: no report: declared', (t) => {
21+
t.noReport('declared');
22+
t.end();
23+
});

0 commit comments

Comments
 (0)