@putout/plugin-putout 19.0.0 β†’ 19.2.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
@@ -60,7 +60,8 @@ npm i @putout/plugin-putout -D
60
60
  "putout/declare": "on",
61
61
  "putout/includer": "on",
62
62
  "putout/move-require-on-top-level": "on",
63
- "putout/replace-test-message": "on"
63
+ "putout/replace-test-message": "on",
64
+ "putout/remove-unused-get-properties-argument": "on"
64
65
  }
65
66
  }
66
67
  ```
@@ -1103,6 +1104,39 @@ test('plugin-putout: rename-operate-to-operator: no report: operator exist', (t)
1103
1104
  });
1104
1105
  ```
1105
1106
 
1107
+ ## remove-unused-get-properties-argument
1108
+
1109
+ Check it out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fc32ff87e91fd28f26a03f55eba0663e/3423926ba0a80d30beafe2ac66c70c517df173e1).
1110
+
1111
+ ### ❌ Example of incorrect code
1112
+
1113
+ ```js
1114
+ const {
1115
+ overridesPath,
1116
+ parserPath,
1117
+ rulesPath,
1118
+ } = getProperties(__jsonPath, [
1119
+ 'parser',
1120
+ 'rules',
1121
+ 'overrides',
1122
+ 'extends',
1123
+ ]);
1124
+ ```
1125
+
1126
+ ### βœ… Example of correct code
1127
+
1128
+ ```js
1129
+ const {
1130
+ overridesPath,
1131
+ parserPath,
1132
+ rulesPath,
1133
+ } = getProperties(__jsonPath, [
1134
+ 'parser',
1135
+ 'rules',
1136
+ 'extends',
1137
+ ]);
1138
+ ```
1139
+
1106
1140
  ## License
1107
1141
 
1108
1142
  MIT
package/lib/index.js CHANGED
@@ -48,6 +48,7 @@ const addTrackFile = require('./add-track-file');
48
48
  const convertProgressToTrackFile = require('./convert-progress-to-track-file');
49
49
  const addAwaitToProgress = require('./add-await-to-progress');
50
50
  const applyForOfToTrackFile = require('./apply-for-of-to-track-file');
51
+ const removeUnusedGetPropertiesArgument = require('./remove-unused-get-properties-argument');
51
52
 
52
53
  module.exports.rules = {
53
54
  'apply-processors-destructuring': applyProcessorsDestructuring,
@@ -98,4 +99,5 @@ module.exports.rules = {
98
99
  'convert-progress-to-track-file': convertProgressToTrackFile,
99
100
  'add-await-to-progress': addAwaitToProgress,
100
101
  'apply-for-of-to-track-file': applyForOfToTrackFile,
102
+ 'remove-unused-get-properties-argument': removeUnusedGetPropertiesArgument,
101
103
  };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const {operator} = require('putout');
4
+ const {
5
+ getTemplateValues,
6
+ remove,
7
+ } = operator;
8
+
9
+ const GET_PROPERTIES = 'const __a = getProperties(__b, __c)';
10
+
11
+ module.exports.report = ({name}) => `Remove unused property '${name}' from 'getProperties()' arguments`;
12
+
13
+ module.exports.fix = ({path}) => {
14
+ remove(path);
15
+ };
16
+
17
+ module.exports.traverse = ({push}) => ({
18
+ [GET_PROPERTIES]: (path) => {
19
+ const {__a} = getTemplateValues(path, GET_PROPERTIES);
20
+ const __cPath = path.get('declarations.0.init.arguments.1');
21
+
22
+ for (const nameProp of __cPath.get('elements')) {
23
+ let used = false;
24
+ const {value} = nameProp.node;
25
+
26
+ for (const prop of __a.properties) {
27
+ const propName = prop.value.name.replace(/Path$/, '');
28
+
29
+ if (propName === value)
30
+ used = true;
31
+ }
32
+
33
+ if (!used)
34
+ push({
35
+ path: nameProp,
36
+ name: value,
37
+ });
38
+ }
39
+ },
40
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "19.0.0",
3
+ "version": "19.2.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",
@@ -41,7 +41,7 @@
41
41
  "@putout/test": "^9.0.0",
42
42
  "c8": "^9.0.0",
43
43
  "eslint": "^9.0.0",
44
- "eslint-plugin-n": "^17.0.0-0",
44
+ "eslint-plugin-n": "^17.0.0",
45
45
  "eslint-plugin-putout": "^22.0.0",
46
46
  "lerna": "^6.0.1",
47
47
  "madrun": "^10.0.0",