@putout/plugin-putout 29.2.2 → 29.3.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 +24 -2
- package/lib/add-path-arg-to-fix/index.js +14 -17
- package/lib/add-path-arg-to-match/index.js +10 -11
- package/lib/add-path-to-filter/index.js +16 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ npm i @putout/plugin-putout -D
|
|
|
16
16
|
- ✅ [add-await-to-progress](#add-await-to-progress);
|
|
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
|
+
- ✅ [add-path-arg-to-filter](#add-path-arg-to-filter);
|
|
19
20
|
- ✅ [add-path-arg-to-visitors](#add-path-arg-to-visitors);
|
|
20
21
|
- ✅ [add-path-arg-to-match](#add-path-arg-to-match);
|
|
21
22
|
- ✅ [add-push-arg](#add-push-arg);
|
|
@@ -103,7 +104,8 @@ npm i @putout/plugin-putout -D
|
|
|
103
104
|
"rules": {
|
|
104
105
|
"putout/add-places-to-compare-places": "on",
|
|
105
106
|
"putout/add-path-arg-to-fix": "on",
|
|
106
|
-
"putout/add-path-to-
|
|
107
|
+
"putout/add-path-arg-to-filter": "on",
|
|
108
|
+
"putout/add-path-arg-to-match": "on",
|
|
107
109
|
"putout/add-path-arg-to-visitors": "on",
|
|
108
110
|
"putout/add-push-arg": "on",
|
|
109
111
|
"putout/add-test-args": "on",
|
|
@@ -1440,6 +1442,26 @@ export const fix = (path) => {
|
|
|
1440
1442
|
};
|
|
1441
1443
|
```
|
|
1442
1444
|
|
|
1445
|
+
## add-path-arg-to-filter
|
|
1446
|
+
|
|
1447
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/00a5e23e6a1a708937ef3fae2a792f86/c2fc350831f777bbb383fb65216b349edd4ec53d).
|
|
1448
|
+
|
|
1449
|
+
### ❌ Example of incorrect code
|
|
1450
|
+
|
|
1451
|
+
```js
|
|
1452
|
+
export const filter = () => {
|
|
1453
|
+
return path.isStringLiteral();
|
|
1454
|
+
};
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
### ✅ Example of correct code
|
|
1458
|
+
|
|
1459
|
+
```js
|
|
1460
|
+
export const filter = (path) => {
|
|
1461
|
+
return path.isStringLiteral();
|
|
1462
|
+
};
|
|
1463
|
+
```
|
|
1464
|
+
|
|
1443
1465
|
## add-path-arg-to-match
|
|
1444
1466
|
|
|
1445
1467
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/35189d0e47c6ad1ca369e5a9287a34c1/d5fa7513a44fecc86beabd1faa8542bee7bc3e5e).
|
|
@@ -2092,7 +2114,7 @@ import {tryCatch} from 'try-catch';
|
|
|
2092
2114
|
transform(ast, source, options);
|
|
2093
2115
|
findPlaces(ast, source, options);
|
|
2094
2116
|
|
|
2095
|
-
tryCatch(transform, ast, source {});
|
|
2117
|
+
tryCatch(transform, ast, source, {});
|
|
2096
2118
|
|
|
2097
2119
|
tryCatch(findPlaces, ast, source, resultOptions);
|
|
2098
2120
|
```
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const check = ({__a}) => {
|
|
5
|
-
if (__a.body)
|
|
6
|
-
return __a.body.length > 0;
|
|
7
|
-
|
|
8
|
-
return compare(__a, 'path.__()');
|
|
9
|
-
};
|
|
3
|
+
const {addArgs} = operator;
|
|
10
4
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
export const {
|
|
6
|
+
report,
|
|
7
|
+
fix,
|
|
8
|
+
traverse,
|
|
9
|
+
} = addArgs({
|
|
10
|
+
path: ['path', {
|
|
11
|
+
include: [
|
|
12
|
+
'export const fix = () => __body',
|
|
13
|
+
'export const fix = () => path.__(__args)',
|
|
14
|
+
'module.exports.fix = () => __body',
|
|
15
|
+
'module.exports.fix = () => path.__(__args)',
|
|
16
|
+
],
|
|
17
|
+
}],
|
|
21
18
|
});
|
|
@@ -2,20 +2,19 @@ import {operator} from 'putout';
|
|
|
2
2
|
|
|
3
3
|
const {addArgs} = operator;
|
|
4
4
|
|
|
5
|
-
const INCLUDE = [
|
|
6
|
-
'(__a) => __body',
|
|
7
|
-
'() => __body',
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
const EXCLUDE = [
|
|
11
|
-
'export const filter = __a',
|
|
12
|
-
'module.exports.filter = __a',
|
|
13
|
-
];
|
|
14
|
-
|
|
15
5
|
export const {
|
|
16
6
|
report,
|
|
17
7
|
fix,
|
|
18
8
|
traverse,
|
|
19
9
|
} = addArgs({
|
|
20
|
-
path: ['vars, path',
|
|
10
|
+
path: ['vars, path', {
|
|
11
|
+
include: [
|
|
12
|
+
'(__a) => __body',
|
|
13
|
+
'() => __body',
|
|
14
|
+
],
|
|
15
|
+
exclude: [
|
|
16
|
+
'export const filter = __a',
|
|
17
|
+
'module.exports.filter = __a',
|
|
18
|
+
],
|
|
19
|
+
}],
|
|
21
20
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {addArgs} = operator;
|
|
4
|
+
|
|
5
|
+
export const {
|
|
6
|
+
report,
|
|
7
|
+
fix,
|
|
8
|
+
traverse,
|
|
9
|
+
} = addArgs({
|
|
10
|
+
path: ['path', {
|
|
11
|
+
include: [
|
|
12
|
+
'export const filter = () => __body',
|
|
13
|
+
'module.exports.filter = () => __body',
|
|
14
|
+
],
|
|
15
|
+
}],
|
|
16
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as addPathToFilter from './add-path-to-filter/index.js';
|
|
1
2
|
import * as removeUselessSourceArgument from './remove-useless-source-argument/index.js';
|
|
2
3
|
import * as applyTraverserToIgnore from './apply-traverser-to-ignore/index.js';
|
|
3
4
|
import * as addPathArgToMatch from './add-path-arg-to-match/index.js';
|
|
@@ -164,4 +165,5 @@ export const rules = {
|
|
|
164
165
|
'add-path-arg-to-match': addPathArgToMatch,
|
|
165
166
|
'apply-traverser-to-ignore': applyTraverserToIgnore,
|
|
166
167
|
'remove-useless-source-argument': removeUselessSourceArgument,
|
|
168
|
+
'add-path-to-filter': addPathToFilter,
|
|
167
169
|
};
|
package/package.json
CHANGED