Skip to content

Commit 904b69b

Browse files
committed
feature: @putout/plugin-maybe: migrate to ESM
1 parent 3d6fcb0 commit 904b69b

File tree

15 files changed

+42
-66
lines changed

15 files changed

+42
-66
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
1+
export const report = () => `Use 'maybeArray()'`;
22

3-
module.exports.report = () => `Use 'maybeArray()'`;
3+
export const filter = ({parentPath}) => !parentPath.isFunction();
44

5-
module.exports.filter = ({parentPath}) => !parentPath.isFunction();
6-
7-
module.exports.replace = () => ({
5+
export const replace = () => ({
86
'isArray(__a) ? __a : [__a]': 'maybeArray(__a)',
97
'Array.isArray(__a) ? __a : [__a]': 'maybeArray(__a)',
108
});

packages/plugin-maybe/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 convert from './index.js';
23

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

packages/plugin-maybe/lib/declare/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports.declare = () => ({
1+
export const declare = () => ({
42
maybeArray: 'const maybeArray = (a) => isArray(a) ? a : [a]',
53
maybeEmptyArray: 'const maybeEmptyArray = (a) => !a ? [] : a',
64
maybeFn: 'const maybeFn = (a) => isFn(a) ? a : noop',

packages/plugin-maybe/lib/declare/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 declare from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const declare = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['maybe/declare', declare],
97
],
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
export const report = () => `Use 'maybeEmptyArray()'`;
22

3-
module.exports.report = () => `Use 'maybeEmptyArray()'`;
3+
export const filter = ({parentPath}) => !parentPath.isFunction();
44

5-
module.exports.filter = ({parentPath}) => !parentPath.isFunction();
6-
7-
module.exports.replace = () => ({
5+
export const replace = () => ({
86
'!__a ? [] :__a': 'maybeEmptyArray(__a)',
97
});

packages/plugin-maybe/lib/empty-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 convert from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convert = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['maybe/apply-async-formatter', convert],
97
],
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
'use strict';
1+
export const report = () => `Use 'maybeFn()'`;
22

3-
module.exports.report = () => `Use 'maybeFn()'`;
4-
5-
module.exports.exclude = () => [
3+
export const exclude = () => [
64
'const maybeFn = isFn(__a) ? __a : noop',
75
'const maybeFn = __',
86
];
97

10-
module.exports.replace = () => ({
8+
export const replace = () => ({
119
'isFn(__a) ? __a : noop': 'maybeFn(__a)',
1210
});

packages/plugin-maybe/lib/fn/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 convert from './index.js';
23

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

0 commit comments

Comments
 (0)