@putout/plugin-esm 5.3.1 β 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 +1 -1
- package/lib/convert-assert-to-with/index.js +35 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {operator, types} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
importAttribute,
|
|
5
|
+
identifier,
|
|
6
|
+
} = types;
|
|
7
|
+
|
|
8
|
+
const {compare, remove} = operator;
|
|
4
9
|
|
|
5
10
|
export const report = () => `Use 'with' instead of 'assert'`;
|
|
6
11
|
|
|
@@ -10,19 +15,38 @@ export const include = () => [
|
|
|
10
15
|
];
|
|
11
16
|
|
|
12
17
|
export const fix = (path) => {
|
|
13
|
-
if (path.
|
|
14
|
-
|
|
18
|
+
if (path.isImportExpression()) {
|
|
19
|
+
path.node.options.properties[0].key.name = 'with';
|
|
15
20
|
return;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
const next = path.getNextSibling();
|
|
24
|
+
const nextNext = next.getNextSibling();
|
|
25
|
+
const nextNextNext = nextNext.getNextSibling();
|
|
26
|
+
const {body} = nextNext.node.body[0];
|
|
27
|
+
|
|
28
|
+
remove(next);
|
|
29
|
+
remove(nextNext);
|
|
30
|
+
|
|
31
|
+
if (nextNextNext.isEmptyStatement())
|
|
32
|
+
remove(nextNextNext);
|
|
33
|
+
|
|
34
|
+
path.node.attributes = [
|
|
35
|
+
importAttribute(identifier('type'), body.expression),
|
|
36
|
+
];
|
|
19
37
|
};
|
|
20
38
|
|
|
21
39
|
export const filter = (path) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
if (path.isImportDeclaration()) {
|
|
41
|
+
const next = path.getNextSibling();
|
|
42
|
+
|
|
43
|
+
if (!compare(next, 'assert;'))
|
|
44
|
+
return false;
|
|
45
|
+
|
|
46
|
+
const nextNext = next.getNextSibling();
|
|
47
|
+
|
|
48
|
+
return compare(nextNext, '{type: "__";}');
|
|
49
|
+
}
|
|
26
50
|
|
|
27
|
-
return
|
|
51
|
+
return path.isImportExpression();
|
|
28
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-esm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "πPutout plugin improves ability to transform ESM code",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"supertape": "^11.0.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"putout": ">=
|
|
60
|
+
"putout": ">=41"
|
|
61
61
|
},
|
|
62
62
|
"license": "MIT",
|
|
63
63
|
"engines": {
|