@putout/plugin-putout 28.5.0 → 28.6.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
@@ -62,6 +62,7 @@ npm i @putout/plugin-putout -D
62
62
  - ✅ [convert-plugins-element-to-tuple](#convert-plugins-element-to-tuple);
63
63
  - ✅ [convert-push-object-to-push-path](#convert-push-object-to-push-path);
64
64
  - ✅ [convert-replace-to-function](#convert-replace-to-function);
65
+ - ✅ [convert-replace-to-traverse](#convert-replace-to-traverse);
65
66
  - ✅ [convert-replace-with](#convert-replace-with);
66
67
  - ✅ [convert-replace-with-multiple](#convert-replace-with-multiple);
67
68
  - ✅ [convert-report-to-function](#convert-report-to-function);
@@ -133,6 +134,7 @@ npm i @putout/plugin-putout -D
133
134
  "putout/convert-replace-with": "on",
134
135
  "putout/convert-replace-with-multiple": "on",
135
136
  "putout/convert-replace-to-function": "on",
137
+ "putout/convert-replace-to-traverse": "on",
136
138
  "putout/convert-match-to-function": "on",
137
139
  "putout/convert-babel-types": "on",
138
140
  "putout/convert-destructuring-to-identifier": "on",
@@ -943,6 +945,34 @@ module.exports.replace = () => ({
943
945
  });
944
946
  ```
945
947
 
948
+ ## convert-replace-to-traverse
949
+
950
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a87ab50e500cd3aee3099063a48c0e3f/8dee3919638062563c9b39886d8bb8581f5722f2).
951
+
952
+ ### ❌ Example of incorrect code
953
+
954
+ ```js
955
+ export const fix = () => {};
956
+ export const replace = () => ({
957
+ [__json]: (path) => {
958
+ const __aPath = path.get('arguments.0');
959
+ const {importsPath} = getProperties(__aPath, ['imports']);
960
+ },
961
+ });
962
+ ```
963
+
964
+ ### ✅ Example of correct code
965
+
966
+ ```js
967
+ export const fix = () => {};
968
+ export const traverse = () => ({
969
+ [__json]: (path) => {
970
+ const __aPath = path.get('arguments.0');
971
+ const {importsPath} = getProperties(__aPath, ['imports']);
972
+ },
973
+ });
974
+ ```
975
+
946
976
  ## convert-match-to-function
947
977
 
948
978
  ### ❌ Example of incorrect code
@@ -0,0 +1,22 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {compare} = operator;
4
+
5
+ export const report = () => `Use 'traverse' instead of 'replace' when using 'fix'`;
6
+
7
+ export const match = () => ({
8
+ 'export const replace = __a': (vars, path) => {
9
+ const {body} = path.scope.getProgramParent().path.node;
10
+
11
+ for (const current of body) {
12
+ if (compare(current, 'export const fix = __a'))
13
+ return true;
14
+ }
15
+
16
+ return false;
17
+ },
18
+ });
19
+
20
+ export const replace = () => ({
21
+ 'export const replace = __a': 'export const traverse = __a',
22
+ });
@@ -1,5 +1,4 @@
1
1
  import {operator} from 'putout';
2
- import fullstore from 'fullstore';
3
2
 
4
3
  const {replaceWith} = operator;
5
4
 
@@ -12,8 +11,8 @@ export const fix = ({path, calleePath, property, object}) => {
12
11
  path.node.arguments.unshift(object);
13
12
  };
14
13
 
15
- export const traverse = ({push}) => {
16
- const isInserted = fullstore();
14
+ export const traverse = ({push, store}) => {
15
+ const isInserted = store();
17
16
 
18
17
  return {
19
18
  CallExpression(path) {
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as convertReplaceToTraverse from './convert-replace-to-traverse/index.js';
1
2
  import * as applyEngineNodeVersion from './apply-engine-node-version/index.js';
2
3
  import * as convertPushObjectToPushPath from './convert-push-object-to-push-path/index.js';
3
4
  import * as applyTransformWithOptions from './apply-transform-with-options/index.js';
@@ -146,4 +147,5 @@ export const rules = {
146
147
  'apply-transform-with-options': applyTransformWithOptions,
147
148
  'convert-push-object-to-push-path': convertPushObjectToPushPath,
148
149
  'apply-engine-node-version': applyEngineNodeVersion,
150
+ 'convert-replace-to-traverse': convertReplaceToTraverse,
149
151
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "28.5.0",
3
+ "version": "28.6.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",
@@ -31,7 +31,6 @@
31
31
  "create:declare:types": "madrun create:declare:types"
32
32
  },
33
33
  "dependencies": {
34
- "fullstore": "^3.0.0",
35
34
  "just-camel-case": "^6.2.0",
36
35
  "just-kebab-case": "^4.2.0",
37
36
  "regexp.escape": "^2.0.1",