@putout/plugin-putout 12.1.1 → 12.2.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 +10 -1
- package/lib/create-test/index.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,8 @@ It helps to preserve comments.
|
|
|
78
78
|
### ❌ Example of incorrect code
|
|
79
79
|
|
|
80
80
|
```js
|
|
81
|
-
export
|
|
81
|
+
export
|
|
82
|
+
const fix = (path) => {
|
|
82
83
|
path.remove();
|
|
83
84
|
};
|
|
84
85
|
```
|
|
@@ -524,6 +525,7 @@ const {
|
|
|
524
525
|
operator,
|
|
525
526
|
types,
|
|
526
527
|
} = require('putout');
|
|
528
|
+
|
|
527
529
|
const {compare} = operator;
|
|
528
530
|
const {isIdentifier} = types;
|
|
529
531
|
|
|
@@ -704,9 +706,11 @@ module.exports.include = () => 'cons __a = __b';
|
|
|
704
706
|
module.exports.exclude = () => 'var __a = __b';
|
|
705
707
|
module.exports.include = 'cons __a = __b';
|
|
706
708
|
module.exports.exclude = 'var __a = __b';
|
|
709
|
+
|
|
707
710
|
module.exports.include = [
|
|
708
711
|
'cons __a = __b',
|
|
709
712
|
];
|
|
713
|
+
|
|
710
714
|
module.exports.exclude = [
|
|
711
715
|
'var __a = __b',
|
|
712
716
|
];
|
|
@@ -718,18 +722,23 @@ module.exports.exclude = [
|
|
|
718
722
|
module.exports.include = () => [
|
|
719
723
|
'cons __a = __b',
|
|
720
724
|
];
|
|
725
|
+
|
|
721
726
|
module.exports.exclude = () => [
|
|
722
727
|
'var __a = __b',
|
|
723
728
|
];
|
|
729
|
+
|
|
724
730
|
module.exports.include = () => [
|
|
725
731
|
'cons __a = __b',
|
|
726
732
|
];
|
|
733
|
+
|
|
727
734
|
module.exports.exclude = () => [
|
|
728
735
|
'var __a = __b',
|
|
729
736
|
];
|
|
737
|
+
|
|
730
738
|
module.exports.include = () => [
|
|
731
739
|
'cons __a = __b',
|
|
732
740
|
];
|
|
741
|
+
|
|
733
742
|
module.exports.exclude = () => [
|
|
734
743
|
'var __a = __b',
|
|
735
744
|
];
|
package/lib/create-test/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
Identifier,
|
|
12
12
|
ObjectProperty,
|
|
13
13
|
ObjectExpression,
|
|
14
|
+
isIdentifier,
|
|
14
15
|
} = types;
|
|
15
16
|
|
|
16
17
|
const {
|
|
@@ -55,6 +56,13 @@ module.exports.filter = (path, {options}) => {
|
|
|
55
56
|
return false;
|
|
56
57
|
};
|
|
57
58
|
|
|
59
|
+
const maybeLiteral = (a) => {
|
|
60
|
+
if (isIdentifier(a))
|
|
61
|
+
return StringLiteral(a.name);
|
|
62
|
+
|
|
63
|
+
return a;
|
|
64
|
+
};
|
|
65
|
+
|
|
58
66
|
function convert(objectPath) {
|
|
59
67
|
const {
|
|
60
68
|
key,
|
|
@@ -64,7 +72,7 @@ function convert(objectPath) {
|
|
|
64
72
|
replaceWith(objectPath, ObjectExpression([
|
|
65
73
|
ObjectProperty(Identifier('plugins'), ArrayExpression([
|
|
66
74
|
ArrayExpression([
|
|
67
|
-
key,
|
|
75
|
+
maybeLiteral(key),
|
|
68
76
|
value,
|
|
69
77
|
]),
|
|
70
78
|
])),
|
package/package.json
CHANGED