Skip to content

Commit aa13973

Browse files
committed
feature: @putout/declare-before-reference: exclude require
1 parent 8f0336e commit aa13973

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

packages/plugin-declare-before-reference/lib/declare-before-reference.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ module.exports.traverse = ({push}) => ({
4444
const {bindings} = path.scope;
4545

4646
for (const [name, value] of entries(bindings)) {
47+
if (name === 'require')
48+
continue;
49+
4750
const {referencePaths, path} = value;
4851
const {uid} = path.scope;
4952

packages/plugin-declare-before-reference/test/declare-before-reference.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ test('plugin-declare-before-reference: no transform: export-type', (t) => {
9292
t.end();
9393
});
9494

95+
test('plugin-declare-before-reference: no transform: require', (t) => {
96+
t.noTransform('require');
97+
t.end();
98+
});
99+
95100
test('plugin-declare-before-reference: no report: apply-types', (t) => {
96101
t.noReportAfterTransform('apply-types', {
97102
'apply-types': printer.rules['apply-types'],
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const {createRequire} = require('node:module');
2+
const require = createRequire(import.meta.url);

0 commit comments

Comments
 (0)