@putout/plugin-printer 8.21.0 → 8.22.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 +30 -0
- package/lib/apply-printer-declarations/index.js +1 -0
- package/lib/declare-nearby/index.js +11 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ npm i @putout/plugin-printer -D
|
|
|
27
27
|
- ✅ [check-if-success-possible-in-type-checker](#check-if-success-possible-in-type-checker);
|
|
28
28
|
- ✅ [merge-tuple-of-type-checker](#merge-tuple-of-type-checker);
|
|
29
29
|
- ✅ [declare](#declare);
|
|
30
|
+
- ✅ [declare-nearby](#declare-nearby);
|
|
30
31
|
- ✅ [remove-args](#remove-args);
|
|
31
32
|
- ✅ [remove-useless-maybe](#remove-useless-maybe);
|
|
32
33
|
- ✅ [remove-useless-print](#remove-useless-print);
|
|
@@ -58,6 +59,7 @@ npm i @putout/plugin-printer -D
|
|
|
58
59
|
"printer/check-type-passed-to-type-checker": "on",
|
|
59
60
|
"printer/check-if-success-possible-in-type-checker": "on",
|
|
60
61
|
"printer/declare": "on",
|
|
62
|
+
"printer/declare-nearby": "on",
|
|
61
63
|
"printer/merge-tuple-of-type-checker": "on",
|
|
62
64
|
"printer/remove-args": "on",
|
|
63
65
|
"printer/remove-useless-maybe": "on",
|
|
@@ -543,6 +545,34 @@ test('', (t) => {
|
|
|
543
545
|
});
|
|
544
546
|
```
|
|
545
547
|
|
|
548
|
+
## declare-nearby
|
|
549
|
+
|
|
550
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/03d729e40ffd352678cdcc92a1cb7e2d/33a3d522247db4a1dd6d34b035176f26fc020ca8).
|
|
551
|
+
|
|
552
|
+
### ❌ Example of incorrect code
|
|
553
|
+
|
|
554
|
+
```js
|
|
555
|
+
export const FunctionDeclaration = {
|
|
556
|
+
print(path, printer, semantics) {
|
|
557
|
+
const {print} = printer;
|
|
558
|
+
|
|
559
|
+
indent();
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### ✅ Example of correct code
|
|
565
|
+
|
|
566
|
+
```js
|
|
567
|
+
export const FunctionDeclaration = {
|
|
568
|
+
print(path, printer, semantics) {
|
|
569
|
+
const {indent, print} = printer;
|
|
570
|
+
|
|
571
|
+
indent();
|
|
572
|
+
},
|
|
573
|
+
};
|
|
574
|
+
```
|
|
575
|
+
|
|
546
576
|
## merge-tuple-of-type-checker
|
|
547
577
|
|
|
548
578
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/7351b8359ac3da967e9b4b80d49b51da/74de1543f6e129f6e22f38e2eb597abce6c122a6).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const options = {
|
|
2
|
+
nearby: true,
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export const declare = () => ({
|
|
6
|
+
indent: ['const {indent} = printer', options],
|
|
7
|
+
print: ['const {print} = printer', options],
|
|
8
|
+
write: ['const {write} = printer', options],
|
|
9
|
+
traverse: ['const {traverse} = printer', options],
|
|
10
|
+
maybe: ['const {maybe} = printer', options],
|
|
11
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as declareNearby from './declare-nearby/index.js';
|
|
1
2
|
import * as applyPrinterDeclarations from './apply-printer-declarations/index.js';
|
|
2
3
|
import * as removeUselessPrint from './remove-useless-print/index.js';
|
|
3
4
|
import * as addMissingArrowToTypeChecker from './add-missing-arrow-to-type-checker/index.js';
|
|
@@ -54,4 +55,5 @@ export const rules = {
|
|
|
54
55
|
'remove-useless-arrow-from-type-checker': removeUselessArrowFromTypeChecker,
|
|
55
56
|
'add-missing-arrow-to-type-checker': addMissingArrowToTypeChecker,
|
|
56
57
|
'remove-useless-print': removeUselessPrint,
|
|
58
|
+
'declare-nearby': declareNearby,
|
|
57
59
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-printer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds support of transformations for @putout/printer",
|