Skip to content

Commit f177cad

Browse files
committed
feature: @putout/plugin-convert-array-copy-to-slice: migrate to ESM
1 parent c537624 commit f177cad

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

packages/plugin-convert-array-copy-to-slice/lib/convert-array-copy-to-slice.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
const {types, operator} = require('putout');
1+
import {types, operator} from 'putout';
42

53
const {
64
isIdentifier,
@@ -9,15 +7,15 @@ const {
97

108
const {compare} = operator;
119

12-
module.exports.report = () => `Copy array with '.slice()'`;
10+
export const report = () => `Copy array with '.slice()'`;
1311

14-
module.exports.exclude = () => [
12+
export const exclude = () => [
1513
'[...new Set(__a)]',
1614
'new Set([...__a])',
1715
'[...(__a ? __b : __c)]',
1816
];
1917

20-
module.exports.match = () => ({
18+
export const match = () => ({
2119
'[...__a]': ({__a}, path) => {
2220
if (isCallExpression(__a))
2321
return false;
@@ -36,7 +34,7 @@ module.exports.match = () => ({
3634
},
3735
});
3836

39-
module.exports.replace = () => ({
37+
export const replace = () => ({
4038
'[...__a]': '__a.slice()',
4139
'__a.map((a) => a)': '__a.slice()',
4240
});

packages/plugin-convert-array-copy-to-slice/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-convert-array-copy-to-slice",
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 convert array copy to slice",
77
"homepage": "http://github.com/coderaiser/putout/tree/master/packages/plugin-convert-array-copy-to-slice#readme",

packages/plugin-convert-array-copy-to-slice/test/convert-array-copy-to-slice.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 convertArrayCopyToSlice from '../lib/convert-array-copy-to-slice.js';
23

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

0 commit comments

Comments
 (0)