@putout/plugin-putout 29.1.0 → 29.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
|
@@ -88,6 +88,7 @@ npm i @putout/plugin-putout -D
|
|
|
88
88
|
- ✅ [remove-empty-object-from-transform](#remove-empty-object-from-transform);
|
|
89
89
|
- ✅ [remove-unused-get-properties-argument](#remove-unused-get-properties-argument);
|
|
90
90
|
- ✅ [remove-useless-printer-option](#remove-useless-printer-option);
|
|
91
|
+
- ✅ [remove-useless-source-argument](#remove-useless-source-argument);
|
|
91
92
|
- ✅ [remove-message-from-no-report-after-transform](#remove-message-from-no-report-after-transform);
|
|
92
93
|
- ✅ [rename-operate-to-operator](#rename-operate-to-operator);
|
|
93
94
|
- ✅ [replace-operate-with-operator](#replace-operate-with-operator);
|
|
@@ -178,6 +179,7 @@ npm i @putout/plugin-putout -D
|
|
|
178
179
|
"putout/remove-empty-array-from-process": "on",
|
|
179
180
|
"putout/remove-empty-object-from-transform": "on",
|
|
180
181
|
"putout/remove-useless-printer-option": "on",
|
|
182
|
+
"putout/remove-useless-source-argument": "on",
|
|
181
183
|
"putout/remove-message-from-no-report-after-transform": "on",
|
|
182
184
|
"putout/simplify-replace-template": "on"
|
|
183
185
|
}
|
|
@@ -2078,6 +2080,36 @@ const test = createTest(__dirname, {
|
|
|
2078
2080
|
});
|
|
2079
2081
|
```
|
|
2080
2082
|
|
|
2083
|
+
## remove-useless-source-argument
|
|
2084
|
+
|
|
2085
|
+
Check it out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9b5f94d6a60f3337f925fcc338370d83/0f47ee0e979ae4ea27007c2f9751a1376b36de01).
|
|
2086
|
+
|
|
2087
|
+
### ❌ Example of incorrect code
|
|
2088
|
+
|
|
2089
|
+
```js
|
|
2090
|
+
import {tryCatch} from 'try-catch';
|
|
2091
|
+
|
|
2092
|
+
transform(ast, options);
|
|
2093
|
+
findPlaces(ast, options);
|
|
2094
|
+
|
|
2095
|
+
tryCatch(transform, ast, {});
|
|
2096
|
+
|
|
2097
|
+
tryCatch(findPlaces, ast, resultOptions);
|
|
2098
|
+
```
|
|
2099
|
+
|
|
2100
|
+
### ✅ Example of correct code
|
|
2101
|
+
|
|
2102
|
+
```js
|
|
2103
|
+
import {tryCatch} from 'try-catch';
|
|
2104
|
+
|
|
2105
|
+
transform(ast, options);
|
|
2106
|
+
findPlaces(ast, options);
|
|
2107
|
+
|
|
2108
|
+
tryCatch(transform, ast, {});
|
|
2109
|
+
|
|
2110
|
+
tryCatch(findPlaces, ast, resultOptions);
|
|
2111
|
+
```
|
|
2112
|
+
|
|
2081
2113
|
## simplify-replace-template
|
|
2082
2114
|
|
|
2083
2115
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a012fc12f4d38038da022f7c8f379fe2/c65bf97c42650aa31c5481849bc934323df892a6).
|
|
@@ -114,7 +114,7 @@ const createTraverseReplacer = ({once, push}) => (path) => {
|
|
|
114
114
|
isTS: true,
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
const [transformError] = tryCatch(transform, ast,
|
|
117
|
+
const [transformError] = tryCatch(transform, ast, {
|
|
118
118
|
plugins: [
|
|
119
119
|
['evaluate', {
|
|
120
120
|
report: noop,
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as removeUselessSourceArgument from './remove-useless-source-argument/index.js';
|
|
1
2
|
import * as applyTraverserToIgnore from './apply-traverser-to-ignore/index.js';
|
|
2
3
|
import * as addPathArgToMatch from './add-path-arg-to-match/index.js';
|
|
3
4
|
import * as removeMessageFromNoReportAfterTransform from './remove-message-from-no-report-after-transform/index.js';
|
|
@@ -162,4 +163,5 @@ export const rules = {
|
|
|
162
163
|
'remove-message-from-no-report-after-transform': removeMessageFromNoReportAfterTransform,
|
|
163
164
|
'add-path-arg-to-match': addPathArgToMatch,
|
|
164
165
|
'apply-traverser-to-ignore': applyTraverserToIgnore,
|
|
166
|
+
'remove-useless-source-argument': removeUselessSourceArgument,
|
|
165
167
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {types} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {isObjectProperty} = types;
|
|
4
|
+
|
|
5
|
+
export const report = () => `Avoid useless 'source' argument`;
|
|
6
|
+
|
|
7
|
+
export const filter = (path) => !isObjectProperty(path.parentPath);
|
|
8
|
+
|
|
9
|
+
export const replace = () => ({
|
|
10
|
+
'findPlaces(__a, __b, __c)': 'findPlaces(__a, __c)',
|
|
11
|
+
'transform(__a, __b, __c)': 'transform(__a, __c)',
|
|
12
|
+
'tryCatch(transform, __a, __b, __c)': 'tryCatch(transform, __a, __c)',
|
|
13
|
+
'tryCatch(findPlaces, __a, __b, __c)': 'tryCatch(findPlaces, __a, __c)',
|
|
14
|
+
});
|
package/package.json
CHANGED