@putout/plugin-putout 29.34.0 → 29.35.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
@@ -105,6 +105,7 @@ npm i @putout/plugin-putout -D
105
105
  - ✅ [convert-replacer-to-includer](#convert-replacer-to-includer);
106
106
  - ✅ [remove-useless-match](#remove-useless-match);
107
107
  - ✅ [remove-useless-type-check-declaration](#remove-useless-type-check-declaration);
108
+ - ✅ [shorten-path-get](#shorten-path-get);
108
109
 
109
110
  ## File rules
110
111
 
@@ -206,7 +207,8 @@ npm i @putout/plugin-putout -D
206
207
  "putout/sort-readme-file": "on",
207
208
  "putout/convert-replacer-to-includer": "on",
208
209
  "putout/remove-useless-match": "on",
209
- "putout/remove-useless-type-check-declaration": "on"
210
+ "putout/remove-useless-type-check-declaration": "on",
211
+ "putout/shorten-path-get": "on"
210
212
  }
211
213
  }
212
214
  ```
@@ -2329,13 +2331,27 @@ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/443f742c8c
2329
2331
 
2330
2332
  ```js
2331
2333
  const isStringLiteral = (arg) => arg.type === 'StringLiteral';
2332
- const isMemberExpression = (arg) => arg.type === 'Identifier';
2333
2334
  ```
2334
2335
 
2335
2336
  ### ✅ Example of correct code
2336
2337
 
2337
2338
  ```js
2338
- const isMemberExpression = (arg) => arg.type === 'Identifier';
2339
+ ```
2340
+
2341
+ ## shorten-path-get
2342
+
2343
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/afc8a421eee129910153939eae2eb79e/04304530529a53f5894a289bcd83d3ac2460c9ab).
2344
+
2345
+ ### ❌ Example of incorrect code
2346
+
2347
+ ```js
2348
+ const elements = path.get('arguments')[0].get('elements');
2349
+ ```
2350
+
2351
+ ### ✅ Example of correct code
2352
+
2353
+ ```js
2354
+ const elements = path.get('arguments.0.elements');
2339
2355
  ```
2340
2356
 
2341
2357
  ## License
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as shortenPathGet from './shorten-path-get/index.js';
1
2
  import * as removeUselessTypeCheckDeclaration from './remove-useless-type-check-declaration/index.js';
2
3
  import * as removeUselessMatch from './remove-useless-match/index.js';
3
4
  import * as convertReplacerToIncluder from './convert-replacer-to-includer/index.js';
@@ -186,4 +187,5 @@ export const rules = {
186
187
  'convert-replacer-to-includer': convertReplacerToIncluder,
187
188
  'remove-useless-match': removeUselessMatch,
188
189
  'remove-useless-type-check-declaration': removeUselessTypeCheckDeclaration,
190
+ 'shorten-path-get': shortenPathGet,
189
191
  };
@@ -0,0 +1,7 @@
1
+ export const report = () => `Shorten 'path.get()'`;
2
+
3
+ export const replace = () => ({
4
+ 'path.get("__a")[__b].get("__c")': ({__a, __b, __c}) => {
5
+ return `path.get('${__a.value}.${__b.value}.${__c.value}')`;
6
+ },
7
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "29.34.0",
3
+ "version": "29.35.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",