@putout/plugin-printer 8.23.1 β†’ 9.0.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
@@ -5,6 +5,8 @@
5
5
 
6
6
  🐊[**Putout**](https://github.com/coderaiser/putout) adds support of transformations for [`@putout/printer`](https://github.com/putoutjs/printer).
7
7
 
8
+ > Type-checker rules moved to [`@putout/plugin-type-checker`](https://github.com/coderaiser/putout/tree/master/packages/plugin-type-checker#readme).
9
+
8
10
  ## Install
9
11
 
10
12
  ```
@@ -14,32 +16,18 @@ npm i @putout/plugin-printer -D
14
16
  ## Rules
15
17
 
16
18
  - βœ… [add-args](#add-args);
17
- - βœ… [add-missing-spaces-to-type-checker](#add-missing-spaces-to-type-checker);
18
- - βœ… [add-missing-colon-to-type-checker](#add-missing-spaces-to-type-checker);
19
- - βœ… [add-missing-tuples-to-type-checker](#add-missing-tuples-to-type-checker);
20
19
  - βœ… [apply-breakline](#apply-breakline);
21
20
  - βœ… [apply-computed-print](#apply-computed-print);
22
21
  - βœ… [apply-create-test-url](#apply-create-test-url);
23
22
  - βœ… [apply-linebreak](#apply-linebreak);
24
23
  - βœ… [apply-printer-declarations](#apply-printer-declarations);
25
24
  - βœ… [apply-types](#apply-types);
26
- - βœ… [check-type-passed-to-type-checker](#check-type-passed-to-type-checker);
27
- - βœ… [check-if-success-possible-in-type-checker](#check-if-success-possible-in-type-checker);
28
25
  - βœ… [declare](#declare);
29
26
  - βœ… [declare-nearby](#declare-nearby);
30
- - βœ… [merge-tuple-of-type-checker](#merge-tuple-of-type-checker);
31
27
  - βœ… [remove-args](#remove-args);
28
+ - βœ… [remove-legacy-test-declaration](#remove-legacy-test-declaration);
32
29
  - βœ… [remove-useless-maybe](#remove-useless-maybe);
33
30
  - βœ… [remove-useless-print](#remove-useless-print);
34
- - βœ… [remove-legacy-test-declaration](#remove-legacy-test-declaration);
35
- - βœ… [remove-trailing-spaces-from-type-checker](#remove-trailing-spaces-from-type-checker);
36
- - βœ… [remove-useless-spaces-from-type-checker](#remove-useless-spaces-from-type-checker);
37
- - βœ… [remove-useless-arrow-from-type-checker](#remove-useless-arrow-from-type-checker);
38
- - βœ… [remove-useless-colon-from-type-checker](#remove-useless-colon-from-type-checker);
39
- - βœ… [remove-useless-tuples-from-type-checker](#remove-useless-tuples-from-type-checker);
40
- - βœ… [remove-useless-not-from-type-checker](#remove-useless-not-from-type-checker);
41
- - βœ… [remove-useless-path-from-type-checker](#remove-useless-path-from-type-checker);
42
- - βœ… [reverse-comparison-in-type-checker](#reverse-comparison-in-type-checker);
43
31
 
44
32
  ## Config
45
33
 
@@ -47,91 +35,21 @@ npm i @putout/plugin-printer -D
47
35
  {
48
36
  "rules": {
49
37
  "printer/add-args": "on",
50
- "printer/add-missing-tuples-to-type-checker": "on",
51
- "printer/add-missing-colon-to-type-checker": "on",
52
- "printer/add-missing-spaces-to-type-checker": "on",
53
38
  "printer/apply-breakline": "on",
54
- "printer/apply-linebreak": "on",
55
39
  "printer/apply-computed-print": "on",
56
40
  "printer/apply-create-test-url": "on",
41
+ "printer/apply-linebreak": "on",
57
42
  "printer/apply-printer-declarations": "on",
58
43
  "printer/apply-types": "on",
59
- "printer/check-type-passed-to-type-checker": "on",
60
- "printer/check-if-success-possible-in-type-checker": "on",
61
44
  "printer/declare": "on",
62
45
  "printer/declare-nearby": "on",
63
- "printer/merge-tuple-of-type-checker": "on",
64
46
  "printer/remove-args": "on",
65
47
  "printer/remove-useless-maybe": "on",
66
- "printer/remove-trailing-spaces-from-type-checker": "on",
67
- "printer/remove-useless-spaces-from-type-checker": "on",
68
- "printer/remove-useless-arrow-from-type-checker": "on",
69
- "printer/remove-useless-colon-from-type-checker": "on",
70
- "printer/remove-useless-not-from-type-checker": "on",
71
- "printer/remove-useless-path-from-type-checker": "on",
72
- "printer/remove-useless-tuples-from-type-checker": "on",
73
- "printer/remove-useless-print": "on",
74
- "printer/reverse-comparison-in-type-checker": "on"
48
+ "printer/remove-useless-print": "on"
75
49
  }
76
50
  }
77
51
  ```
78
52
 
79
- ## apply-breakline
80
-
81
- ```diff
82
- -print.newline();
83
- -indent();
84
- print.breakline();
85
- ```
86
-
87
- ## apply-linebreak;
88
-
89
- ```diff
90
- -indent();
91
- -print.newline();
92
- print.linebreak();
93
- ```
94
-
95
- ## apply-printer-declarations
96
-
97
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2fc66c476a235eb25f47e55fd7b33042/b0371fe2dd62e8f9fe5ce1fff6d352386e69fcc6).
98
-
99
- ### ❌ Example of incorrect code
100
-
101
- ```js
102
- export const ExportNamedDeclaration = (path, printer, {indent}) => {
103
- const {print, write} = printer;
104
- const {leadingComments} = path.node;
105
-
106
- indent();
107
- };
108
- ```
109
-
110
- ### βœ… Example of correct code
111
-
112
- ```js
113
- export const ExportNamedDeclaration = (path, printer) => {
114
- const {leadingComments} = path.node;
115
- const {
116
- print,
117
- write,
118
- indent,
119
- } = printer;
120
-
121
- indent();
122
- };
123
- ```
124
-
125
- ## apply-types
126
-
127
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8a88fec812a52e302cf7b191eca2f49e/474ca87860d2eab755373ba9dc8b12efc4a80252).
128
-
129
- ```diff
130
- -const {isIdentifier} = require('@babel/types');
131
- +const {types} = require('@babel/types');
132
- +const {isIdentifier} = types;
133
- ```
134
-
135
53
  ## add-args
