Skip to content

Commit 44576ac

Browse files
committed
feature: @putout/plugin-label: migrate to ESM
1 parent 66de59c commit 44576ac

File tree

9 files changed

+25
-36
lines changed

9 files changed

+25
-36
lines changed

packages/plugin-labels/lib/convert-to-object/index.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
objectExpression,
65
isLabeledStatement,
@@ -9,9 +8,9 @@ const {
98

109
const {replaceWith} = operator;
1110

12-
module.exports.report = () => `Convert 'label' to 'object'`;
11+
export const report = () => `Convert 'label' to 'object'`;
1312

14-
module.exports.match = () => ({
13+
export const match = () => ({
1514
'(__args) => __body': ({__body}) => {
1615
if (!__body.body.length)
1716
return false;
@@ -25,7 +24,7 @@ module.exports.match = () => ({
2524
},
2625
});
2726

28-
module.exports.replace = () => ({
27+
export const replace = () => ({
2928
'(__args) => __body': ({__body}, path) => {
3029
const properties = [];
3130

packages/plugin-labels/lib/convert-to-object/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['convert-to-object', plugin],
97
],
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import * as convertToObject from './convert-to-object/index.js';
2+
import * as removeUnused from './remove-unused/index.js';
23

3-
const convertToObject = require('./convert-to-object');
4-
const removeUnused = require('./remove-unused');
5-
6-
module.exports.rules = {
4+
export const rules = {
75
'convert-to-object': convertToObject,
86
'remove-unused': removeUnused,
97
};

packages/plugin-labels/lib/remove-unused/index.js

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

3-
const {operator, types} = require('putout');
43
const {isReturnStatement} = types;
5-
const {traverse, replaceWith} = operator;
4+
const {replaceWith} = operator;
65

7-
module.exports.report = ({name}) => `Label '${name}' is defined but never used`;
6+
export const report = ({name}) => `Label '${name}' is defined but never used`;
87

9-
module.exports.fix = ({path}) => {
8+
export const fix = ({path}) => {
109
replaceWith(path, path.node.body);
1110
};
1211

13-
module.exports.traverse = ({push}) => ({
12+
export const traverse = ({push}) => ({
1413
LabeledStatement(path) {
1514
const {label} = path.node;
1615
const {name} = label;
@@ -42,7 +41,7 @@ function usedLabel({path, name}) {
4241
currentPath.stop();
4342
};
4443

45-
traverse(path, {
44+
path.traverse({
4645
ContinueStatement: checkLabel,
4746
BreakStatement: checkLabel,
4847
});

packages/plugin-labels/lib/remove-unused/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['remove-unused', plugin],
97
],

packages/plugin-labels/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@putout/plugin-labels",
33
"version": "1.0.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin helps with labels",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-labels#readme",
@@ -34,7 +34,6 @@
3434
"commonjs"
3535
],
3636
"devDependencies": {
37-
"@putout/eslint-flat": "^3.0.0",
3837
"@putout/test": "^13.0.0",
3938
"c8": "^10.0.0",
4039
"eslint": "^9.0.0",
@@ -44,11 +43,11 @@
4443
"nodemon": "^3.0.1"
4544
},
4645
"peerDependencies": {
47-
"putout": ">=37"
46+
"putout": ">=40"
4847
},
4948
"license": "MIT",
5049
"engines": {
51-
"node": ">=18"
50+
"node": ">=20"
5251
},
5352
"publishConfig": {
5453
"access": "public"

packages/plugin-labels/test/labels.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as labels from '../lib/index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const labels = require('..');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['labels', labels],
97
],

0 commit comments

Comments
 (0)