@putout/plugin-putout 27.6.0 → 27.7.1

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
@@ -59,6 +59,7 @@ npm i @putout/plugin-putout -D
59
59
  - ✅ [convert-progress-to-track-file](#convert-progress-to-track-file);
60
60
  - ✅ [convert-putout-test-to-create-test](#convert-putout-test-to-create-test);
61
61
  - ✅ [convert-plugins-element-to-tuple](#convert-plugins-element-to-tuple);
62
+ - ✅ [convert-push-object-to-push-path](#convert-push-object-to-push-path);
62
63
  - ✅ [convert-replace-to-function](#convert-replace-to-function);
63
64
  - ✅ [convert-replace-with](#convert-replace-with);
64
65
  - ✅ [convert-replace-with-multiple](#convert-replace-with-multiple);
@@ -147,6 +148,7 @@ npm i @putout/plugin-putout -D
147
148
  "putout/convert-get-rule-to-require": "on",
148
149
  "putout/convert-progress-to-track-file": "on",
149
150
  "putout/convert-plugins-element-to-tuple": "on",
151
+ "putout/convert-push-object-to-push-path": "on",
150
152
  "putout/create-test": "on",
151
153
  "putout/shorten-imports": "on",
152
154
  "putout/declare": "on",
@@ -809,6 +811,32 @@ t.transform('nested-not-block', [
809
811
  ]);
810
812
  ```
811
813
 
814
+ ## convert-push-object-to-push-path
815
+
816
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fc54c923cb3cc4095c3c1d84d7ae7982/7de8eace54c8068be4ec5954ad4dde6d52ec6ca6).
817
+
818
+ ### ❌ Example of incorrect code
819
+
820
+ ```js
821
+ export const fix = ({path}) => {
822
+ removeClassName(path, SELECTED);
823
+ };
824
+
825
+ push({
826
+ path: child,
827
+ });
828
+ ```
829
+
830
+ ### ✅ Example of correct code
831
+
832
+ ```js
833
+ export const fix = (path) => {
834
+ removeClassName(path, SELECTED);
835
+ };
836
+
837
+ push(child);
838
+ ```
839
+
812
840
  ## convert-to-no-transform-code
813
841
 
814
842
  ### ❌ Example of incorrect code
@@ -0,0 +1,24 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {traverse} = operator;
4
+
5
+ export const report = () => `Use 'push(__a)' instead of 'push({path: __a})'`;
6
+
7
+ export const match = () => ({
8
+ 'export const fix = ({path}) => __a': (vars, {parentPath}) => {
9
+ let is = false;
10
+
11
+ traverse(parentPath, {
12
+ 'push({path: __a})': () => {
13
+ is = true;
14
+ },
15
+ });
16
+
17
+ return is;
18
+ },
19
+ });
20
+
21
+ export const replace = () => ({
22
+ 'push({path: __a})': 'push(__a)',
23
+ 'export const fix = ({path}) => __a': 'export const fix = (path) => __a',
24
+ });
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as convertPushObjectToPushPath from './convert-push-object-to-push-path/index.js';
1
2
  import * as applyTransformWithOptions from './apply-transform-with-options/index.js';
2
3
  import * as convertPluginsElementToTuple from './convert-plugins-element-to-tuple/index.js';
3
4
  import * as removeEmptyObjectFromTransform from './remove-empty-object-from-transform/index.js';
@@ -142,4 +143,5 @@ export const rules = {
142
143
  'remove-empty-object-from-transform': removeEmptyObjectFromTransform,
143
144
  'convert-plugins-element-to-tuple': convertPluginsElementToTuple,
144
145
  'apply-transform-with-options': applyTransformWithOptions,
146
+ 'convert-push-object-to-push-path': convertPushObjectToPushPath,
145
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "27.6.0",
3
+ "version": "27.7.1",
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",