@putout/plugin-tape 21.0.0 → 21.2.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
@@ -79,8 +79,12 @@ npm i @putout/plugin-tape -D
79
79
  "tape/declare": "on",
80
80
  "tape/remove-default-messages": "on",
81
81
  "tape/remove-useless-not-called-args": "on",
82
- "tape/remove-only": "on",
83
- "tape/remove-skip": "on"
82
+ "tape/remove-only": ["on", {
83
+ "allowed": ["test"]
84
+ }],
85
+ "tape/remove-skip": ["on", {
86
+ "allowed": ["test"]
87
+ }]
84
88
  }
85
89
  }
86
90
  ```
@@ -5,6 +5,7 @@ import {
5
5
  } from 'putout';
6
6
 
7
7
  const {compare, compareAny} = operator;
8
+
8
9
  const {
9
10
  expressionStatement,
10
11
  isCallExpression,
@@ -6,7 +6,7 @@ const isBool = (a) => typeof a === 'boolean';
6
6
  const isNumber = (a) => typeof a === 'number';
7
7
  const isString = (a) => typeof a === 'string';
8
8
  const isPrimitive = (a) => isString(a) || isNumber(a) || isBool(a) || isNull(a) || isUndefined(a);
9
- const {compute} = operator;
9
+ const {compute, compare} = operator;
10
10
 
11
11
  const {
12
12
  isLiteral,
@@ -68,5 +68,8 @@ function checkExpected(path) {
68
68
 
69
69
  const initPath = binding.path.get('init');
70
70
 
71
- return initPath.isTaggedTemplateExpression();
71
+ if (initPath.isTaggedTemplateExpression())
72
+ return true;
73
+
74
+ return compare(initPath, '__array.join(__b)');
72
75
  }
@@ -64,6 +64,7 @@ function doReplace({__a}, path) {
64
64
  for (let i = 0; i < n; i++) {
65
65
  let nodes = [];
66
66
  const current = body[i];
67
+
67
68
  const {
68
69
  expression = current,
69
70
  } = current;
@@ -1,3 +1,6 @@
1
+ const {isArray} = Array;
2
+ const maybeArray = (a) => isArray(a) ? a : [a];
3
+
1
4
  export const report = () => `Remove 'test.only'`;
2
5
 
3
6
  export const replace = () => ({
@@ -5,11 +8,24 @@ export const replace = () => ({
5
8
  '__a.only(__b, __c, __d)': '__a(__b, __c, __d)',
6
9
  });
7
10
 
8
- export const filter = (path) => {
11
+ export const filter = (path, {options}) => {
12
+ const {allowed = []} = options;
9
13
  const objectPath = path.get('callee.object');
10
14
 
11
15
  if (!objectPath.isIdentifier())
12
16
  return false;
13
17
 
14
- return objectPath.node.name.startsWith('test');
18
+ const {name} = objectPath.node;
19
+
20
+ const all = [
21
+ 'test',
22
+ ...maybeArray(allowed),
23
+ ];
24
+
25
+ for (const allowedName of all) {
26
+ if (name.startsWith(allowedName))
27
+ return true;
28
+ }
29
+
30
+ return false;
15
31
  };
@@ -1,5 +1,7 @@
1
1
  import {types} from 'putout';
2
2
 
3
+ const {isArray} = Array;
4
+ const maybeArray = (a) => isArray(a) ? a : [a];
3
5
  const {isIdentifier} = types;
4
6
 
5
7
  export const report = () => 'Remove "test.skip"';
@@ -9,8 +11,21 @@ export const replace = () => ({
9
11
  '__a.skip(__b, __c, __d)': '__a(__b, __c, __d)',
10
12
  });
11
13
 
12
- export const filter = (path) => {
13
- return isIdentifier(path.node.callee.object, {
14
- name: 'test',
15
- });
14
+ export const filter = (path, {options}) => {
15
+ const {allowed = []} = options;
16
+ const all = [
17
+ 'test',
18
+ ...maybeArray(allowed),
19
+ ];
20
+
21
+ for (const name of all) {
22
+ const is = isIdentifier(path.node.callee.object, {
23
+ name,
24
+ });
25
+
26
+ if (is)
27
+ return true;
28
+ }
29
+
30
+ return false;
16
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "21.0.0",
3
+ "version": "21.2.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with tests",
@@ -32,13 +32,13 @@
32
32
  "devDependencies": {
33
33
  "@putout/plugin-putout": "*",
34
34
  "@putout/test": "^15.0.0",
35
- "c8": "^10.0.0",
36
35
  "eslint": "^10.0.0",
37
36
  "eslint-plugin-n": "^17.0.0",
38
37
  "eslint-plugin-putout": "^31.0.0",
39
38
  "madrun": "^13.0.0",
40
- "montag": "^1.2.1",
41
- "nodemon": "^3.0.1"
39
+ "montag": "^2.0.0",
40
+ "nodemon": "^3.0.1",
41
+ "superc8": "^12.0.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "putout": ">=42"