Skip to content

Commit 54bb365

Browse files
committed
feature: @putout/plugin-declare-before-reference: migtrate to ESM
1 parent 610b43b commit 54bb365

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed
File renamed without changes.

packages/plugin-declare-before-reference/eslint.config.mjs renamed to packages/plugin-declare-before-reference/eslint.config.js

File renamed without changes.

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict';
1+
import {types, operator} from 'putout';
22

3-
const {types, operator} = require('putout');
43
const {
54
remove,
65
compare,
@@ -22,11 +21,11 @@ const getTopUID = (a) => a.find(isTopScope).scope.uid;
2221
const getBlockUID = (a) => a.find(isBlockStatement)?.scope.uid;
2322
const getKey = (a) => a.key;
2423

25-
module.exports.report = ({name}) => {
24+
export const report = ({name}) => {
2625
return `Declare '${name}' before referencing to avoid 'ReferenceError'`;
2726
};
2827

29-
module.exports.fix = ({path, referencePath}) => {
28+
export const fix = ({path, referencePath}) => {
3029
const {node} = path.parentPath;
3130
const programPath = path.scope.getProgramParent().path;
3231

@@ -55,7 +54,7 @@ module.exports.fix = ({path, referencePath}) => {
5554
path.__putout_declare_before_reference = true;
5655
};
5756

58-
module.exports.traverse = ({push}) => ({
57+
export const traverse = ({push}) => ({
5958
'Program|BlockStatement'(path) {
6059
const {bindings} = path.scope;
6160

packages/plugin-declare-before-reference/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@putout/plugin-declare-before-reference",
33
"version": "6.2.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin adds ability move declarations before references",
77
"homepage": "http://github.com/coderaiser/putout/tree/master/packages/plugin-declare-before-reference#readme",

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
'use strict';
2-
3-
const {createTest} = require('@putout/test');
4-
5-
const putout = require('@putout/plugin-putout');
6-
const tryCatch = require('@putout/plugin-try-catch');
7-
const promises = require('@putout/plugin-promises');
8-
const printer = require('@putout/plugin-printer');
9-
const removeNestedBlocks = require('@putout/plugin-remove-nested-blocks');
10-
const nodejs = require('@putout/plugin-nodejs');
11-
const reuseDuplicateInit = require('@putout/plugin-reuse-duplicate-init');
12-
const declare = require('..');
13-
14-
const test = createTest(__dirname, {
1+
import {createTest} from '@putout/test';
2+
import * as putout from '@putout/plugin-putout';
3+
import * as tryCatch from '@putout/plugin-try-catch';
4+
import * as promises from '@putout/plugin-promises';
5+
import * as printer from '@putout/plugin-printer';
6+
import * as removeNestedBlocks from '@putout/plugin-remove-nested-blocks';
7+
import * as nodejs from '@putout/plugin-nodejs';
8+
import * as reuseDuplicateInit from '@putout/plugin-reuse-duplicate-init';
9+
import * as declare from '../lib/declare-before-reference.js';
10+
11+
const test = createTest(import.meta.url, {
1512
plugins: [
1613
['declare-before-reference', declare],
1714
],

0 commit comments

Comments
 (0)