@putout/plugin-putout 27.7.0 β 27.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
|
@@ -813,11 +813,15 @@ t.transform('nested-not-block', [
|
|
|
813
813
|
|
|
814
814
|
## convert-push-object-to-push-path
|
|
815
815
|
|
|
816
|
-
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/
|
|
816
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fc54c923cb3cc4095c3c1d84d7ae7982/7de8eace54c8068be4ec5954ad4dde6d52ec6ca6).
|
|
817
817
|
|
|
818
818
|
### β Example of incorrect code
|
|
819
819
|
|
|
820
820
|
```js
|
|
821
|
+
export const fix = ({path}) => {
|
|
822
|
+
removeClassName(path, SELECTED);
|
|
823
|
+
};
|
|
824
|
+
|
|
821
825
|
push({
|
|
822
826
|
path: child,
|
|
823
827
|
});
|
|
@@ -826,6 +830,10 @@ push({
|
|
|
826
830
|
### β
Example of correct code
|
|
827
831
|
|
|
828
832
|
```js
|
|
833
|
+
export const fix = (path) => {
|
|
834
|
+
removeClassName(path, SELECTED);
|
|
835
|
+
};
|
|
836
|
+
|
|
829
837
|
push(child);
|
|
830
838
|
```
|
|
831
839
|
|
|
@@ -1,5 +1,37 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {traverse} = operator;
|
|
4
|
+
|
|
1
5
|
export const report = () => `Use 'push(__a)' instead of 'push({path: __a})'`;
|
|
2
6
|
|
|
7
|
+
export const match = () => ({
|
|
8
|
+
'push({path})': (vars, path) => {
|
|
9
|
+
let is = false;
|
|
10
|
+
const programPath = path.scope.getProgramParent().path;
|
|
11
|
+
|
|
12
|
+
traverse(programPath, {
|
|
13
|
+
'export const fix = ({path}) => __body': () => {
|
|
14
|
+
is = true;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return is;
|
|
19
|
+
},
|
|
20
|
+
'export const fix = ({path}) => __a': (vars, {parentPath}) => {
|
|
21
|
+
let is = false;
|
|
22
|
+
|
|
23
|
+
traverse(parentPath, {
|
|
24
|
+
'push({path: __a})': () => {
|
|
25
|
+
is = true;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return is;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
3
33
|
export const replace = () => ({
|
|
4
34
|
'push({path: __a})': 'push(__a)',
|
|
35
|
+
'push({path})': 'push(path)',
|
|
36
|
+
'export const fix = ({path}) => __a': 'export const fix = (path) => __a',
|
|
5
37
|
});
|
package/package.json
CHANGED