136
54
 
137
55
  ### ❌ Example of incorrect code
@@ -158,76 +76,20 @@ module.exports = {
158
76
  };
159
77
  ```
160
78
 
161
- ## add-missing-spaces-to-type-checker
162
-
163
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2451cd51ebd3dfd20c32b6d22ca176b7/bd593860ff4bb2d66e06cf95bbe103cb1203129d).
164
-
165
- ### ❌ Example of incorrect code
166
-
167
- ```js
168
- export const beforeIf = createTypeChecker([
169
- ['-:->!', isInsideArray],
170
- ['-:parentPath->', isCoupleLines],
171
- ]);
172
- ```
173
-
174
- ### βœ… Example of correct code
175
-
176
- ```js
177
- export const beforeIf = createTypeChecker([
178
- ['-: -> !', isInsideArray],
179
- ['-: parentPath ->', isCoupleLines],
180
- ]);
181
- ```
182
-
183
- ## add-missing-colon-to-type-checker
184
-
185
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/97d38d9bee0586deb8c627c19e399a27/889646df2dcfcfe86f7eb0efb6e3ed5791701f58).
186
-
187
- ### ❌ Example of incorrect code
188
-
189
- ```js
190
- export const beforeIf = createTypeChecker([
191
- ['+ -> !', isInsideArray],
192
- ['- parentPath ->', isCoupleLines],
193
- ]);
194
- ```
195
-
196
- ### βœ… Example of correct code
197
-
198
- ```js
199
- export const beforeIf = createTypeChecker([
200
- ['+: -> !', isInsideArray],
201
- ['-: parentPath ->', isCoupleLines],
202
- ]);
203
- ```
204
-
205
- ## add-missing-tuple-to-type-checker
206
-
207
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9fdfda423df3af9b0f08541710706299/0259bba117997861fe7573bad5477282f4df8554).
208
-
209
- ### ❌ Example of incorrect code
79
+ ## apply-linebreak;
210
80
 
211
- ```js
212
- export const beforeIf = createTypeChecker([
213
- '- : -> !StringLiteral',
214
- '- : -> BlockStatement',
215
- '- : -> WrongType',
216
- ['- : ->', isBlockStatement],
217
- ['-', isBlockStatement],
218
- ]);
81
+ ```diff
82
+ -indent();
83
+ -print.newline();
84
+ print.linebreak();
219
85
  ```
