@putout/plugin-printer 4.1.0 → 4.1.2

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
@@ -15,9 +15,9 @@ npm i @putout/plugin-printer -D
15
15
 
16
16
  - ✅ [add-args](#add-args);
17
17
  - ✅ [apply-breakline](#apply-breakline);
18
+ - ✅ [apply-computed-print](#apply-computed-print);
18
19
  - ✅ [apply-linebreak](#apply-linebreak);
19
20
  - ✅ [apply-types](#apply-types);
20
- - ✅ [apply-computed-print](#apply-computed-print);
21
21
  - ✅ [declare](#declare);
22
22
  - ✅ [remove-args](#remove-args);
23
23
 
@@ -30,6 +30,7 @@ npm i @putout/plugin-printer -D
30
30
  "printer/apply-breakline": "on",
31
31
  "printer/apply-linebreak": "on",
32
32
  "printer/apply-computed-print": "on",
33
+ "printer/apply-types": "on",
33
34
  "printer/declare": "on",
34
35
  "printer/remove-args": "on"
35
36
  }
@@ -54,6 +55,8 @@ print.linebreak();
54
55
 
55
56
  ## apply-types
56
57
 
58
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8a88fec812a52e302cf7b191eca2f49e/474ca87860d2eab755373ba9dc8b12efc4a80252).
59
+
57
60
  ```diff
58
61
  -const {isIdentifier} = require('@babel/types');
59
62
  +const {types} = require('@babel/types');
@@ -86,58 +89,6 @@ module.exports = {
86
89
  };
87
90
  ```
88
91
 
89
- ## add-args
90
-
91
- ### ❌ Example of incorrect code
92
-
93
- ```js
94
- module.exports = {
95
- TSPropertySignature(path) {
96
- const {optional} = path.node;
97
- print('__key');
98
- maybe.print(optional, '?');
99
- },
100
- };
101
- ```
102
-
103
- ### ✅ Example of correct code
104
-
105
- ```js
106
- module.exports = {
107
- TSPropertySignature(path, {print, maybe}) {
108
- const {optional} = path.node;
109
- print('__key');
110
- maybe.print(optional, '?');
111
- },
112
- };
113
- ```
114
-
115
- ## add-args
116
-
117
- ### ❌ Example of incorrect code
118
-
119
- ```js
120
- module.exports = {
121
- TSPropertySignature(path) {
122
- const {optional} = path.node;
123
- print('__key');
124
- maybe.print(optional, '?');
125
- },
126
- };
127
- ```
128
-
129
- ### ✅ Example of correct code
130
-
131
- ```js
132
- module.exports = {
133
- TSPropertySignature(path, {print, maybe}) {
134
- const {optional} = path.node;
135
- print('__key');
136
- maybe.print(optional, '?');
137
- },
138
- };
139
- ```
140
-
141
92
  ## apply-computed-print
142
93
 
143
94
  ### ❌ Example of incorrect code
@@ -13,13 +13,24 @@ module.exports.match = () => ({
13
13
  if (!isObjectPattern(__a))
14
14
  return false;
15
15
 
16
- const [first] = __a.properties;
16
+ const {properties} = __a;
17
+
18
+ if (properties.length > 1) {
19
+ const [, second] = properties;
20
+ return TYPES.includes(second.value.name);
21
+ }
22
+
23
+ const [first] = properties;
17
24
 
18
25
  return TYPES.includes(first.value.name);
19
26
  },
20
27
  });
21
28
 
22
29
  module.exports.replace = () => ({
30
+ 'const {types, __a} = require("@putout/babel")': `{
31
+ const {types} = require("@putout/babel");
32
+ const {__a} = types;
33
+ }`,
23
34
  'const __a = require("@putout/babel")': 'const __a = require("@putout/babel").types',
24
35
  'const __a = require("@putout/babel").types': `{
25
36
  const {types} = require("@putout/babel");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-printer",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds support of transformations for @putout/printer",