@putout/plugin-tape 20.3.1 → 21.1.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
  ```
@@ -19,7 +19,7 @@ export const replace = () => ({
19
19
  't.notEqual(__a, __b)': 't.notDeepEqual(__a, __b)',
20
20
  });
21
21
 
22
- function check({__b}, path) {
22
+ function check({__a, __b}, path) {
23
23
  if (isObjectExpression(__b))
24
24
  return true;
25
25
 
@@ -29,6 +29,15 @@ function check({__b}, path) {
29
29
  if (!isIdentifier(__b))
30
30
  return false;
31
31
 
32
+ const __aDeclaration = path.scope.bindings[__a.name];
33
+
34
+ if (__aDeclaration) {
35
+ const {init} = __aDeclaration.path.node;
36
+
37
+ if (compare(init, 'new Date(__args)'))
38
+ return true;
39
+ }
40
+
32
41
  const __bDeclaration = path.scope.bindings[__b.name];
33
42
 
34
43
  if (!__bDeclaration)
@@ -36,6 +45,9 @@ function check({__b}, path) {
36
45
 
37
46
  const {id, init} = __bDeclaration.path.node;
38
47
 
48
+ if (compare(init, 'new Date(__args)'))
49
+ return true;
50
+
39
51
  if (!isIdentifier(id, {name: 'expected'}))
40
52
  return false;
41
53
 
@@ -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": "20.3.1",
3
+ "version": "21.1.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,16 +32,16 @@
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
- "eslint-plugin-putout": "^30.0.0",
39
- "madrun": "^12.0.0",
37
+ "eslint-plugin-putout": "^31.0.0",
38
+ "madrun": "^13.0.0",
40
39
  "montag": "^1.2.1",
41
- "nodemon": "^3.0.1"
40
+ "nodemon": "^3.0.1",
41
+ "superc8": "^12.0.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "putout": ">=41"
44
+ "putout": ">=42"
45
45
  },
46
46
  "license": "MIT",
47
47
  "engines": {