@putout/plugin-destructuring 1.4.0 → 1.4.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
@@ -19,7 +19,6 @@ npm i @putout/plugin-destructuring
19
19
 
20
20
  - ✅ [apply-array](#apply-array);
21
21
  - ✅ [apply-object](#apply-object);
22
- - ✅ [apply-declarations-order](#apply-declarations-order);
23
22
  - ✅ [convert-object-to-array](#convert-object-to-array);
24
23
  - ✅ [extract-properties](#extract-properties);
25
24
  - ✅ [remove-useless-object](#remove-useless-object);
@@ -36,7 +35,6 @@ npm i @putout/plugin-destructuring
36
35
  "rules": {
37
36
  "destructuring/apply-array": "on",
38
37
  "destructuring/apply-object": "on",
39
- "destructuring/apply-declarations-order": "on",
40
38
  "destructuring/convert-object-to-array": "on",
41
39
  "destructuring/extract-properties": "on",
42
40
  "destructuring/remove-useless-object": "on",
@@ -81,24 +79,6 @@ const {name} = user;
81
79
  ({hello} = world);
82
80
  ```
83
81
 
84
- ## apply-declarations-order
85
-
86
- Helps to [extract-properties](#extract-properties'). Checkout in 🐊[**Putout Editor**](https://putout.vercel.app/#/gist/b70ff926b36e1e97ec7129aa0e0458a7/ece0a706de2fd24a66b4671284f7f75017f3c268).
87
-
88
- ### ❌ Example of incorrect code
89
-
90
- ```js
91
- const {env} = require('node:process');
92
- const process = require('node:process');
93
- ```
94
-
95
- ### ✅ Example of correct code
96
-
97
- ```js
98
- const process = require('node:process');
99
- const {env} = process;
100
- ```
101
-
102
82
  ## remove-useless-object
103
83
 
104
84
  Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c9ed04b421d75ae39e58038fa6e14630/4c097e3173990ec7e5ebabbe2cedf8e952092ebf).
package/lib/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import * as applyDeclarationsOrder from './apply-declarations-order/index.js';
2
1
  import * as applyObject from './apply-object/index.js';
3
2
  import * as applyArray from './apply-array/index.js';
4
3
  import * as extractPropertiesEqualDeep from './extract-properties-equal-deep/index.js';
@@ -14,7 +13,6 @@ import * as mergeProperties from './merge-properties/index.js';
14
13
  export const rules = {
15
14
  'apply-array': applyArray,
16
15
  'apply-object': applyObject,
17
- 'apply-declarations-order': applyDeclarationsOrder,
18
16
  'convert-object-to-array': convertObjectToArray,
19
17
  'extract-properties-equal-deep': extractPropertiesEqualDeep,
20
18
  'extract-properties-not-equal-deep': extractPropertiesNotEqualDeep,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-destructuring",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform destructuring",
@@ -1,40 +0,0 @@
1
- import {types, operator} from 'putout';
2
-
3
- const {
4
- insertAfter,
5
- remove,
6
- compare,
7
- getTemplateValues,
8
- } = operator;
9
-
10
- const {
11
- isVariableDeclaration,
12
- isIdentifier,
13
- } = types;
14
-
15
- export const report = () => `Apply declarations order`;
16
-
17
- export const fix = ({path, current}) => {
18
- const {node} = current;
19
- remove(current);
20
- insertAfter(path, node);
21
- };
22
-
23
- export const traverse = ({push}) => ({
24
- 'const __a = __b': (path) => {
25
- const {__a, __b} = getTemplateValues(path, 'const __a = __b');
26
-
27
- if (!isIdentifier(__a))
28
- return;
29
-
30
- const prev = path.getAllPrevSiblings();
31
-
32
- for (const current of prev.filter(isVariableDeclaration)) {
33
- if (compare(__b, current.node.declarations[0].init))
34
- push({
35
- current,
36
- path,
37
- });
38
- }
39
- },
40
- });