@putout/plugin-for-of 5.2.0 → 6.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,7 +17,6 @@ npm i @putout/plugin-for-of
17
17
 
18
18
  ## Rules
19
19
 
20
- - ✅ [add-missing-star](#add-missing-star);
21
20
  - ✅ [for-each](#for-each);
22
21
  - ✅ [for-entries](#for-entries);
23
22
  - ✅ [for-entries-n](#for-entries-n);
@@ -37,7 +36,6 @@ npm i @putout/plugin-for-of
37
36
  ```json
38
37
  {
39
38
  "rules": {
40
- "for-of/add-missing-star": "on",
41
39
  "for-of/map": "on",
42
40
  "for-of/for-in": "on",
43
41
  "for-of/for-each": "on",
@@ -53,37 +51,6 @@ npm i @putout/plugin-for-of
53
51
  }
54
52
  ```
55
53
 
56
- ## add-missing-star
57
-
58
- > The `function*` declaration creates a binding of a new generator function to a given name.
59
- >
60
- > (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*)
61
-
62
- ### ❌ Example of incorrect code
63
-
64
- ```js
65
- function hello() {
66
- yield;
67
- 'world';
68
- }
69
-
70
- function func2() {
71
- yield * func1();
72
- }
73
- ```
74
-
75
- ### ✅ Example of correct code
76
-
77
- ```js
78
- function* hello() {
79
- yield 'world';
80
- }
81
-
82
- function* func2() {
83
- yield* func1();
84
- }
85
- ```
86
-
87
54
  ## map
88
55
 
89
56
  > The [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) method creates a new array populated with the results of calling a provided function on every element in the calling array.
package/lib/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const addMissingStar = require('./add-missing-star');
4
3
  const map = require('./map');
5
4
  const forEach = require('./for-each');
6
5
  const forN = require('./for-n');
@@ -16,7 +15,6 @@ const removeUselessArrayFrom = require('./remove-useless-array-from');
16
15
  const removeUnusedVariables = require('./remove-unused-variables');
17
16
 
18
17
  module.exports.rules = {
19
- 'add-missing-star': addMissingStar,
20
18
  map,
21
19
  'for-each': forEach,
22
20
  'for-n': forN,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-for-of",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to apply for...of",
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- const {types, operator} = require('putout');
4
- const {remove, replaceWith} = operator;
5
- const {YieldExpression} = types;
6
-
7
- const DELEGATE = true;
8
-
9
- module.exports.report = () => `Add missing '*' in generator function`;
10
-
11
- module.exports.fix = (path) => {
12
- const fnPath = path.getFunctionParent();
13
-
14
- fnPath.node.generator = true;
15
-
16
- if (path.parentPath.isExpressionStatement()) {
17
- const next = path.parentPath.getNextSibling();
18
- const {expression} = next.node;
19
-
20
- replaceWith(path, YieldExpression(expression));
21
- remove(next);
22
-
23
- return;
24
- }
25
-
26
- const {parentPath} = path;
27
- const {right} = parentPath.node;
28
-
29
- replaceWith(parentPath, YieldExpression(right, DELEGATE));
30
- };
31
-
32
- module.exports.traverse = ({push}) => ({
33
- Identifier(path) {
34
- if (path.node.name !== 'yield')
35
- return;
36
-
37
- if (path.parentPath.isBinaryExpression({operator: '*'})) {
38
- push(path);
39
- return;
40
- }
41
-
42
- if (!path.parentPath.isExpressionStatement())
43
- return;
44
-
45
- push(path);
46
- },
47
- });