220
86
 
221
- ### βœ… Example of correct code
87
+ ## apply-breakline
222
88
 
223
- ```js
224
- export const beforeIf = createTypeChecker([
225
- ['- : -> !StringLiteral'],
226
- ['- : -> BlockStatement'],
227
- ['- : -> WrongType'],
228
- ['- : ->', isBlockStatement],
229
- ['-', isBlockStatement],
230
- ]);
89
+ ```diff
90
+ -print.newline();
91
+ -indent();
92
+ print.breakline();
231
93
  ```
232
94
 
233
95
  ## apply-computed-print
@@ -235,15 +97,21 @@ export const beforeIf = createTypeChecker([
235
97
  ### ❌ Example of incorrect code
236
98
 
237
99
  ```js
238
- print(path.get('block'));
100
+ export const TryStatement = (path, {print}) => {
101
+ print(path.get('block'));
102
+ };
239
103
  ```
240
104
 
241
105
  ### βœ… Example of correct code
242
106
 
243
107
  ```js
244
- print('__block');
108
+ export const TryStatement = (path, {print}) => {
109
+ print('__block');
110
+ };
245
111
  ```
246
112
 
113
+ The rule changes only the `print` of a printer visitor (a parameter). Imported `print` of `putout` needs a path and stays as is.
114
+
247
115
  ## apply-create-test-url
248
116
 
249
117
  Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ddf1425ace2a53e9010b82ded1dd1012/3e56365b58d01ebe8abba46caf04ed5e51043feb).
@@ -264,257 +132,44 @@ import {createTest} from '#test';
264
132
  const {test, fixture} = createTest(import.meta.url);
265
133
  ```
266
134
 
