Skip to content

Commit ea21d12

Browse files
committed
feature: @putout/plugin-madrun: drop support of node < 20
1 parent 9a53137 commit ea21d12

File tree

49 files changed

+186
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+186
-268
lines changed
File renamed without changes.

packages/plugin-madrun/lib/add-cut-env/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
'use strict';
1+
import {operator} from 'putout';
22

3-
const {operator} = require('putout');
43
const {
54
getExportDefault,
65
getProperty,
76
} = operator;
87

9-
module.exports.report = () => `Call 'await cutEnv(script)' instead of 'script'`;
8+
export const report = () => `Call 'await cutEnv(script)' instead of 'script'`;
109

11-
module.exports.replace = () => ({
10+
export const replace = () => ({
1211
'[__a, __b]': '[__a, cutEnv(__b)]',
1312
});
1413

15-
module.exports.match = () => ({
14+
export const match = () => ({
1615
'[__a, __b]': ({__b}, path) => {
1716
const exportDefault = getExportDefault(path);
1817

packages/plugin-madrun/lib/add-cut-env/index.spec.js

+3-5
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
['madrun/add-cut-env', convert],
97
],

packages/plugin-madrun/lib/add-fix-lint/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
2-
3-
const {
1+
import {
42
types,
53
operator,
64
template,
7-
} = require('putout');
5+
} from 'putout';
86

97
const {stringLiteral, objectProperty} = types;
108
const {
@@ -16,13 +14,13 @@ const fixLintScript = template.ast(`
1614
() => run('lint', '--fix')
1715
`);
1816

19-
module.exports.report = () => `fix:lint should exist`;
17+
export const report = () => `fix:lint should exist`;
2018

21-
module.exports.fix = (path) => {
19+
export const fix = (path) => {
2220
replaceWithMultiple(path, [path.node, objectProperty(stringLiteral('fix:lint'), fixLintScript)]);
2321
};
2422

25-
module.exports.traverse = ({push}) => ({
23+
export const traverse = ({push}) => ({
2624
'module.exports = __object'(path) {
2725
const rightPath = path.get('right');
2826
const lint = getProperty(rightPath, 'lint');

packages/plugin-madrun/lib/add-fix-lint/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as addFixLint from './index.js';
23

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

packages/plugin-madrun/lib/add-function/index.js

+4-6
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 {replaceWith, extract} = operator;
64
const {
@@ -9,13 +7,13 @@ const {
97
arrowFunctionExpression,
108
} = types;
119

12-
module.exports.report = ({name}) => `Use 'function' instead of 'string' in script: '${name}'`;
10+
export const report = ({name}) => `Use 'function' instead of 'string' in script: '${name}'`;
1311

14-
module.exports.fix = ({path}) => {
12+
export const fix = ({path}) => {
1513
replaceWith(path, arrowFunctionExpression([], path.node));
1614
};
1715

18-
module.exports.traverse = ({push}) => ({
16+
export const traverse = ({push}) => ({
1917
'export default __object'(path) {
2018
const properties = path.get('declaration.properties');
2119

packages/plugin-madrun/lib/add-function/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as addFunction from './index.js';
23

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

packages/plugin-madrun/lib/add-missing-quotes-to-watcher/index.js

+4-5
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
isCallExpression,
65
isTemplateLiteral,
76
} = types;
87

9-
module.exports.report = () => `Add missing quotes to watcher`;
8+
export const report = () => `Add missing quotes to watcher`;
109

11-
module.exports.match = () => ({
10+
export const match = () => ({
1211
'await run("test")': (vars, {parentPath}) => {
1312
if (isTemplateLiteral(parentPath)) {
1413
const {quasis} = parentPath.node;
@@ -27,7 +26,7 @@ module.exports.match = () => ({
2726
},
2827
});
2928

30-
module.exports.replace = () => ({
29+
export const replace = () => ({
3130
'await run("test")': (vars, path) => {
3231
const {parentPath} = path;
3332

packages/plugin-madrun/lib/add-missing-quotes-to-watcher/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

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

packages/plugin-madrun/lib/add-run/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
'use strict';
2-
3-
const {
1+
import {
42
operator,
53
template,
64
types,
7-
} = require('putout');
5+
} from 'putout';
86

97
const {isProgram} = types;
108
const {findBinding} = operator;
119

1210
const node = template.ast(`const {run} = require('madrun')`);
1311

14-
module.exports.report = () => 'run should be declared';
12+
export const report = () => 'run should be declared';
1513

16-
module.exports.fix = (path) => {
14+
export const fix = (path) => {
1715
path.node.body.unshift(node);
1816
};
1917

20-
module.exports.traverse = ({push}) => {
18+
export const traverse = ({push}) => {
2119
let added = false;
2220

2321
return {

packages/plugin-madrun/lib/add-run/index.spec.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as strictMode from '@putout/plugin-nodejs/strict-mode';
3+
import * as removeUnusedExpressions from '@putout/plugin-remove-unused-expressions';
4+
import * as addRun from './index.js';
25

3-
const {createTest} = require('@putout/test');
4-
5-
const strictMode = require('@putout/plugin-nodejs/strict-mode');
6-
const removeUnusedExpressions = require('@putout/plugin-remove-unused-expressions');
7-
const addRun = require('.');
8-
9-
const test = createTest(__dirname, {
6+
const test = createTest(import.meta.url, {
107
plugins: [
118
['add-run', addRun],
129
],

packages/plugin-madrun/lib/call-run/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
'use strict';
1+
import {types} from 'putout';
22

33
const {
44
isStringLiteral,
55
stringLiteral,
66
identifier,
77
callExpression,
88
arrayExpression,
9-
} = require('putout').types;
9+
} = types;
1010

11-
module.exports.report = ({name}) => {
11+
export const report = ({name}) => {
1212
return `"run" should be called in script: "${name}"`;
1313
};
1414

15-
module.exports.traverse = ({push}) => ({
15+
export const traverse = ({push}) => ({
1616
ArrowFunctionExpression(path) {
1717
const {body} = path.node;
1818

@@ -32,7 +32,7 @@ module.exports.traverse = ({push}) => ({
3232
},
3333
});
3434

35-
module.exports.fix = ({path, value}) => {
35+
export const fix = ({path, value}) => {
3636
const [line, arg] = value.split(' -- ');
3737
const scripts = getScripts(line);
3838

packages/plugin-madrun/lib/call-run/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as callRun from './index.js';
23

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

packages/plugin-madrun/lib/convert-args-to-scripts/index.js

+4-6
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
isObjectExpression,
@@ -9,9 +7,9 @@ const {
97

108
const {extract} = operator;
119

12-
module.exports.report = () => `Pass an array when you want to run a list of scripts`;
10+
export const report = () => `Pass an array when you want to run a list of scripts`;
1311

14-
module.exports.match = () => ({
12+
export const match = () => ({
1513
'run(__args)': ({__args}, path) => {
1614
const [, ...names] = __args;
1715

@@ -25,7 +23,7 @@ module.exports.match = () => ({
2523
},
2624
});
2725

28-
module.exports.replace = () => ({
26+
export const replace = () => ({
2927
'run(__args)': 'run([__args])',
3028
});
3129

packages/plugin-madrun/lib/convert-args-to-scripts/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

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

packages/plugin-madrun/lib/convert-cut-env-to-run/index.js

+4-6
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 {isArrayExpression} = types;
64

@@ -9,13 +7,13 @@ const {
97
getProperty,
108
} = operator;
119

12-
module.exports.report = () => `Use 'cutEnv()' instead of 'run()'`;
10+
export const report = () => `Use 'cutEnv()' instead of 'run()'`;
1311

14-
module.exports.replace = () => ({
12+
export const replace = () => ({
1513
'cutEnv(__a)': 'run(__a)',
1614
});
1715

18-
module.exports.match = () => ({
16+
export const match = () => ({
1917
'cutEnv(__a)': ({__a}, path) => {
2018
const exportDefault = getExportDefault(path);
2119

packages/plugin-madrun/lib/convert-cut-env-to-run/index.spec.js

+3-5
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
['madrun/convert-cut-env-to-run', convert],
97
],

packages/plugin-madrun/lib/convert-lint-lib/index.js

+4-6
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
replaceWith,
@@ -10,9 +8,9 @@ const {
108

119
const {stringLiteral} = types;
1210

13-
module.exports.report = () => `'lint' should be used instead of 'lint:lib'`;
11+
export const report = () => `'lint' should be used instead of 'lint:lib'`;
1412

15-
module.exports.fix = ({lintLib, fixLint, lint}) => {
13+
export const fix = ({lintLib, fixLint, lint}) => {
1614
replaceWith(lintLib.get('key'), lint.node.key);
1715
remove(lint);
1816

@@ -21,7 +19,7 @@ module.exports.fix = ({lintLib, fixLint, lint}) => {
2119
body.arguments[0] = stringLiteral('lint');
2220
};
2321

24-
module.exports.traverse = ({push}) => ({
22+
export const traverse = ({push}) => ({
2523
'module.exports = __object'(path) {
2624
const rightPath = path.get('right');
2725

packages/plugin-madrun/lib/convert-lint-lib/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertLintLib from './index.js';
23

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

packages/plugin-madrun/lib/convert-nyc-to-c8/index.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
'use strict';
2-
3-
const {template, operator} = require('putout');
1+
import {template, operator} from 'putout';
42

53
const {replaceWith, getProperty} = operator;
64

7-
module.exports.report = () => {
5+
export const report = () => {
86
return `Use 'c8' instead of 'nyc' to get code coverage`;
97
};
108

11-
module.exports.fix = ({path, line}) => {
9+
export const fix = ({path, line}) => {
1210
const c8 = line.replace('nyc', 'c8');
1311
replaceWith(path, template.ast(c8));
1412
};
1513

16-
module.exports.traverse = ({push}) => ({
14+
export const traverse = ({push}) => ({
1715
'module.exports = __object': addAll('right', push),
1816
'export default __object': addAll('declaration', push),
1917
});

0 commit comments

Comments
 (0)