@putout/plugin-putout 14.8.0 β†’ 15.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
@@ -20,6 +20,7 @@ npm i @putout/plugin-putout -D
20
20
  "putout/apply-processors-destructuring": "on",
21
21
  "putout/apply-async-formatter": "on",
22
22
  "putout/apply-declare": "on",
23
+ "putout/apply-rename": "on",
23
24
  "putout/apply-remove": "on",
24
25
  "putout/apply-insert-before": "on",
25
26
  "putout/apply-insert-after": "on",
@@ -76,6 +77,31 @@ test('', async ({process}) => {
76
77
  });
77
78
  ```
78
79
 
80
+ ## apply-rename
81
+
82
+ Better use [`rename(path, from, to)`](https://github.com/coderaiser/putout/tree/master/packages/operate#rename) method of `operator`.
83
+ Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/22716f61af86351331fc92260b7ed8e6/1435f31954764c119813e03654caa36e6a2a666b).
84
+
85
+ ### ❌ Example of incorrect code
86
+
87
+ ```js
88
+ export const fix = ({path, from, to}) => {
89
+ path.scope.rename(from, to);
90
+ };
91
+ ```
92
+
93
+ ### βœ… Example of correct code
94
+
95
+ ```js
96
+ import {operator} from 'putout';
97
+
98
+ const {rename} = operator;
99
+
100
+ export const fix = ({path, from, to}) => {
101
+ rename(path, from, to);
102
+ };
103
+ ```
104
+
79
105
  ## apply-remove
80
106
 
81
107
  Better to use [`remove(path)`](https://github.com/coderaiser/putout/tree/master/packages/operate#removepath) method of `operator`.
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => `Use 'rename(path, from, to)' instead of 'path.scope.rename(from, to)'`;
4
+
5
+ module.exports.replace = () => ({
6
+ '__a.scope.rename(__b, __c)': 'rename(__a, __b, __c)',
7
+ });
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const {operator} = require('putout');
4
+ const {rename} = operator;
3
5
  const {assign} = Object;
4
6
 
5
7
  module.exports.report = () => `Use 'createTest' instead of 'putoutTest'`;
@@ -18,5 +20,5 @@ module.exports.fix = (path) => {
18
20
  imported: first.local,
19
21
  });
20
22
 
21
- path.scope.rename('putoutTest', 'createTest');
23
+ rename(path, 'putoutTest', 'createTest');
22
24
  };
package/lib/index.js CHANGED
@@ -41,6 +41,7 @@ const createTest = require('./create-test');
41
41
  const applyNamaspaceSpecifier = require('./apply-namaspace-specifier');
42
42
  const convertGetRuleToRequire = require('./convert-get-rule-to-require');
43
43
  const addIndexToImport = require('./add-index-to-import');
44
+ const applyRename = require('./apply-rename');
44
45
 
45
46
  module.exports.rules = {
46
47
  'apply-processors-destructuring': applyProcessorsDestructuring,
@@ -84,4 +85,5 @@ module.exports.rules = {
84
85
  'apply-namaspace-specifier': applyNamaspaceSpecifier,
85
86
  'convert-get-rule-to-require': convertGetRuleToRequire,
86
87
  'add-index-to-import': addIndexToImport,
88
+ 'apply-rename': applyRename,
87
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "14.8.0",
3
+ "version": "15.0.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",
@@ -48,7 +48,7 @@
48
48
  "nodemon": "^3.0.1"
49
49
  },
50
50
  "peerDependencies": {
51
- "putout": ">=31"
51
+ "putout": ">=32"
52
52
  },
53
53
  "license": "MIT",
54
54
  "engines": {