267
- ## remove-args
268
-
269
- ### ❌ Example of incorrect code
270
-
271
- ```js
272
- print.indent(is);
273
- ```
274
-
275
- ### βœ… Example of correct code
276
-
277
- ```js
278
- print.indent();
279
- ```
280
-
281
- ## remove-useless-maybe
282
-
283
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/d448a928400ff37043ae03510ce7c85c/db1a758809e8759f591533f9ef92bef1188d32b0).
284
-
285
- ### ❌ Example of incorrect code
286
-
287
- ```js
288
- maybe.print.linebreak(wasNewline);
289
- maybe.print.newline(!wasNewline);
290
- ```
291
-
292
- ### βœ… Example of correct code
293
-
294
- ```js
295
- maybe.indent(wasNewline);
296
- print.newline();
297
- ```
298
-
299
- ## remove-useless-spaces-from-type-checker
300
-
301
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2e90aa74898a496b488f9c369801b47a/fbd700d965952e80588ec61054b3ed7aee4d17a2).
302
-
303
- ### ❌ Example of incorrect code
304
-
305
- ```js
306
- export const beforeIf = createTypeChecker([
307
- ['- : -> !', isInsideArray],
308
- ]);
309
- ```
310
-
311
- ### βœ… Example of correct code
312
-
313
- ```js
314
- export const beforeIf = createTypeChecker([
315
- ['-: -> !', isInsideArray],
316
- ]);
317
- ```
318
-
319
- ## remove-useless-arrow-from-type-checker
320
-
321
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/c12c37b793192eadb60fac332d95cc3b/3f4aa557c65897f4967712f30e51c29483feddc8).
322
-
323
- ### ❌ Example of incorrect code
324
-
325
- ```js
326
- const isTwoLongStringsInsideArray = createTypeChecker([
327
- ['-: -> !', isTwoLongStrings],
328
- ['+: parentPath -> -> ArrayExpression'],
329
- ]);
330
- ```
331
-
332
- ### βœ… Example of correct code
333
-
334
- ```js
335
- const isTwoLongStringsInsideArray = createTypeChecker([
336
- ['-: -> !', isTwoLongStrings],
337
- ['+: parentPath -> ArrayExpression'],
338
- ]);
339
- ```
340
-
341
- ## remove-useless-colon-from-type-checker
342
-
343
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/49a35399bd43d56bfd0221b3a0ace3b0/3ff3bdc8cb5f2a06786e9b616252d1b5f506dd73).
344
-
345
- ### ❌ Example of incorrect code
346
-
347
- ```js
348
- export const beforeIf = createTypeChecker([
349
- ['+:', isInsideArray],
350
- ['-:', isCoupleLines],
351
- ]);
352
- ```
353
-
354
- ### βœ… Example of correct code
355
-
356
- ```js
357
- export const beforeIf = createTypeChecker([
358
- ['+', isInsideArray],
359
- ['-', isCoupleLines],
360
- ]);
361
- ```
362
-
363
- ## remove-useless-not-from-type-checker
364
-
365
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/051b981021fd1e048b675106f0850211/2022b9797125016d4e5c5e6b5d4e066ab2e103ad).
366
-
367
- ### ❌ Example of incorrect code
368
-
369
- ```js
370
- export const beforeIf = createTypeChecker([
371
- ['-: -> !+'],
372
- ['+: -> !-'],
373
- ]);
374
- ```
375
-
376
- ### βœ… Example of correct code
377
-
378
- ```js
379
- export const beforeIf = createTypeChecker([
380
- ['-: -> -'],
381
- ['+: -> +'],
382
- ]);
383
- ```
384
-
385
- ## remove-useless-path-from-type-checker
386
-
387
- Selector always starts from `path`, so it can be `parentPath.`, or `node.`, but never `path.`, since it is self reference.
388
-
389
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ef8e1dc1036a4a2fcc99b32c3dc661e2/bc43a082dc9cb5ed8a8afe6964174f0d1be2e1c1).
390
-
391
- ### ❌ Example of incorrect code
392
-
393
- ```js
394
- export const beforeIf = createTypeChecker([
395
- ['-: path.parentPath -> ', isCoupleLines],
396
- ]);
397
- ```
398
-
399
- ### βœ… Example of correct code
400
-
401
- ```js
402
- export const beforeIf = createTypeChecker([
403
- ['-: parentPath -> ', isCoupleLines],
404
- ]);
405
- ```
406
-
407
- ## remove-useless-tuples-from-type-checker
408
-
409
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f53f386b607115e0a96f7e294e34761e/cefd72aba4fcade59bbf8faa59739bac5c2fe057).
410
-
411
- ### ❌ Example of incorrect code
412
-
413
- ```js
414
- export const allStrings = createTypeChecker([
415
- ['- : -> BlockStatement'],
416
- ['- : -> WrongType'],
417
- ]);
418
- ```
419
-
420
- ### βœ… Example of correct code
421
-
422
- ```js
423
- export const allStrings = createTypeChecker([
424
- '- : -> BlockStatement',
425
- '- : -> WrongType',
426
- ]);
427
- ```
428
-
429
- ## remove-trailing-spaces-from-type-checker
430
-
431
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/91d33e39485c31e76b534ad8447ba4db/abca8d21ad6edc1f6fed23edb05fa166677f11d6).
432
-
433
- ### ❌ Example of incorrect code
434
-
435
- ```js
436
- export const beforeIf = createTypeChecker([
437
- ['-: parentPath -> ', isCoupleLines],
438
- ]);
439
- ```
440
-
441
- ### βœ… Example of correct code
442
-
443
- ```js
444
- export const beforeIf = createTypeChecker([
445
- ['-: parentPath ->', isCoupleLines],
446
- ]);
447
- ```
448
-
449
- ## check-if-success-possible-in-type-checker
450
-
451
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/4164addec1e1b2bb93ad7caf3ed13ad8/b04dc172f4094ea6b6902ec54deee779aba6b944).
452
- When you have only negative branch defined in type checker it never never succeeds (`+`), and always returns false.
453
-
454
- Consider adding success branch, or remove type checker.
135
+ ## apply-printer-declarations
455
136
 
