@putout/plugin-printer 3.1.0 → 4.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 +88 -0
- package/lib/apply-types/index.js +28 -0
- package/lib/declare/index.js +8 -0
- package/lib/index.js +4 -0
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -13,6 +13,16 @@ npm i @putout/plugin-printer -D
|
|
|
13
13
|
|
|
14
14
|
## Rules
|
|
15
15
|
|
|
16
|
+
- ✅ [add-args](#add-args);
|
|
17
|
+
- ✅ [apply-breakline](#apply-breakline);
|
|
18
|
+
- ✅ [apply-linebreak](#apply-linebreak);
|
|
19
|
+
- ✅ [apply-types](#apply-types);
|
|
20
|
+
- ✅ [apply-computed-print](#apply-computed-print);
|
|
21
|
+
- ✅ [declare](#declare);
|
|
22
|
+
- ✅ [remove-args](#remove-args);
|
|
23
|
+
|
|
24
|
+
## Config
|
|
25
|
+
|
|
16
26
|
```json
|
|
17
27
|
{
|
|
18
28
|
"rules": {
|
|
@@ -20,6 +30,7 @@ npm i @putout/plugin-printer -D
|
|
|
20
30
|
"printer/apply-breakline": "on",
|
|
21
31
|
"printer/apply-linebreak": "on",
|
|
22
32
|
"printer/apply-computed-print": "on",
|
|
33
|
+
"printer/declare": "on",
|
|
23
34
|
"printer/remove-args": "on"
|
|
24
35
|
}
|
|
25
36
|
}
|
|
@@ -41,6 +52,66 @@ print.breakline();
|
|
|
41
52
|
print.linebreak();
|
|
42
53
|
```
|
|
43
54
|
|
|
55
|
+
## apply-types
|
|
56
|
+
|
|
57
|
+
```diff
|
|
58
|
+
-const {isIdentifier} = require('@babel/types');
|
|
59
|
+
+const {types} = require('@babel/types');
|
|
60
|
+
+const {isIdentifier} = types;
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## add-args
|
|
64
|
+
|
|
65
|
+
### ❌ Example of incorrect code
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
module.exports = {
|
|
69
|
+
TSPropertySignature(path) {
|
|
70
|
+
const {optional} = path.node;
|
|
71
|
+
print('__key');
|
|
72
|
+
maybe.print(optional, '?');
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### ✅ Example of correct code
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
module.exports = {
|
|
81
|
+
TSPropertySignature(path, {print, maybe}) {
|
|
82
|
+
const {optional} = path.node;
|
|
83
|
+
print('__key');
|
|
84
|
+
maybe.print(optional, '?');
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
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
|
+
|
|
44
115
|
## add-args
|
|
45
116
|
|
|
46
117
|
### ❌ Example of incorrect code
|
|
@@ -95,6 +166,23 @@ print.indent(is);
|
|
|
95
166
|
print.indent();
|
|
96
167
|
```
|
|
97
168
|
|
|
169
|
+
## declare
|
|
170
|
+
|
|
171
|
+
### ❌ Example of incorrect code
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
isIdentifier();
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### ✅ Example of correct code
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
const {types} = require('@putout/babel');
|
|
181
|
+
const {isIdentifier} = types;
|
|
182
|
+
|
|
183
|
+
isIdentifier();
|
|
184
|
+
```
|
|
185
|
+
|
|
98
186
|
## License
|
|
99
187
|
|
|
100
188
|
MIT
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {types} = require('putout');
|
|
4
|
+
const {isObjectPattern} = types;
|
|
5
|
+
|
|
6
|
+
const {keys} = Object;
|
|
7
|
+
const TYPES = keys(types);
|
|
8
|
+
|
|
9
|
+
module.exports.report = () => `require: ('@putout/babel') -> ('putout/babel').types`;
|
|
10
|
+
|
|
11
|
+
module.exports.match = () => ({
|
|
12
|
+
'const __a = require("@putout/babel")': ({__a}) => {
|
|
13
|
+
if (!isObjectPattern(__a))
|
|
14
|
+
return false;
|
|
15
|
+
|
|
16
|
+
const [first] = __a.properties;
|
|
17
|
+
|
|
18
|
+
return TYPES.includes(first.value.name);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
module.exports.replace = () => ({
|
|
23
|
+
'const __a = require("@putout/babel")': 'const __a = require("@putout/babel").types',
|
|
24
|
+
'const __a = require("@putout/babel").types': `{
|
|
25
|
+
const {types} = require("@putout/babel");
|
|
26
|
+
const __a = types;
|
|
27
|
+
}`,
|
|
28
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,8 @@ const applyBreakline = require('./apply-breakline');
|
|
|
5
5
|
const applyLinebreak = require('./apply-linebreak');
|
|
6
6
|
const applyComputedPrint = require('./apply-computed-print');
|
|
7
7
|
const addArgs = require('./add-args');
|
|
8
|
+
const declare = require('./declare');
|
|
9
|
+
const applyTypes = require('./apply-types');
|
|
8
10
|
|
|
9
11
|
module.exports.rules = {
|
|
10
12
|
'remove-args': removeArgs,
|
|
@@ -12,4 +14,6 @@ module.exports.rules = {
|
|
|
12
14
|
'apply-linebreak': applyLinebreak,
|
|
13
15
|
'apply-computed-print': applyComputedPrint,
|
|
14
16
|
'add-args': addArgs,
|
|
17
|
+
declare,
|
|
18
|
+
'apply-types': applyTypes,
|
|
15
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-printer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
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",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"changelog": false,
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git://github.com/coderaiser/printer.git"
|
|
14
|
+
"url": "git+https://github.com/coderaiser/printer.git"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"wisdom": "madrun wisdom",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"coverage": "madrun coverage",
|
|
25
25
|
"report": "madrun report"
|
|
26
26
|
},
|
|
27
|
-
"dependencies": {
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@putout/plugin-putout": "*"
|
|
29
|
+
},
|
|
28
30
|
"keywords": [
|
|
29
31
|
"putout-plugin",
|
|
30
32
|
"putout",
|
|
@@ -33,22 +35,22 @@
|
|
|
33
35
|
],
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@putout/plugin-for-of": "*",
|
|
36
|
-
"@putout/test": "^
|
|
37
|
-
"c8": "^
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"eslint-plugin-n": "^
|
|
40
|
-
"eslint-plugin-putout": "^
|
|
38
|
+
"@putout/test": "^11.0.0",
|
|
39
|
+
"c8": "^10.0.0",
|
|
40
|
+
"eslint": "^9.0.0",
|
|
41
|
+
"eslint-plugin-n": "^17.0.0",
|
|
42
|
+
"eslint-plugin-putout": "^23.0.0",
|
|
41
43
|
"lerna": "^6.0.1",
|
|
42
|
-
"madrun": "^
|
|
44
|
+
"madrun": "^10.0.0",
|
|
43
45
|
"montag": "^1.2.1",
|
|
44
46
|
"nodemon": "^3.0.1"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
|
-
"putout": ">=
|
|
49
|
+
"putout": ">=37"
|
|
48
50
|
},
|
|
49
51
|
"license": "MIT",
|
|
50
52
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
53
|
+
"node": ">=18"
|
|
52
54
|
},
|
|
53
55
|
"publishConfig": {
|
|
54
56
|
"access": "public"
|