@putout/plugin-putout 18.4.1 β†’ 18.5.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
@@ -25,7 +25,8 @@ npm i @putout/plugin-putout -D
25
25
  "putout/apply-insert-before": "on",
26
26
  "putout/apply-insert-after": "on",
27
27
  "putout/apply-short-processors": "on",
28
- "putout/apply-namaspace-specifier": "on",
28
+ "putout/apply-namespace-specifier": "on",
29
+ "putout/apply-for-of-to-track-file": "on",
29
30
  "putout/add-args": "on",
30
31
  "putout/add-push": "on",
31
32
  "putout/add-track-file": "on",
@@ -276,22 +277,32 @@ const test = createTest({
276
277
  });
277
278
  ```
278
279
 
279
- ## apply-namaspace-specifier
280
+ ## apply-for-of-to-track-file
280
281
 
281
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c8ccc07044299e463807773705aec583/71722e57f2b0b03eb8300ab6fe268251dc696629).
282
+ > The **Generator** object is returned by a `generator function` and it conforms to both the iterable protocol and the `iterator` protocol.
283
+ >
284
+ > (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator)
285
+
286
+ `trackFile` is generator function used to count progress that can be used in [**Scanner**](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#scanner).
287
+
288
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/5ec6c384aa6e4471aab17efb86e185f3/e749c7d649ef2da76410a5964e7c875d10538789)
282
289
 
283
290
  ### ❌ Example of incorrect code
284
291
 
285
292
  ```js
286
- import a from './index.js';
287
- import b from '../lib/index.js';
293
+ module.exports.scan = (path, {push, trackFile}) => {
294
+ trackFile(path, '*.swp').map(push);
295
+ };
288
296
  ```
289
297
 
290
298
  ### βœ… Example of correct code
291
299
 
292
300
  ```js
293
- import * as a from './index.js';
294
- import * as b from '../lib/index.js';
301
+ module.exports.scan = (path, {push, trackFile}) => {
302
+ for (const file of trackFile(path, '*.swp')) {
303
+ push(file);
304
+ }
305
+ };
295
306
  ```
296
307
 
297
308
  ## create-test
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => `Use 'if condition' instead of 'ternary expression'`;
4
+
5
+ module.exports.replace = () => ({
6
+ 'trackFile(__a, __b).map(push)': 'for (const file of trackFile( __a, __b)) {push(file)}',
7
+ });
package/lib/index.js CHANGED
@@ -39,7 +39,7 @@ const addPush = require('./add-push');
39
39
  const moveRequireOnTopLevel = require('./move-require-on-top-level');
40
40
  const includer = require('./includer');
41
41
  const createTest = require('./create-test');
42
- const applyNamaspaceSpecifier = require('./apply-namaspace-specifier');
42
+ const applyNamespaceSpecifier = require('./apply-namespace-specifier');
43
43
  const convertGetRuleToRequire = require('./convert-get-rule-to-require');
44
44
  const addIndexToImport = require('./add-index-to-import');
45
45
  const applyRename = require('./apply-rename');
@@ -47,6 +47,7 @@ const applyShortProcessors = require('./apply-short-processors');
47
47
  const addTrackFile = require('./add-track-file');
48
48
  const convertProgressToTrackFile = require('./convert-progress-to-track-file');
49
49
  const addAwaitToProgress = require('./add-await-to-progress');
50
+ const applyForOfToTrackFile = require('./apply-for-of-to-track-file');
50
51
 
51
52
  module.exports.rules = {
52
53
  'apply-processors-destructuring': applyProcessorsDestructuring,
@@ -87,7 +88,7 @@ module.exports.rules = {
87
88
  'move-require-on-top-level': moveRequireOnTopLevel,
88
89
  includer,
89
90
  'create-test': createTest,
90
- 'apply-namaspace-specifier': applyNamaspaceSpecifier,
91
+ 'apply-namespace-specifier': applyNamespaceSpecifier,
91
92
  'convert-get-rule-to-require': convertGetRuleToRequire,
92
93
  'add-index-to-import': addIndexToImport,
93
94
  'apply-rename': applyRename,
@@ -96,4 +97,5 @@ module.exports.rules = {
96
97
  'add-track-file': addTrackFile,
97
98
  'convert-progress-to-track-file': convertProgressToTrackFile,
98
99
  'add-await-to-progress': addAwaitToProgress,
100
+ 'apply-for-of-to-track-file': applyForOfToTrackFile,
99
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "18.4.1",
3
+ "version": "18.5.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",