Skip to content

Commit c337326

Browse files
committed
feature: @putout/plugin-apply-destructuring: convert to ESM
1 parent 5e999b3 commit c337326

File tree

11 files changed

+29
-45
lines changed

11 files changed

+29
-45
lines changed
File renamed without changes.
File renamed without changes.

packages/plugin-apply-destructuring/lib/array/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
'use strict';
1+
export const report = () => `Use array destructuring`;
22

3-
module.exports.report = () => `Use array destructuring`;
4-
5-
module.exports.exclude = () => [
3+
export const exclude = () => [
64
'const __object = __[0]',
75
'const __array = __[0]',
86
'({__} = __[0])',
97
'[__] = __[0]',
108
'__a[0] = __b[0]',
119
];
1210

13-
module.exports.replace = () => ({
11+
export const replace = () => ({
1412
'__a = __b[0]': '[__a] = __b',
1513
'__a = __b[1]': '[, __a] = __b',
1614
'const __a = __b[0]': convertTo('const [__a] = __b'),

packages/plugin-apply-destructuring/lib/array/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 applyDestructuring from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const applyDestructuring = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['apply-array-destructuring', applyDestructuring],
97
],
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
'use strict';
2-
31
const FIRST_PROPERTY = 'declarations.0.id.properties.0';
42

5-
module.exports.report = (path) => {
3+
export const report = (path) => {
64
const {name} = path.get(`${FIRST_PROPERTY}.key`).node;
75
return `Use destructuring instead of setting '${name}' to 'undefined'`;
86
};
97

10-
module.exports.match = () => ({
8+
export const match = () => ({
119
'const {__a} = {__b}': (vars, path) => {
1210
const prop = path.get(FIRST_PROPERTY);
1311
return !prop.node.computed;
1412
},
1513
});
1614

17-
module.exports.replace = () => ({
15+
export const replace = () => ({
1816
'const {__a} = {__b}': 'const {__a} = __b',
1917
});

packages/plugin-apply-destructuring/lib/falsy/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 falsy from './index.js';
23

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

packages/plugin-apply-destructuring/lib/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
1+
import * as object from './object/index.js';
2+
import * as array from './array/index.js';
3+
import * as falsy from './falsy/index.js';
24

3-
const object = require('./object');
4-
const array = require('./array');
5-
const falsy = require('./falsy');
6-
7-
module.exports.rules = {
5+
export const rules = {
86
object,
97
array,
108
falsy,

packages/plugin-apply-destructuring/lib/object/index.js

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

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

6-
module.exports.report = () => 'Use object destructuring';
5+
export const report = () => 'Use object destructuring';
76

8-
module.exports.match = () => ({
7+
export const match = () => ({
98
'__a = __b.__a': (vars, {parentPath}) => isExpressionStatement(parentPath),
109
});
1110

12-
module.exports.replace = () => ({
11+
export const replace = () => ({
1312
'const __a = __b.__a': 'const {__a} = __b',
1413
'let __a = __b.__a': 'let {__a} = __b',
1514
'__a = __b.__a': '({__a} = __b)',

packages/plugin-apply-destructuring/lib/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 applyObjectDestructuring from './index.js';
23

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

packages/plugin-apply-destructuring/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-apply-destructuring",
33
"version": "8.0.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin adds ability use destructuring on variable declarations",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-apply-destructuring#readme",
@@ -31,7 +31,6 @@
3131
"destructuring"
3232
],
3333
"devDependencies": {
34-
"@putout/eslint-flat": "^3.0.0",
3534
"@putout/test": "^13.0.0",
3635
"c8": "^10.0.0",
3736
"eslint": "^9.0.0",
@@ -41,11 +40,11 @@
4140
"nodemon": "^3.0.1"
4241
},
4342
"peerDependencies": {
44-
"putout": ">=38"
43+
"putout": ">=39"
4544
},
4645
"license": "MIT",
4746
"engines": {
48-
"node": ">=18"
47+
"node": ">=20"
4948
},
5049
"publishConfig": {
5150
"access": "public"

0 commit comments

Comments
 (0)