456
- ☝️ *This rule has no autofix, because most likely tests will fail after auto fix,
457
- and instead of observing code with a problem, you will first see failed tests,
458
- and then after some searches determine that there is a wrong auto fix.*
137
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2fc66c476a235eb25f47e55fd7b33042/b0371fe2dd62e8f9fe5ce1fff6d352386e69fcc6).
459
138
 
460
139
  ### ❌ Example of incorrect code
461
140
 
462
141
  ```js
463
- const isSimple = createTypeChecker([
464
- '-: -> SpreadElement',
465
- '-: -> Identifier',
466
- '-: -> !CallExpression',
467
- ]);
468
-
469
- const isSimpleAfterObject = createTypeChecker([
470
- ['-', isSimple],
471
- ['-', callWithNext(isObjectExpression)],
472
- ['-', callWithPrev(isObjectExpression)],
473
- ]);
142
+ export const ExportNamedDeclaration = (path, printer, {indent}) => {
143
+ const {print, write} = printer;
144
+ const {leadingComments} = path.node;
145
+
146
+ indent();
147
+ };
474
148
  ```
475
149
 
476
150
  ### βœ… Example of correct code
477
151
 
478
- Possible fix:
479
-
480
152
  ```js
481
- const isSimple = createTypeChecker([
482
- '-: -> SpreadElement',
483
- '-: -> Identifier',
484
- '+: -> !CallExpression',
485
- ]);
486
-
487
- const isSimpleAfterObject = createTypeChecker([
488
- ['-', isSimple],
489
- ['-', callWithNext(isObjectExpression)],
490
- ['+', callWithPrev(isObjectExpression)],
491
- ]);
492
- ```
493
-
494
- ## check-type-passed-to-type-checker
495
-
496
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/9b35f5f2f23bece832f0f87c929d30e2/b08df8ef8ce6c2a03bceebe6119846c45a78a119).
497
-
498
- ☝️ *This rule has no autofix, because most likely tests will fail after auto fix,
499
- and instead of observing code with a problem, you will first see failed tests,
500
- and then after some searches determine that there is a wrong auto fix.*
501
-
502
- ### ❌ Example of incorrect code
503
-
504
- ```js
505
- export const beforeIf = createTypeChecker([
506
- ['- : -> WrongType'],
507
- ]);
153
+ export const ExportNamedDeclaration = (path, printer) => {
154
+ const {leadingComments} = path.node;
155
+ const {
156
+ print,
157
+ write,
158
+ indent,
159
+ } = printer;
160
+
161
+ indent();
162
+ };
508
163
  ```
509
164
 
510
- ### βœ… Example of correct code
165
+ ## apply-types
511
166
 
512
- Here is possible correct code:
167
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8a88fec812a52e302cf7b191eca2f49e/474ca87860d2eab755373ba9dc8b12efc4a80252).
513
168
 
514
- ```js
515
- export const beforeIf = createTypeChecker([
516
- ['- : -> Identifier'],
517
- ]);
169
+ ```diff
170
+ -const {isIdentifier} = require('@babel/types');
171
+ +const {types} = require('@babel/types');
172
+ +const {isIdentifier} = types;
518
173
  ```
519
174
 
520
175
  ## declare
@@ -573,54 +228,18 @@ export const FunctionDeclaration = {
573
228
  };
574
229
  ```
575
230
 
