@putout/plugin-putout 21.7.0 → 22.1.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 +28 -0
- package/lib/declare/index.js +2 -1
- package/lib/declare/types.json +0 -2
- package/lib/index.js +2 -0
- package/lib/remove-useless-printer-option/index.js +35 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ npm i @putout/plugin-putout -D
|
|
|
62
62
|
- ✅ [move-require-on-top-level](#move-require-on-top-level);
|
|
63
63
|
- ✅ [remove-empty-array-from-process](#remove-empty-array-from-process);
|
|
64
64
|
- ✅ [remove-unused-get-properties-argument](#remove-unused-get-properties-argument);
|
|
65
|
+
- ✅ [remove-useless-printer-option](#remove-useless-printer-option);
|
|
65
66
|
- ✅ [rename-operate-to-operator](#rename-operate-to-operator);
|
|
66
67
|
- ✅ [replace-operate-with-operator](#replace-operate-with-operator);
|
|
67
68
|
- ✅ [replace-test-message](#replace-test-message);
|
|
@@ -125,6 +126,7 @@ npm i @putout/plugin-putout -D
|
|
|
125
126
|
"putout/replace-test-message": "on",
|
|
126
127
|
"putout/remove-unused-get-properties-argument": "on",
|
|
127
128
|
"putout/remove-empty-array-from-process": "on",
|
|
129
|
+
"putout/remove-useless-printer-option": "on",
|
|
128
130
|
"putout/simplify-replace-template": "on"
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -1345,6 +1347,32 @@ const {
|
|
|
1345
1347
|
} = getProperties(__jsonPath, ['parser', 'rules', 'extends']);
|
|
1346
1348
|
```
|
|
1347
1349
|
|
|
1350
|
+
## remove-useless-printer-option
|
|
1351
|
+
|
|
1352
|
+
Check it out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f176313cf67fd6d7138470385511319f/5b26aa45db21f250016d228b7bbabbb3c10b582b).
|
|
1353
|
+
`putout` printer used by default, so there is no need to pass it.
|
|
1354
|
+
|
|
1355
|
+
### ❌ Example of incorrect code
|
|
1356
|
+
|
|
1357
|
+
```js
|
|
1358
|
+
const test = createTest(__dirname, {
|
|
1359
|
+
printer: 'putout',
|
|
1360
|
+
plugins: [
|
|
1361
|
+
['remove-unchanged-zero-declarations', plugin],
|
|
1362
|
+
],
|
|
1363
|
+
});
|
|
1364
|
+
```
|
|
1365
|
+
|
|
1366
|
+
### ✅ Example of correct code
|
|
1367
|
+
|
|
1368
|
+
```js
|
|
1369
|
+
const test = createTest(__dirname, {
|
|
1370
|
+
plugins: [
|
|
1371
|
+
['remove-unchanged-zero-declarations', plugin],
|
|
1372
|
+
],
|
|
1373
|
+
});
|
|
1374
|
+
```
|
|
1375
|
+
|
|
1348
1376
|
## simplify-replace-template
|
|
1349
1377
|
|
|
1350
1378
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a012fc12f4d38038da022f7c8f379fe2/c65bf97c42650aa31c5481849bc934323df892a6).
|
package/lib/declare/index.js
CHANGED
|
@@ -5,9 +5,10 @@ const operator = require('./operator');
|
|
|
5
5
|
const {getRule} = require('./get-rule');
|
|
6
6
|
|
|
7
7
|
module.exports.declare = () => ({
|
|
8
|
+
types: `import {types} from 'putout'`,
|
|
9
|
+
...types,
|
|
8
10
|
template: `import {template} from 'putout'`,
|
|
9
11
|
createTest: `import {createTest} from '@putout/test'`,
|
|
10
12
|
...operator,
|
|
11
|
-
...types,
|
|
12
13
|
getRule: `const getRule = ${getRule.toString()};`,
|
|
13
14
|
});
|
package/lib/declare/types.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"types": "import {types} from 'putout'",
|
|
3
2
|
"AnyTypeAnnotation": "const {AnyTypeAnnotation} = types",
|
|
4
3
|
"ArgumentPlaceholder": "const {ArgumentPlaceholder} = types",
|
|
5
4
|
"ArrayExpression": "const {ArrayExpression} = types",
|
|
@@ -253,7 +252,6 @@
|
|
|
253
252
|
"WhileStatement": "const {WhileStatement} = types",
|
|
254
253
|
"WithStatement": "const {WithStatement} = types",
|
|
255
254
|
"YieldExpression": "const {YieldExpression} = types",
|
|
256
|
-
"is": "const {is} = types",
|
|
257
255
|
"isAccessor": "const {isAccessor} = types",
|
|
258
256
|
"isAnyTypeAnnotation": "const {isAnyTypeAnnotation} = types",
|
|
259
257
|
"isArgumentPlaceholder": "const {isArgumentPlaceholder} = types",
|
package/lib/index.js
CHANGED
|
@@ -54,6 +54,7 @@ const removeEmptyArrayFromProcess = require('./remove-empty-array-from-process')
|
|
|
54
54
|
const addPlacesToComparePlaces = require('./add-places-to-compare-places');
|
|
55
55
|
const addPathArgToFix = require('./add-path-arg-to-fix');
|
|
56
56
|
const convertIncludeToTraverse = require('./convert-include-to-traverse');
|
|
57
|
+
const removeUselessPrinterOption = require('./remove-useless-printer-option');
|
|
57
58
|
|
|
58
59
|
module.exports.rules = {
|
|
59
60
|
'apply-processors-destructuring': applyProcessorsDestructuring,
|
|
@@ -110,4 +111,5 @@ module.exports.rules = {
|
|
|
110
111
|
'add-places-to-compare-places': addPlacesToComparePlaces,
|
|
111
112
|
'add-path-arg-to-fix': addPathArgToFix,
|
|
112
113
|
'convert-include-to-traverse': convertIncludeToTraverse,
|
|
114
|
+
'remove-useless-printer-option': removeUselessPrinterOption,
|
|
113
115
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {operator, types} = require('putout');
|
|
4
|
+
const {
|
|
5
|
+
isCallExpression,
|
|
6
|
+
isIdentifier,
|
|
7
|
+
} = types;
|
|
8
|
+
const {remove} = operator;
|
|
9
|
+
|
|
10
|
+
module.exports.report = () => `Avoid useless 'printer' option`;
|
|
11
|
+
|
|
12
|
+
module.exports.fix = (path) => {
|
|
13
|
+
remove(path);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports.traverse = ({push}) => ({
|
|
17
|
+
ObjectProperty(path) {
|
|
18
|
+
const {value} = path.node;
|
|
19
|
+
|
|
20
|
+
if (value.value !== 'putout')
|
|
21
|
+
return;
|
|
22
|
+
|
|
23
|
+
const {parentPath} = path.parentPath;
|
|
24
|
+
|
|
25
|
+
if (!isCallExpression(parentPath))
|
|
26
|
+
return;
|
|
27
|
+
|
|
28
|
+
const name = 'createTest';
|
|
29
|
+
|
|
30
|
+
if (!isIdentifier(parentPath.node.callee, {name}))
|
|
31
|
+
return;
|
|
32
|
+
|
|
33
|
+
push(path);
|
|
34
|
+
},
|
|
35
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.1.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",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout#readme",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./lib/index.js",
|
|
11
|
+
"./declare/types": "./lib/declare/types.json"
|
|
12
|
+
},
|
|
9
13
|
"release": false,
|
|
10
14
|
"tag": false,
|
|
11
15
|
"changelog": false,
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
"supertape": "^10.0.0"
|
|
55
59
|
},
|
|
56
60
|
"peerDependencies": {
|
|
57
|
-
"putout": ">=
|
|
61
|
+
"putout": ">=37"
|
|
58
62
|
},
|
|
59
63
|
"license": "MIT",
|
|
60
64
|
"engines": {
|