@putout/plugin-tape 3.7.1 → 3.8.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
@@ -20,6 +20,7 @@ npm i @putout/plugin-tape -D
20
20
  "rules": {
21
21
  "tape/apply-stub-operator": "on",
22
22
  "tape/apply-with-name": "on",
23
+ "tape/sync-with-name": "on",
23
24
  "tape/switch-expected-with-result": "on",
24
25
  "tape/convert-tape-to-supertape": "on",
25
26
  "tape/convert-throws-to-try-catch": "on",
@@ -343,6 +344,31 @@ test('should call init before show', (t) => {
343
344
  });
344
345
  ```
345
346
 
347
+ ## sync-with-name
348
+
349
+ ### ❌ Incorrect code example
350
+
351
+ ```js
352
+ test('should call init before show', (t) => {
353
+ const init = stub().withName('show');
354
+ const show = stub().withName('show');
355
+
356
+ t.calledInOrder([init, show]);
357
+ t.end();
358
+ });
359
+ ```
360
+
361
+ ### ✅ Correct code example
362
+
363
+ ```js
364
+ test('should call init before show', (t) => {
365
+ const init = stub().withName('init');
366
+ const show = stub().withName('show');
367
+
368
+ t.calledInOrder([init, show]);
369
+ t.end();
370
+ });
371
+ ```
346
372
 
347
373
  ## declare-stub
348
374
 
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ const getRule = (a) => ({
6
6
 
7
7
  module.exports.rules = {
8
8
  ...getRule('apply-with-name'),
9
+ ...getRule('sync-with-name'),
9
10
  ...getRule('convert-tape-to-supertape'),
10
11
  ...getRule('convert-throws-to-try-catch'),
11
12
  ...getRule('convert-does-not-throw-to-try-catch'),
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => `'stub().withName(name)' should synced with variable name`;
4
+
5
+ module.exports.match = () => ({
6
+ 'const __a = stub().withName(__b)': ({__a, __b}) => __b.value !== __a.name,
7
+ });
8
+
9
+ module.exports.replace = () => ({
10
+ 'const __a = stub().withName(__b)': ({__a, __b}, path) => {
11
+ __b.value = __a.name;
12
+ return path;
13
+ },
14
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "putout plugin helps with tests",
6
6
  "homepage": "http://github.com/coderaiser/putout",
@@ -39,6 +39,7 @@
39
39
  "eslint-plugin-putout": "^10.0.0",
40
40
  "lerna": "^4.0.0",
41
41
  "madrun": "^8.0.1",
42
+ "montag": "^1.2.1",
42
43
  "nodemon": "^2.0.1"
43
44
  },
44
45
  "peerDependencies": {