576
- ## merge-tuple-of-type-checker
577
-
578
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/7351b8359ac3da967e9b4b80d49b51da/74de1543f6e129f6e22f38e2eb597abce6c122a6).
579
-
580
- ### ❌ Example of incorrect code
581
-
582
- ```js
583
- export const isNewlineAfterComma = createTypeChecker([
584
- ['+: -> !', isObjectExpression],
585
- ['+: ->', isStringLiteral],
586
- ['+', isStringLiteral],
587
- ]);
588
- ```
589
-
590
- ### βœ… Example of correct code
591
-
592
- ```js
593
- export const isNewlineAfterComma = createTypeChecker([
594
- ['+: -> !ObjectExpression'],
595
- ['+: -> StringLiteral'],
596
- ['+: StringLiteral'],
597
- ]);
598
- ```
599
-
600
- ## reverse-comparison-in-type-checker
601
-
602
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ae2335d32022de240e918ce077144767/f25c5a11f746fe532f81adede991286cb77d1b11).
231
+ ## remove-args
603
232
 
604
233
  ### ❌ Example of incorrect code
605
234
 
606
235
  ```js
607
- const isMoreThenMaxElementLengthInOneLine = createTypeChecker([
608
- ['-: node.elements.length -> !', '<', 2],
609
- ['-: node.elements.length -> !', '>', 2],
610
- ['-: node.elements.length -> !', '>=', 2],
611
- ['-: node.elements.length -> !', '<=', 2],
612
- ]);
236
+ print.indent(is);
613
237
  ```
614
238
 
615
239
  ### βœ… Example of correct code
616
240
 
617
241
  ```js
618
- const isMoreThenMaxElementLengthInOneLine = createTypeChecker([
619
- ['-: node.elements.length', '>=', 2],
620
- ['-: node.elements.length', '<=', 2],
621
- ['-: node.elements.length', '<', 2],
622
- ['-: node.elements.length', '>', 2],
623
- ]);
242
+ print.indent();
624
243
  ```
625
244
 
626
245
  ## remove-legacy-test-declaration
@@ -636,30 +255,22 @@ const isMoreThenMaxElementLengthInOneLine = createTypeChecker([
636
255
  -});
637
256
  ```
638
257
 
639
- ## reverse-comparison-in-type-checker
258
+ ## remove-useless-maybe
640
259
 
641
- Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/be2bb33f5c7ac7b687c1fa856704bc73/e57fa5a3ded571adca03f5bdeb5a0f63a594aa81).
260
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/d448a928400ff37043ae03510ce7c85c/db1a758809e8759f591533f9ef92bef1188d32b0).
642
261
 
643
262
  ### ❌ Example of incorrect code
644
263
 
645
264
  ```js
646
- export const ExpressionStatement = {
647
- print(path, {indent, print}) {
648
- indent();
649
- print('__expression');
650
- print.newline();
651
- },
652
- };
265
+ maybe.print.linebreak(wasNewline);
266
+ maybe.print.newline(!wasNewline);
653
267
  ```
654
268
 
655
269
  ### βœ… Example of correct code
656
270
 
657
271
  ```js
