@putout/plugin-putout 28.17.0 → 28.19.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
@@ -17,6 +17,7 @@ npm i @putout/plugin-putout -D
17
17
  - ✅ [add-places-to-compare-places](#add-places-to-compare-places);
18
18
  - ✅ [add-path-arg-to-fix](#add-path-arg-to-fix);
19
19
  - ✅ [add-path-arg-to-visitors](#add-path-arg-to-visitors);
20
+ - ✅ [add-path-arg-to-match](#add-path-arg-to-match);
20
21
  - ✅ [add-push-arg](#add-push-arg);
21
22
  - ✅ [add-test-args](#add-test-args);
22
23
  - ✅ [add-traverse-args](#add-traverse-args);
@@ -36,6 +37,7 @@ npm i @putout/plugin-putout -D
36
37
  - ✅ [apply-fixture-name-to-message](#apply-fixture-name-to-message);
37
38
  - ✅ [apply-insert-after](#apply-insert-after);
38
39
  - ✅ [apply-insert-before](#apply-insert-before);
40
+ - ✅ [apply-traverser-to-ignore](#apply-traverser-to-ignore);
39
41
  - ✅ [apply-vars](#apply-vars);
40
42
  - ✅ [apply-lowercase-to-node-builders](#apply-lowercase-to-node-builders);
41
43
  - ✅ [apply-namespace-specifier](#apply-namespace-specifier);
@@ -100,6 +102,7 @@ npm i @putout/plugin-putout -D
100
102
  "rules": {
101
103
  "putout/add-places-to-compare-places": "on",
102
104
  "putout/add-path-arg-to-fix": "on",
105
+ "putout/add-path-to-match": "on",
103
106
  "putout/add-path-arg-to-visitors": "on",
104
107
  "putout/add-push-arg": "on",
105
108
  "putout/add-test-args": "on",
@@ -124,6 +127,7 @@ npm i @putout/plugin-putout -D
124
127
  "putout/apply-remove": "on",
125
128
  "putout/apply-transform-with-options": "on",
126
129
  "putout/apply-insert-before": "on",
130
+ "putout/apply-traverser-to-ignore": "on",
127
131
  "putout/apply-insert-after": "on",
128
132
  "putout/apply-vars": "on",
129
133
  "putout/apply-short-processors": "on",
@@ -444,6 +448,40 @@ export const fix = (path) => {
444
448
  };
445
449
  ```
446
450
 
451
+ ## apply-traverser-to-ignore
452
+
453
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ff74cf775696df17a5ba96c7ec309821/1cbdee25af883ccefd0a3614fe8424d8690fc58a).
454
+
455
+ ### ❌ Example of incorrect code
456
+
457
+ ```js
458
+ export const {
459
+ report,
460
+ match,
461
+ replace,
462
+ } = ignore({
463
+ type: __json,
464
+ name: '.nycrc.json',
465
+ field: 'exclude',
466
+ list: ['*.config.*'],
467
+ });
468
+ ```
469
+
470
+ ### ✅ Example of correct code
471
+
472
+ ```js
473
+ export const {
474
+ report,
475
+ fix,
476
+ traverse,
477
+ } = ignore({
478
+ type: __json,
479
+ name: '.nycrc.json',
480
+ field: 'exclude',
481
+ list: ['*.config.*'],
482
+ });
483
+ ```
484
+
447
485
  ## apply-vars
448
486
 
449
487
  Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/6b1a4b5dc75f2591faf580774d23b38f/7278945371ceb76942494f7caf88375d2eaca869).
@@ -1403,6 +1441,36 @@ export const fix = (path) => {
1403
1441
  };
1404
1442
  ```
1405
1443
 
1444
+ ## add-path-arg-to-match
1445
+
1446
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/35189d0e47c6ad1ca369e5a9287a34c1/d5fa7513a44fecc86beabd1faa8542bee7bc3e5e).
1447
+
1448
+ ### ❌ Example of incorrect code
1449
+
1450
+ ```js
1451
+ export const match = () => ({
1452
+ 'nemesis.getChar()': () => {
1453
+ return path.parentPath.isExpressionStatement();
1454
+ },
1455
+ 'getChar()': ({__a}) => {
1456
+ return path.parentPath.isExpressionStatement();
1457
+ },
1458
+ });
1459
+ ```
1460
+
1461
+ ### ✅ Example of correct code
1462
+
1463
+ ```js
1464
+ export const match = () => ({
1465
+ 'nemesis.getChar()': (vars, path) => {
1466
+ return path.parentPath.isExpressionStatement();
1467
+ },
1468
+ 'getChar()': ({__a}, path) => {
1469
+ return path.parentPath.isExpressionStatement();
1470
+ },
1471
+ });
1472
+ ```
1473
+
1406
1474
  ## add-path-arg-to-visitors
1407
1475
 
1408
1476
  Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/e20eb16668b2ebbceca1a03cde859e93/fee08d6dbb6aa4d835adacc8e9de4d994fd34848).
@@ -0,0 +1,14 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {addArgs} = operator;
4
+
5
+ export const {
6
+ report,
7
+ fix,
8
+ traverse,
9
+ } = addArgs({
10
+ path: ['vars, path', [
11
+ '(__a) => __body',
12
+ '() => __body',
13
+ ]],
14
+ });
@@ -0,0 +1,21 @@
1
+ export const report = () => `Use 'Traverser' instead of 'Replacer'`;
2
+
3
+ const getName = ({key}) => key.name;
4
+ const TRAVERSER = new Set([
5
+ 'report',
6
+ 'fix',
7
+ 'traverse',
8
+ ]);
9
+
10
+ export const match = () => ({
11
+ 'export const __object = ignore(__args)': ({__object}) => {
12
+ const names = new Set(__object.properties.map(getName));
13
+ const diff = TRAVERSER.difference(names);
14
+
15
+ return diff.size;
16
+ },
17
+ });
18
+
19
+ export const replace = () => ({
20
+ 'export const __object = ignore(__args)': 'export const {report, fix, traverse} = ignore(__args)',
21
+ });
package/lib/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import * as applyTraverserToIgnore from './apply-traverser-to-ignore/index.js';
2
+ import * as addPathArgToMatch from './add-path-arg-to-match/index.js';
1
3
  import * as removeMessageFromNoReportAfterTransform from './remove-message-from-no-report-after-transform/index.js';
2
4
  import * as addCrawlFile from './add-crawl-file/index.js';
3
5
  import * as applyDesturcturing from './apply-desturcturing/index.js';
@@ -158,4 +160,6 @@ export const rules = {
158
160
  'apply-desturcturing': applyDesturcturing,
159
161
  'add-crawl-file': addCrawlFile,
160
162
  'remove-message-from-no-report-after-transform': removeMessageFromNoReportAfterTransform,
163
+ 'add-path-arg-to-match': addPathArgToMatch,
164
+ 'apply-traverser-to-ignore': applyTraverserToIgnore,
161
165
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "28.17.0",
3
+ "version": "28.19.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",