@putout/test 11.1.0 β 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/lib/eslint/eslint.mjs +3 -2
- package/lib/processor/index.js +2 -1
- package/lib/test.js +45 -44
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,17 @@ You can also pass all π**Putout** options:
|
|
|
41
41
|
|
|
42
42
|
```js
|
|
43
43
|
const test = createTest(import.meta.url, {
|
|
44
|
-
|
|
44
|
+
plugins: [
|
|
45
|
+
['remove-unused-variables', rmVars],
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or use another linter with the same signature as π**Putout** using `lint` field:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
const test = createTest(import.meta.url, {
|
|
54
|
+
lint: putout,
|
|
45
55
|
plugins: [
|
|
46
56
|
['remove-unused-variables', rmVars],
|
|
47
57
|
],
|
|
@@ -382,9 +392,7 @@ test('test: eslint: noProcess', async ({noProcess}) => {
|
|
|
382
392
|
test('test: eslint: noProcess', async ({noProcess}) => {
|
|
383
393
|
await noProcess('operator-linebreak-fix', {
|
|
384
394
|
rules: {
|
|
385
|
-
'putout/putout': ['error', {
|
|
386
|
-
printer: 'putout',
|
|
387
|
-
}],
|
|
395
|
+
'putout/putout': ['error', {}],
|
|
388
396
|
},
|
|
389
397
|
});
|
|
390
398
|
});
|
package/lib/eslint/eslint.mjs
CHANGED
|
@@ -77,7 +77,6 @@ export const createTest = (url, plugins = {}) => {
|
|
|
77
77
|
process: (operator) => async (name, override) => {
|
|
78
78
|
const full = join(fixtureDir, name);
|
|
79
79
|
const [resolvedName, code] = await read(full);
|
|
80
|
-
const [fixturePath, fixture] = await read(`${full}-fix`);
|
|
81
80
|
const fix = true;
|
|
82
81
|
|
|
83
82
|
const [source] = await eslint({
|
|
@@ -92,10 +91,12 @@ export const createTest = (url, plugins = {}) => {
|
|
|
92
91
|
});
|
|
93
92
|
|
|
94
93
|
if (isUpdate()) {
|
|
95
|
-
update(
|
|
94
|
+
update(resolvedName, source);
|
|
96
95
|
return operator.pass('fixture updated');
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
const [, fixture] = await read(`${full}-fix`);
|
|
99
|
+
|
|
99
100
|
return operator.equal(source, fixture);
|
|
100
101
|
},
|
|
101
102
|
noProcess: (operator) => async (name, overrides) => {
|
package/lib/processor/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const tryToCatch = require('try-to-catch');
|
|
4
3
|
const {
|
|
5
4
|
readFile,
|
|
6
5
|
writeFile,
|
|
@@ -13,6 +12,8 @@ const {
|
|
|
13
12
|
basename,
|
|
14
13
|
} = require('node:path');
|
|
15
14
|
|
|
15
|
+
const tryToCatch = require('try-to-catch');
|
|
16
|
+
|
|
16
17
|
const test = require('supertape');
|
|
17
18
|
const processFile = require('putout/process-file');
|
|
18
19
|
const {runProcessors} = require('@putout/engine-processor');
|
package/lib/test.js
CHANGED
|
@@ -101,30 +101,31 @@ const parsePlugin = (plugins) => {
|
|
|
101
101
|
function createTest(dir, maybeOptions) {
|
|
102
102
|
dir = join(dir, 'fixture');
|
|
103
103
|
|
|
104
|
-
const options = parseOptions(maybeOptions);
|
|
104
|
+
const {lint = putout, ...options} = parseOptions(maybeOptions);
|
|
105
|
+
|
|
105
106
|
const plugin = parsePlugin(options.plugins);
|
|
106
107
|
|
|
107
108
|
preTest(test, plugin);
|
|
108
109
|
|
|
109
110
|
return test.extend({
|
|
110
|
-
transform: transform(dir, options),
|
|
111
|
-
noTransform: noTransform(dir, options),
|
|
112
|
-
transformCode: transformCode(options),
|
|
113
|
-
noTransformCode: noTransformCode(options),
|
|
111
|
+
transform: transform(dir, lint, options),
|
|
112
|
+
noTransform: noTransform(dir, lint, options),
|
|
113
|
+
transformCode: transformCode(lint, options),
|
|
114
|
+
noTransformCode: noTransformCode(lint, options),
|
|
114
115
|
|
|
115
116
|
progress: progress(dir, options),
|
|
116
117
|
progressWithOptions: progressWithOptions(dir, options),
|
|
117
118
|
|
|
118
|
-
transformWithOptions: transformWithOptions(dir, options),
|
|
119
|
-
noTransformWithOptions: noTransformWithOptions(dir, options),
|
|
119
|
+
transformWithOptions: transformWithOptions(dir, lint, options),
|
|
120
|
+
noTransformWithOptions: noTransformWithOptions(dir, lint, options),
|
|
120
121
|
|
|
121
|
-
report: report(dir, options),
|
|
122
|
-
noReport: noReport(dir, options),
|
|
123
|
-
noReportAfterTransform: noReportAfterTransform(dir, options),
|
|
124
|
-
noReportAfterTransformWithOptions: noReportAfterTransformWithOptions(dir, options),
|
|
125
|
-
reportWithOptions: reportWithOptions(dir, options),
|
|
126
|
-
noReportWithOptions: noReportWithOptions(dir, options),
|
|
127
|
-
reportCode: reportCode(options),
|
|
122
|
+
report: report(dir, lint, options),
|
|
123
|
+
noReport: noReport(dir, lint, options),
|
|
124
|
+
noReportAfterTransform: noReportAfterTransform(dir, lint, options),
|
|
125
|
+
noReportAfterTransformWithOptions: noReportAfterTransformWithOptions(dir, lint, options),
|
|
126
|
+
reportWithOptions: reportWithOptions(dir, lint, options),
|
|
127
|
+
noReportWithOptions: noReportWithOptions(dir, lint, options),
|
|
128
|
+
reportCode: reportCode(lint, options),
|
|
128
129
|
format: formatSave(dir, options),
|
|
129
130
|
formatMany: formatManySave(dir, options),
|
|
130
131
|
noFormat: noFormat(dir, options),
|
|
@@ -324,7 +325,7 @@ const progressWithOptions = (dir, options) => (t) => async (name, pluginOptions,
|
|
|
324
325
|
return t.deepEqual(result, expected);
|
|
325
326
|
};
|
|
326
327
|
|
|
327
|
-
const transform = currify((dir, options, t, name, transformed = null, addons = {}) => {
|
|
328
|
+
const transform = currify((dir, lint, options, t, name, transformed = null, addons = {}) => {
|
|
328
329
|
const {plugins} = options;
|
|
329
330
|
const full = join(dir, name);
|
|
330
331
|
const isStr = isString(transformed);
|
|
@@ -336,7 +337,7 @@ const transform = currify((dir, options, t, name, transformed = null, addons = {
|
|
|
336
337
|
|
|
337
338
|
addons = addons || {};
|
|
338
339
|
|
|
339
|
-
const {code} =
|
|
340
|
+
const {code} = lint(input, {
|
|
340
341
|
isTS,
|
|
341
342
|
...options,
|
|
342
343
|
plugins: [{
|
|
@@ -362,7 +363,7 @@ const transform = currify((dir, options, t, name, transformed = null, addons = {
|
|
|
362
363
|
return t.equal(code, output);
|
|
363
364
|
});
|
|
364
365
|
|
|
365
|
-
const transformWithOptions = currify((dir, options, t, name, pluginOptions) => {
|
|
366
|
+
const transformWithOptions = currify((dir, lint, options, t, name, pluginOptions) => {
|
|
366
367
|
const {writeFileSync} = global.__putout_test_fs;
|
|
367
368
|
const full = join(dir, name);
|
|
368
369
|
const [input, isTS] = readFixture(full);
|
|
@@ -373,7 +374,7 @@ const transformWithOptions = currify((dir, options, t, name, pluginOptions) => {
|
|
|
373
374
|
[rule]: ['on', pluginOptions],
|
|
374
375
|
};
|
|
375
376
|
|
|
376
|
-
const {code} =
|
|
377
|
+
const {code} = lint(input, {
|
|
377
378
|
isTS,
|
|
378
379
|
rules,
|
|
379
380
|
...options,
|
|
@@ -395,7 +396,7 @@ const parseRule = ({plugins}) => {
|
|
|
395
396
|
return plugin[0] || keys(plugin)[0];
|
|
396
397
|
};
|
|
397
398
|
|
|
398
|
-
const noTransformWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
399
|
+
const noTransformWithOptions = currify((dir, lint, options, t, name, ruleOptions) => {
|
|
399
400
|
const full = join(dir, name);
|
|
400
401
|
const [input, isTS] = readFixture(full);
|
|
401
402
|
|
|
@@ -406,7 +407,7 @@ const noTransformWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
|
406
407
|
[rule]: ['on', ruleOptions],
|
|
407
408
|
};
|
|
408
409
|
|
|
409
|
-
const {code} =
|
|
410
|
+
const {code} = lint(input, {
|
|
410
411
|
isTS,
|
|
411
412
|
rules,
|
|
412
413
|
...options,
|
|
@@ -425,7 +426,7 @@ const noTransformWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
|
425
426
|
return t.equal(code, input);
|
|
426
427
|
});
|
|
427
428
|
|
|
428
|
-
const noTransform = currify((dir, options, t, name, addons = {}) => {
|
|
429
|
+
const noTransform = currify((dir, lint, options, t, name, addons = {}) => {
|
|
429
430
|
const full = join(dir, name);
|
|
430
431
|
const [fixture] = readFixture(full);
|
|
431
432
|
|
|
@@ -434,7 +435,7 @@ const noTransform = currify((dir, options, t, name, addons = {}) => {
|
|
|
434
435
|
const {plugins} = options;
|
|
435
436
|
const [input, isTS] = readFixture(full);
|
|
436
437
|
|
|
437
|
-
const {code} =
|
|
438
|
+
const {code} = lint(input, {
|
|
438
439
|
isTS,
|
|
439
440
|
...options,
|
|
440
441
|
plugins: [{
|
|
@@ -456,8 +457,8 @@ const noTransform = currify((dir, options, t, name, addons = {}) => {
|
|
|
456
457
|
return t.equal(code, fixture);
|
|
457
458
|
});
|
|
458
459
|
|
|
459
|
-
const transformCode = currify((options, t, input, output, isTS = false) => {
|
|
460
|
-
const {code} =
|
|
460
|
+
const transformCode = currify((lint, options, t, input, output, isTS = false) => {
|
|
461
|
+
const {code} = lint(input, {
|
|
461
462
|
isTS,
|
|
462
463
|
...options,
|
|
463
464
|
});
|
|
@@ -465,32 +466,32 @@ const transformCode = currify((options, t, input, output, isTS = false) => {
|
|
|
465
466
|
return t.equal(code, output);
|
|
466
467
|
});
|
|
467
468
|
|
|
468
|
-
const noTransformCode = currify((options, t, input) => {
|
|
469
|
-
const {code} =
|
|
469
|
+
const noTransformCode = currify((lint, options, t, input) => {
|
|
470
|
+
const {code} = lint(input, options);
|
|
470
471
|
return t.equal(code, input);
|
|
471
472
|
});
|
|
472
473
|
|
|
473
474
|
const getMessage = ({message}) => message;
|
|
474
475
|
|
|
475
|
-
const report = (dir, options) => (t) => (name, message) => {
|
|
476
|
+
const report = (dir, lint, options) => (t) => (name, message) => {
|
|
476
477
|
checkReport(name, message);
|
|
477
478
|
|
|
478
479
|
const full = join(dir, name);
|
|
479
480
|
const [source, isTS] = readFixture(full);
|
|
480
481
|
|
|
481
|
-
return reportCode({
|
|
482
|
+
return reportCode(lint, {
|
|
482
483
|
isTS,
|
|
483
484
|
...options,
|
|
484
485
|
}, t, source, message);
|
|
485
486
|
};
|
|
486
487
|
|
|
487
|
-
const noReport = currify((dir, options, t, name) => {
|
|
488
|
+
const noReport = currify((dir, lint, options, t, name) => {
|
|
488
489
|
const full = join(dir, name);
|
|
489
490
|
const [source, isTS] = readFixture(full);
|
|
490
491
|
|
|
491
492
|
rmFixture(`${full}-fix`);
|
|
492
493
|
|
|
493
|
-
return noReportCode({
|
|
494
|
+
return noReportCode(lint, {
|
|
494
495
|
isTS,
|
|
495
496
|
...options,
|
|
496
497
|
}, t, source);
|
|
@@ -498,11 +499,11 @@ const noReport = currify((dir, options, t, name) => {
|
|
|
498
499
|
|
|
499
500
|
module.exports._createNoReport = noReport;
|
|
500
501
|
|
|
501
|
-
const noReportAfterTransform = currify((dir, options, t, name, addons = {}) => {
|
|
502
|
+
const noReportAfterTransform = currify((dir, lint, options, t, name, addons = {}) => {
|
|
502
503
|
const full = join(dir, name);
|
|
503
504
|
const [source, isTS] = readFixture(full);
|
|
504
505
|
|
|
505
|
-
return noReportCodeAfterTransform({
|
|
506
|
+
return noReportCodeAfterTransform(lint, {
|
|
506
507
|
isTS,
|
|
507
508
|
...options,
|
|
508
509
|
}, t, source, addons);
|
|
@@ -510,7 +511,7 @@ const noReportAfterTransform = currify((dir, options, t, name, addons = {}) => {
|
|
|
510
511
|
|
|
511
512
|
module.exports._createNoReportAfterTransform = noReportAfterTransform;
|
|
512
513
|
|
|
513
|
-
const noReportAfterTransformWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
514
|
+
const noReportAfterTransformWithOptions = currify((dir, lint, options, t, name, ruleOptions) => {
|
|
514
515
|
const full = join(dir, name);
|
|
515
516
|
const [source, isTS] = readFixture(full);
|
|
516
517
|
const rule = parseRule(options);
|
|
@@ -519,7 +520,7 @@ const noReportAfterTransformWithOptions = currify((dir, options, t, name, ruleOp
|
|
|
519
520
|
[rule]: ['on', ruleOptions],
|
|
520
521
|
};
|
|
521
522
|
|
|
522
|
-
return noReportCodeAfterTransform({
|
|
523
|
+
return noReportCodeAfterTransform(lint, {
|
|
523
524
|
isTS,
|
|
524
525
|
...options,
|
|
525
526
|
rules: {
|
|
@@ -531,7 +532,7 @@ const noReportAfterTransformWithOptions = currify((dir, options, t, name, ruleOp
|
|
|
531
532
|
|
|
532
533
|
module.exports._createNoReportAfterTransformWithOptions = noReportAfterTransformWithOptions;
|
|
533
534
|
|
|
534
|
-
const reportWithOptions = currify((dir, options, t, name, message, ruleOptions) => {
|
|
535
|
+
const reportWithOptions = currify((dir, lint, options, t, name, message, ruleOptions) => {
|
|
535
536
|
const full = join(dir, name);
|
|
536
537
|
const [source, isTS] = readFixture(full);
|
|
537
538
|
|
|
@@ -541,14 +542,14 @@ const reportWithOptions = currify((dir, options, t, name, message, ruleOptions)
|
|
|
541
542
|
[rule]: ['on', ruleOptions],
|
|
542
543
|
};
|
|
543
544
|
|
|
544
|
-
return reportCode({
|
|
545
|
+
return reportCode(lint, {
|
|
545
546
|
...options,
|
|
546
547
|
rules,
|
|
547
548
|
isTS,
|
|
548
549
|
}, t, source, message);
|
|
549
550
|
});
|
|
550
551
|
|
|
551
|
-
const noReportWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
552
|
+
const noReportWithOptions = currify((dir, lint, options, t, name, ruleOptions) => {
|
|
552
553
|
const full = join(dir, name);
|
|
553
554
|
const [source, isTS] = readFixture(full);
|
|
554
555
|
|
|
@@ -559,15 +560,15 @@ const noReportWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
|
559
560
|
[rule]: ['on', ruleOptions],
|
|
560
561
|
};
|
|
561
562
|
|
|
562
|
-
return noReportCode({
|
|
563
|
+
return noReportCode(lint, {
|
|
563
564
|
isTS,
|
|
564
565
|
...options,
|
|
565
566
|
rules,
|
|
566
567
|
}, t, source);
|
|
567
568
|
});
|
|
568
569
|
|
|
569
|
-
const reportCode = currify((options, t, source, message) => {
|
|
570
|
-
const {places} =
|
|
570
|
+
const reportCode = currify((lint, options, t, source, message) => {
|
|
571
|
+
const {places} = lint(source, {
|
|
571
572
|
fix: false,
|
|
572
573
|
...options,
|
|
573
574
|
});
|
|
@@ -580,8 +581,8 @@ const reportCode = currify((options, t, source, message) => {
|
|
|
580
581
|
return t.equal(resultMessages[0], message);
|
|
581
582
|
});
|
|
582
583
|
|
|
583
|
-
const noReportCode = currify((options, t, source) => {
|
|
584
|
-
const {places} =
|
|
584
|
+
const noReportCode = currify((lint, options, t, source) => {
|
|
585
|
+
const {places} = lint(source, {
|
|
585
586
|
fix: false,
|
|
586
587
|
...options,
|
|
587
588
|
});
|
|
@@ -589,9 +590,9 @@ const noReportCode = currify((options, t, source) => {
|
|
|
589
590
|
return t.deepEqual(places, [], 'should not report');
|
|
590
591
|
});
|
|
591
592
|
|
|
592
|
-
const noReportCodeAfterTransform = currify((options, t, source, addons = {}) => {
|
|
593
|
+
const noReportCodeAfterTransform = currify((lint, options, t, source, addons = {}) => {
|
|
593
594
|
const {plugins} = options;
|
|
594
|
-
const {places} =
|
|
595
|
+
const {places} = lint(source, {
|
|
595
596
|
fix: true,
|
|
596
597
|
...options,
|
|
597
598
|
plugins: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/test",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Test runner for πPutout plugins ",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@putout/formatter-dump": "*",
|
|
61
61
|
"@putout/formatter-progress": "*",
|
|
62
|
+
"@putout/plugin-esm": "*",
|
|
62
63
|
"@putout/plugin-extract-object-properties": "*",
|
|
63
64
|
"@putout/plugin-putout": "*",
|
|
64
65
|
"@putout/plugin-remove-console": "*",
|
|
65
|
-
"@putout/plugin-remove-empty": "*",
|
|
66
66
|
"@putout/plugin-remove-unused-variables": "*",
|
|
67
67
|
"c8": "^10.0.0",
|
|
68
68
|
"eslint": "^9.0.0",
|