@putout/plugin-tape 14.2.0 → 15.0.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
CHANGED
|
@@ -17,6 +17,44 @@ npm i @putout/plugin-tape -D
|
|
|
17
17
|
|
|
18
18
|
## Rules
|
|
19
19
|
|
|
20
|
+
- ✅ [add-args](#add-args);
|
|
21
|
+
- ✅ [add-await-to-re-import](#add-await-to-re-import);
|
|
22
|
+
- ✅ [add-node-prefix-to-mock-require](#add-node-prefix-to-mock-require);
|
|
23
|
+
- ✅ [add-stop-all](#add-stop-all);
|
|
24
|
+
- ✅ [add-t-end](#add-t-end);
|
|
25
|
+
- ✅ [apply-destructuring](#apply-destructuring);
|
|
26
|
+
- ✅ [apply-stub](#apply-stub);
|
|
27
|
+
- ✅ [apply-with-name](#apply-with-name);
|
|
28
|
+
- ✅ [convert-called-with-args](#convert-called-with-args);
|
|
29
|
+
- ✅ [convert-called-with-no-args-to-called-with](#convert-called-with-no-args-to-called-with);
|
|
30
|
+
- ✅ [convert-called-with-to-called-with-no-args](#convert-called-with-to-called-with-no-args);
|
|
31
|
+
- ✅ [convert-deep-equal-to-equal](#convert-deep-equal-to-equal);
|
|
32
|
+
- ✅ [convert-does-not-throw-to-try-catch](#convert-does-not-throw-to-try-catch);
|
|
33
|
+
- ✅ [convert-emitter-to-promise](#convert-emitter-to-promise);
|
|
34
|
+
- ✅ [convert-equal-to-called-once](#convert-equal-to-called-once);
|
|
35
|
+
- ✅ [convert-equal-to-deep-equal](#convert-equal-to-deep-equal);
|
|
36
|
+
- ✅ [convert-equal-to-not-ok](#convert-equal-to-not-ok);
|
|
37
|
+
- ✅ [convert-equal-to-ok](#convert-equal-to-ok);
|
|
38
|
+
- ✅ [convert-equals-to-equal](#convert-equals-to-equal);
|
|
39
|
+
- ✅ [convert-match-regexp-to-string](#convert-match-regexp-to-string);
|
|
40
|
+
- ✅ [convert-mock-require-to-mock-import](#convert-mock-require-to-mock-import);
|
|
41
|
+
- ✅ [convert-ok-to-called-with](#convert-ok-to-called-with);
|
|
42
|
+
- ✅ [convert-ok-to-match](#convert-ok-to-match);
|
|
43
|
+
- ✅ [convert-tape-to-supertape](#convert-tape-to-supertape);
|
|
44
|
+
- ✅ [convert-throws-to-try-catch](#convert-throws-to-try-catch);
|
|
45
|
+
- ✅ [declare](#declare);
|
|
46
|
+
- ✅ [jest](#jest);
|
|
47
|
+
- ✅ [remove-default-messages](#remove-default-messages);
|
|
48
|
+
- ✅ [remove-only](#remove-only);
|
|
49
|
+
- ✅ [remove-skip](#remove-skip);
|
|
50
|
+
- ✅ [remove-stop-all](# [remove-stop-all);
|
|
51
|
+
- ✅ [remove-useless-not-called-args](#remove-useless-not-called-args);
|
|
52
|
+
- ✅ [remove-useless-t-end](#remove-useless-t-end);
|
|
53
|
+
- ✅ [switch-expected-with-result](#switch-expected-with-result);
|
|
54
|
+
- ✅ [sync-with-name](#sync-with-name);
|
|
55
|
+
|
|
56
|
+
## Config
|
|
57
|
+
|
|
20
58
|
```json
|
|
21
59
|
{
|
|
22
60
|
"rules": {
|
|
@@ -28,6 +66,7 @@ npm i @putout/plugin-tape -D
|
|
|
28
66
|
"tape/add-t-end": "on",
|
|
29
67
|
"tape/add-stop-all": "on",
|
|
30
68
|
"tape/add-await-to-re-import": "on",
|
|
69
|
+
"tape/add-node-prefix-to-mock-require": "on",
|
|
31
70
|
"tape/remove-useless-t-end": "on",
|
|
32
71
|
"tape/sync-with-name": "on",
|
|
33
72
|
"tape/switch-expected-with-result": "on",
|
|
@@ -349,7 +388,7 @@ test('copymitter', (t) => {
|
|
|
349
388
|
### ✅ Example of correct code
|
|
350
389
|
|
|
351
390
|
```js
|
|
352
|
-
const {once} = require('events');
|
|
391
|
+
const {once} = require('node:events');
|
|
353
392
|
|
|
354
393
|
test('copymitter', async (t) => {
|
|
355
394
|
const cp = copymitter(from, to, ['1']);
|
|
@@ -507,6 +546,26 @@ test('xxx', (t) => {
|
|
|
507
546
|
});
|
|
508
547
|
```
|
|
509
548
|
|
|
549
|
+
## add-node-prefix-to-mock-require
|
|
550
|
+
|
|
551
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/38f43d1972b3ebe37597022b42024cd5/ccd8cf8a3ff4a30c6dccc528358f9439f1fd366e).
|
|
552
|
+
|
|
553
|
+
### ❌ Example of incorrect code
|
|
554
|
+
|
|
555
|
+
```js
|
|
556
|
+
mockRequire('fs/promises', {
|
|
557
|
+
readdir,
|
|
558
|
+
});
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### ✅ Example of correct code
|
|
562
|
+
|
|
563
|
+
```js
|
|
564
|
+
mockRequire('node:fs/promises', {
|
|
565
|
+
readdir,
|
|
566
|
+
});
|
|
567
|
+
```
|
|
568
|
+
|
|
510
569
|
## add-args
|
|
511
570
|
|
|
512
571
|
### ❌ Example of incorrect code
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {isBuiltin} = require('node:module');
|
|
4
|
+
const {operator, types} = require('putout');
|
|
5
|
+
|
|
6
|
+
const {isStringLiteral} = types;
|
|
7
|
+
const {
|
|
8
|
+
getTemplateValues,
|
|
9
|
+
setLiteralValue,
|
|
10
|
+
} = operator;
|
|
11
|
+
|
|
12
|
+
module.exports.report = ({__a}) => `Add 'node:' prefix: '${__a.value}' -> 'node:${__a.value}'`;
|
|
13
|
+
|
|
14
|
+
module.exports.fix = ({__a}) => {
|
|
15
|
+
setLiteralValue(__a, `node:${__a.value}`);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const MOCK_REQUIRE = 'mockRequire(__a, __b)';
|
|
19
|
+
|
|
20
|
+
module.exports.traverse = ({push}) => ({
|
|
21
|
+
[MOCK_REQUIRE](path) {
|
|
22
|
+
const {__a} = getTemplateValues(path, MOCK_REQUIRE);
|
|
23
|
+
|
|
24
|
+
if (!isStringLiteral(__a))
|
|
25
|
+
return;
|
|
26
|
+
|
|
27
|
+
if (__a.value.startsWith('node:'))
|
|
28
|
+
return;
|
|
29
|
+
|
|
30
|
+
if (isBuiltin(__a.value))
|
|
31
|
+
push({
|
|
32
|
+
path,
|
|
33
|
+
__a,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -36,7 +36,9 @@ module.exports.replace = () => ({
|
|
|
36
36
|
|
|
37
37
|
function match({__body}) {
|
|
38
38
|
for (const codeLine of __body.body) {
|
|
39
|
-
const {
|
|
39
|
+
const {
|
|
40
|
+
expression = codeLine,
|
|
41
|
+
} = codeLine;
|
|
40
42
|
|
|
41
43
|
if (compare(expression, ON_END))
|
|
42
44
|
return true;
|
|
@@ -64,7 +66,9 @@ function replace({__a}, path) {
|
|
|
64
66
|
for (let i = 0; i < n; i++) {
|
|
65
67
|
let nodes = [];
|
|
66
68
|
const current = body[i];
|
|
67
|
-
const {
|
|
69
|
+
const {
|
|
70
|
+
expression = current,
|
|
71
|
+
} = current;
|
|
68
72
|
|
|
69
73
|
if (compare(expression, ON_ERROR))
|
|
70
74
|
nodes = getErrorNodes(expression);
|
package/lib/index.js
CHANGED
|
@@ -34,6 +34,7 @@ const removeUselessTEnd = require('./remove-useless-t-end');
|
|
|
34
34
|
const removeOnly = require('./remove-only');
|
|
35
35
|
const removeSkip = require('./remove-skip');
|
|
36
36
|
const convertEqualsToEqual = require('./convert-equals-to-equal');
|
|
37
|
+
const addNodePrefixToMockRequire = require('./add-node-prefix-to-mock-require');
|
|
37
38
|
|
|
38
39
|
module.exports.rules = {
|
|
39
40
|
'convert-mock-require-to-mock-import': ['off', convertMockRequireToMockImport],
|
|
@@ -71,4 +72,5 @@ module.exports.rules = {
|
|
|
71
72
|
'remove-useless-t-end': removeUselessTEnd,
|
|
72
73
|
'remove-only': removeOnly,
|
|
73
74
|
'remove-skip': removeSkip,
|
|
75
|
+
'add-node-prefix-to-mock-require': addNodePrefixToMockRequire,
|
|
74
76
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-tape",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin helps with tests",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@putout/plugin-putout": "*",
|
|
35
|
-
"@putout/test": "^
|
|
36
|
-
"c8": "^
|
|
37
|
-
"eslint": "^9.0.0
|
|
38
|
-
"eslint-plugin-n": "^17.0.0
|
|
35
|
+
"@putout/test": "^11.0.0",
|
|
36
|
+
"c8": "^10.0.0",
|
|
37
|
+
"eslint": "^9.0.0",
|
|
38
|
+
"eslint-plugin-n": "^17.0.0",
|
|
39
39
|
"eslint-plugin-putout": "^22.0.0",
|
|
40
40
|
"lerna": "^6.0.1",
|
|
41
41
|
"madrun": "^10.0.0",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"nodemon": "^3.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"putout": ">=
|
|
46
|
+
"putout": ">=36"
|
|
47
47
|
},
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"engines": {
|
|
50
|
-
"node": ">=18"
|
|
50
|
+
"node": ">=18.6"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|