Skip to content

Commit b4cacc8

Browse files
committed
feature: @putout/plugin-remove-useless-functions: migrate to ESM
1 parent 431c0ca commit b4cacc8

5 files changed

Lines changed: 16 additions & 19 deletions

File tree

File renamed without changes.

packages/plugin-remove-useless-functions/eslint.config.mjs renamed to packages/plugin-remove-useless-functions/eslint.config.js

File renamed without changes.

packages/plugin-remove-useless-functions/lib/remove-useless-functions.js

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

3-
const {types} = require('putout');
43
const {isIdentifier} = types;
54

6-
module.exports.report = () => 'Avoid useless functions';
7-
8-
module.exports.exclude = () => [
9-
'(__args__a) => __a.__b(__args__a)',
10-
'(__args__a) => {__a.__b(__args__a)}',
11-
];
12-
135
const NAMES = [
146
'filter',
157
'find',
@@ -18,7 +10,14 @@ const NAMES = [
1810
'every',
1911
];
2012

21-
module.exports.match = () => ({
13+
export const report = () => 'Avoid useless functions';
14+
15+
export const exclude = () => [
16+
'(__args__a) => __a.__b(__args__a)',
17+
'(__args__a) => {__a.__b(__args__a)}',
18+
];
19+
20+
export const match = () => ({
2221
'(__a) => __a': (vars, path) => {
2322
const {parentPath} = path;
2423

@@ -44,7 +43,7 @@ module.exports.match = () => ({
4443
},
4544
});
4645

47-
module.exports.replace = () => ({
46+
export const replace = () => ({
4847
'(__a) => Boolean(__a)': 'Boolean',
4948
'(__a) => __a': 'Boolean',
5049
'(__a) => __a !== undefined': 'Boolean',

packages/plugin-remove-useless-functions/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@putout/plugin-remove-useless-functions",
33
"version": "4.0.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin adds ability to find and remove useless functions",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-useless-functions#readme",
@@ -44,11 +44,11 @@
4444
"nodemon": "^3.0.1"
4545
},
4646
"peerDependencies": {
47-
"putout": ">=37"
47+
"putout": ">=40"
4848
},
4949
"license": "MIT",
5050
"engines": {
51-
"node": ">=18"
51+
"node": ">=20"
5252
},
5353
"publishConfig": {
5454
"access": "public"

packages/plugin-remove-useless-functions/test/remove-useless-functions.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 removeUselessFunctions from '../lib/remove-useless-functions.js';
23

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

0 commit comments

Comments
 (0)