babel-plugin-putout 4.0.0 → 6.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 +14 -23
- package/lib/index.js +10 -9
- package/package.json +16 -12
package/README.md
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
# babel-plugin-putout
|
|
2
2
|
|
|
3
|
-
Use
|
|
3
|
+
Use 🐊[**Putout**](https://github.com/coderaiser/putout) as `babel plugin`.
|
|
4
4
|
|
|
5
5
|
## Example
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
// input code
|
|
11
|
-
const s = 'hi';
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
**Out**
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
// output code
|
|
7
|
+
```diff
|
|
8
|
+
-const s = 'hi';
|
|
18
9
|
```
|
|
19
10
|
|
|
20
11
|
## Installation
|
|
@@ -25,19 +16,19 @@ $ npm install babel-plugin-putout
|
|
|
25
16
|
|
|
26
17
|
## Usage
|
|
27
18
|
|
|
28
|
-
### Via `.babelrc` (Recommended)
|
|
19
|
+
### Via `.babelrc.json` (Recommended)
|
|
29
20
|
|
|
30
|
-
**.babelrc**
|
|
21
|
+
**.babelrc.json**
|
|
31
22
|
|
|
32
23
|
```json
|
|
33
24
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
"plugins": [
|
|
26
|
+
["putout", {
|
|
27
|
+
"rules": {
|
|
28
|
+
"remove-unused-variables": false
|
|
29
|
+
}
|
|
30
|
+
}]
|
|
31
|
+
]
|
|
41
32
|
}
|
|
42
33
|
```
|
|
43
34
|
|
|
@@ -50,7 +41,7 @@ $ babel --plugins putout script.js
|
|
|
50
41
|
### Via Node API
|
|
51
42
|
|
|
52
43
|
```javascript
|
|
53
|
-
require(
|
|
54
|
-
|
|
44
|
+
require('babel-core').transform('code', {
|
|
45
|
+
plugins: ['putout'],
|
|
55
46
|
});
|
|
56
47
|
```
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
transform,
|
|
7
7
|
} = require('putout');
|
|
8
8
|
|
|
9
|
-
const parseOptions = require('putout/
|
|
9
|
+
const parseOptions = require('putout/parse-options');
|
|
10
10
|
|
|
11
11
|
module.exports = () => {
|
|
12
12
|
let code = '';
|
|
@@ -16,15 +16,12 @@ module.exports = () => {
|
|
|
16
16
|
visitor: {
|
|
17
17
|
Program(path, {filename, opts}) {
|
|
18
18
|
const options = parseOptions({
|
|
19
|
+
printer: 'putout',
|
|
19
20
|
filename,
|
|
20
21
|
options: opts,
|
|
21
22
|
});
|
|
22
23
|
|
|
23
|
-
transform(
|
|
24
|
-
path.container,
|
|
25
|
-
code,
|
|
26
|
-
options,
|
|
27
|
-
);
|
|
24
|
+
transform(path.container, code, options);
|
|
28
25
|
},
|
|
29
26
|
},
|
|
30
27
|
|
|
@@ -35,9 +32,13 @@ module.exports = () => {
|
|
|
35
32
|
|
|
36
33
|
generatorOverride(ast) {
|
|
37
34
|
ast.program.directives = [];
|
|
38
|
-
const code = print(ast
|
|
39
|
-
|
|
35
|
+
const code = print(ast, {
|
|
36
|
+
printer: 'putout',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
code,
|
|
41
|
+
};
|
|
40
42
|
},
|
|
41
43
|
};
|
|
42
44
|
};
|
|
43
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"type": "commonjs",
|
|
4
5
|
"description": "babel plugin for putout",
|
|
5
6
|
"repository": "coderaiser/babel-plugin-putout",
|
|
6
7
|
"author": "Coderaiser <coderaiser@cloudcmd.io>",
|
|
@@ -9,34 +10,37 @@
|
|
|
9
10
|
"tag": false,
|
|
10
11
|
"changelog": false,
|
|
11
12
|
"devDependencies": {
|
|
12
|
-
"@babel/core": "^7.
|
|
13
|
-
"@babel/eslint-plugin-development": "^
|
|
14
|
-
"babel-plugin-transform-inline-consecutive-adds": "^0.
|
|
15
|
-
"
|
|
16
|
-
"eslint
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
13
|
+
"@babel/core": "^7.12.3",
|
|
14
|
+
"@babel/eslint-plugin-development": "^7.14.5",
|
|
15
|
+
"babel-plugin-transform-inline-consecutive-adds": "^0.5.0-alpha.9",
|
|
16
|
+
"c8": "^7.5.0",
|
|
17
|
+
"eslint": "^8.0.1",
|
|
18
|
+
"eslint-plugin-n": "^16.0.0",
|
|
19
|
+
"eslint-plugin-putout": "^17.0.0",
|
|
20
|
+
"madrun": "^9.0.0",
|
|
21
|
+
"mocha": "^10.0.0",
|
|
22
|
+
"supertape": "^8.0.0"
|
|
21
23
|
},
|
|
22
24
|
"scripts": {
|
|
23
25
|
"test": "madrun test",
|
|
24
26
|
"test:watch": "madrun test:watch",
|
|
25
27
|
"watch:test": "madrun watch:test",
|
|
26
28
|
"lint": "madrun lint",
|
|
29
|
+
"fresh:lint": "madrun fresh:lint",
|
|
30
|
+
"lint:fresh": "madrun lint:fresh",
|
|
27
31
|
"fix:lint": "madrun fix:lint",
|
|
28
32
|
"coverage": "madrun coverage",
|
|
29
33
|
"report": "madrun report"
|
|
30
34
|
},
|
|
31
35
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
36
|
+
"node": ">=16"
|
|
33
37
|
},
|
|
34
38
|
"keywords": [
|
|
35
39
|
"putout",
|
|
36
40
|
"babel-plugin"
|
|
37
41
|
],
|
|
38
42
|
"peerDependencies": {
|
|
39
|
-
"putout": ">=
|
|
43
|
+
"putout": ">=29"
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
42
46
|
"access": "public"
|