658
- export const ExpressionStatement = (path, {indent, print}) => {
659
- indent();
660
- print('__expression');
661
- print.newline();
662
- };
272
+ maybe.indent(wasNewline);
273
+ print.newline();
663
274
  ```
664
275
 
665
276
  ## License
@@ -1,7 +1,18 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {getBinding} = operator;
1
4
  const {assign} = Object;
2
5
 
3
6
  export const report = () => `Use print('__path') instead of path.get(__path)`;
4
7
 
8
+ // 'print' of '@putout/printer' visitor is a param: '(path, {print}) => {}'
9
+ // 'print' of 'putout' is imported and needs a path
10
+ const isPrintParam = (path) => getBinding(path, 'print')?.kind === 'param';
11
+
12
+ export const match = () => ({
13
+ 'print(path.get(__a))': (vars, path) => isPrintParam(path),
14
+ });
15
+
5
16
  export const replace = () => ({
6
17
  'print(path.get(__a))': ({__a}) => {
7
18
  const {raw, value} = __a;
package/lib/index.js CHANGED
@@ -1,21 +1,6 @@
1
1
  import * as declareNearby from './declare-nearby/index.js';
2
2
  import * as applyPrinterDeclarations from './apply-printer-declarations/index.js';
3
3
  import * as removeUselessPrint from './remove-useless-print/index.js';
4
- import * as addMissingArrowToTypeChecker from './add-missing-arrow-to-type-checker/index.js';
5
- import * as removeUselessArrowFromTypeChecker from './remove-useless-arrow-from-type-checker/index.js';
6
- import * as removeUselessPathFromTypeChecker from './remove-useless-path-from-type-checker/index.js';
7
- import * as reverseComparisonInTypeChecker from './reverse-comparison-in-type-checker/index.js';
8
- import * as removeUselessNotFromTypeChecker from './remove-useless-not-from-type-checker/index.js';
9
- import * as removeUselessColonFromTypeChecker from './remove-useless-colon-from-type-checker/index.js';
10
- import * as addMissingColonToTypeChecker from './add-missing-colon-to-type-checker/index.js';
11
- import * as mergeTuplesOfTypeCheckers from './merge-tuples-of-type-checkers/index.js';
12
- import * as checkIfSuccessPossibleInTypeChecker from './check-if-success-possible-in-type-checker/index.js';
13
- import * as removeUselessTuplesFromTypeChecker from './remove-useless-tuples-from-type-checker/index.js';
14
- import * as addMissingTuplesToTypeChecker from './add-missing-tuples-to-type-checker/index.js';
15
- import * as checkTypePassedToTypeChecker from './check-type-passed-to-type-checker/index.js';
16
- import * as removeUselessSpacesFromTypeChecker from './remove-useless-spaces-from-type-checker/index.js';
17
- import * as addMissingSpacesToTypeChecker from './add-missing-spaces-to-type-checker/index.js';
18
- import * as removeTrailingSpacesFromTypeChecker from './remove-trailing-spaces-from-type-checker/index.js';
19
4
  import * as removeUselessMaybe from './remove-useless-maybe/index.js';
20
5
  import * as applyCreateTestUrl from './apply-create-test-url/index.js';
21
6
  import * as removeArgs from './remove-args/index.js';
@@ -39,21 +24,6 @@ export const rules = {
39
24
  'remove-legacy-test-declaration': removeLegacyTestDeclaration,
40
25
  'remove-args': removeArgs,
41
26
  'remove-useless-maybe': removeUselessMaybe,
42
- 'remove-trailing-spaces-from-type-checker': removeTrailingSpacesFromTypeChecker,
43
- 'add-missing-spaces-to-type-checker': addMissingSpacesToTypeChecker,
44
- 'remove-useless-spaces-from-type-checker': removeUselessSpacesFromTypeChecker,
45
- 'check-type-passed-to-type-checker': checkTypePassedToTypeChecker,
46
- 'add-missing-tuples-to-type-checker': addMissingTuplesToTypeChecker,
47
- 'remove-useless-tuples-from-type-checker': removeUselessTuplesFromTypeChecker,
48
- 'check-if-success-possible-in-type-checker': checkIfSuccessPossibleInTypeChecker,
49
- 'merge-tuples-of-type-checkers': mergeTuplesOfTypeCheckers,
50
- 'add-missing-colon-to-type-checker': addMissingColonToTypeChecker,
51
- 'remove-useless-colon-from-type-checker': removeUselessColonFromTypeChecker,
52
- 'remove-useless-not-from-type-checker': removeUselessNotFromTypeChecker,
53
- 'reverse-comparison-in-type-checker': reverseComparisonInTypeChecker,
54
- 'remove-useless-path-from-type-checker': removeUselessPathFromTypeChecker,
55
- 'remove-useless-arrow-from-type-checker': removeUselessArrowFromTypeChecker,
56
- 'add-missing-arrow-to-type-checker': addMissingArrowToTypeChecker,
57
27
  'remove-useless-print': removeUselessPrint,
58
28
  'declare-nearby': declareNearby,
59
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-printer",
3
- "version": "8.23.1",
3
+ "version": "9.0.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",