Skip to content

Commit c30003a

Browse files
committed
feature: @putout/plugin-promises: convert to ESM
1 parent f64809a commit c30003a

File tree

28 files changed

+102
-143
lines changed

28 files changed

+102
-143
lines changed
File renamed without changes.

packages/plugin-promises/lib/add-missing-async/index.js

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 = () => `Add missing 'async'`;
22

3-
module.exports.report = () => `Add missing 'async'`;
4-
5-
module.exports.fix = (path) => {
3+
export const fix = (path) => {
64
path.node.async = true;
75
};
86

9-
module.exports.traverse = ({push}) => ({
7+
export const traverse = ({push}) => ({
108
AwaitExpression(path) {
119
const fnPath = path.getFunctionParent();
1210

packages/plugin-promises/lib/add-missing-async/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
['promises/add-missing-async', convert],
97
],

packages/plugin-promises/lib/add-missing-await/index.js

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

3-
const {types} = require('putout');
43
const {
54
isIdentifier,
65
awaitExpression,
76
} = types;
87

9-
module.exports.report = () => `Call async functions using 'await'`;
8+
export const report = () => `Call async functions using 'await'`;
109

11-
module.exports.match = () => ({
10+
export const match = () => ({
1211
'__a(__args)': ({__a}, path) => {
1312
if (!isIdentifier(__a))
1413
return false;
@@ -41,7 +40,7 @@ module.exports.match = () => ({
4140
},
4241
});
4342

44-
module.exports.replace = () => ({
43+
export const replace = () => ({
4544
'__a(__args)': (vars, path) => {
4645
const fnPath = path.getFunctionParent();
4746

packages/plugin-promises/lib/add-missing-await/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
['promises/add-missing-await', convert],
97
],

packages/plugin-promises/lib/apply-await-import/index.js

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

53
const {replaceWith} = operator;
64
const {
75
isFunction,
86
awaitExpression,
97
} = types;
108

11-
module.exports.report = () => `Use 'await' near 'import' call`;
9+
export const report = () => `Use 'await' near 'import' call`;
1210

13-
module.exports.match = () => ({
11+
export const match = () => ({
1412
'import(__a)'(vars, path) {
1513
if (!path.parentPath.isVariableDeclarator())
1614
return false;
@@ -19,7 +17,7 @@ module.exports.match = () => ({
1917
},
2018
});
2119

22-
module.exports.replace = () => ({
20+
export const replace = () => ({
2321
'import(__a)'(vars, path) {
2422
const fnPath = path.findParent(isFunction);
2523

packages/plugin-promises/lib/apply-await-import/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 awaitImport from './index.js';
23

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

packages/plugin-promises/lib/apply-top-level-await/index.js

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

3-
const fullstore = require('fullstore');
4-
const {replaceWithMultiple} = require('putout').operator;
4+
const {replaceWithMultiple} = operator;
55

66
const add = ({push, isImports, isExports}) => (path) => {
77
const calleePath = path.get('callee');
@@ -17,14 +17,14 @@ const add = ({push, isImports, isExports}) => (path) => {
1717
push(path);
1818
};
1919

20-
module.exports.report = () => `Use top level 'await'`;
20+
export const report = () => `Use top level 'await'`;
2121

22-
module.exports.fix = (path) => {
22+
export const fix = (path) => {
2323
const {body} = path.get('callee.body').node;
2424
replaceWithMultiple(path, body);
2525
};
2626

27-
module.exports.traverse = ({push}) => {
27+
export const traverse = ({push}) => {
2828
const isExports = fullstore();
2929
const isImports = fullstore();
3030

packages/plugin-promises/lib/apply-top-level-await/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 applyTopLevelAwait from './index.js';
23

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

0 commit comments

Comments
 (0)