@putout/plugin-putout 29.35.2 → 29.36.1
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
|
@@ -13,7 +13,6 @@ npm i @putout/plugin-putout -D
|
|
|
13
13
|
|
|
14
14
|
## Rules
|
|
15
15
|
|
|
16
|
-
- ✅ [apply-type-check](#apply-type-check);
|
|
17
16
|
- ✅ [add-await-to-progress](#add-await-to-progress);
|
|
18
17
|
- ✅ [add-crawl-file](#add-crawl-file);
|
|
19
18
|
- ✅ [add-path-arg-to-filter](#add-path-arg-to-filter);
|
|
@@ -53,6 +52,7 @@ npm i @putout/plugin-putout -D
|
|
|
53
52
|
- ✅ [apply-string-to-property-key](#apply-string-to-property-key);
|
|
54
53
|
- ✅ [apply-transform-with-options](#apply-transform-with-options);
|
|
55
54
|
- ✅ [apply-traverser-to-ignore](#apply-traverser-to-ignore);
|
|
55
|
+
- ✅ [apply-type-check](#apply-type-check);
|
|
56
56
|
- ✅ [apply-vars](#apply-vars);
|
|
57
57
|
- ✅ [check-declare](#check-declare);
|
|
58
58
|
- ✅ [check-match](#check-match);
|
|
@@ -78,6 +78,7 @@ npm i @putout/plugin-putout -D
|
|
|
78
78
|
- ✅ [convert-replace-to-traverse](#convert-replace-to-traverse);
|
|
79
79
|
- ✅ [convert-replace-with](#convert-replace-with);
|
|
80
80
|
- ✅ [convert-replace-with-multiple](#convert-replace-with-multiple);
|
|
81
|
+
- ✅ [convert-replacer-to-includer](#convert-replacer-to-includer);
|
|
81
82
|
- ✅ [convert-report-to-function](#convert-report-to-function);
|
|
82
83
|
- ✅ [convert-to-no-transform-code](#convert-to-no-transform-code);
|
|
83
84
|
- ✅ [convert-traverse-to-include](#convert-traverse-to-include);
|
|
@@ -86,7 +87,6 @@ npm i @putout/plugin-putout -D
|
|
|
86
87
|
- ✅ [convert-traverse-to-super-traverse](#convert-traverse-to-super-traverse);
|
|
87
88
|
- ✅ [convert-url-to-dirname](#convert-url-to-dirname);
|
|
88
89
|
- ✅ [create-test](#create-test);
|
|
89
|
-
- ✅ [convert-replacer-to-includer](#convert-replacer-to-includer);
|
|
90
90
|
- ✅ [declare](#declare);
|
|
91
91
|
- ✅ [declare-path-variable](#declare-path-variable);
|
|
92
92
|
- ✅ [declare-template-variables](#declare-template-variables);
|
|
@@ -96,16 +96,16 @@ npm i @putout/plugin-putout -D
|
|
|
96
96
|
- ✅ [remove-empty-object-from-transform](#remove-empty-object-from-transform);
|
|
97
97
|
- ✅ [remove-message-from-no-report-after-transform](#remove-message-from-no-report-after-transform);
|
|
98
98
|
- ✅ [remove-unused-get-properties-argument](#remove-unused-get-properties-argument);
|
|
99
|
+
- ✅ [remove-useless-match](#remove-useless-match);
|
|
99
100
|
- ✅ [remove-useless-printer-option](#remove-useless-printer-option);
|
|
100
101
|
- ✅ [remove-useless-source-argument](#remove-useless-source-argument);
|
|
102
|
+
- ✅ [remove-useless-type-check-declaration](#remove-useless-type-check-declaration);
|
|
101
103
|
- ✅ [rename-operate-to-operator](#rename-operate-to-operator);
|
|
102
104
|
- ✅ [replace-operate-with-operator](#replace-operate-with-operator);
|
|
103
105
|
- ✅ [replace-test-message](#replace-test-message);
|
|
104
|
-
- ✅ [remove-useless-match](#remove-useless-match);
|
|
105
|
-
- ✅ [remove-useless-type-check-declaration](#remove-useless-type-check-declaration);
|
|
106
106
|
- ✅ [shorten-imports](#shorten-imports);
|
|
107
|
-
- ✅ [simplify-replace-template](#simplify-replace-template);
|
|
108
107
|
- ✅ [shorten-path-get](#shorten-path-get);
|
|
108
|
+
- ✅ [simplify-replace-template](#simplify-replace-template);
|
|
109
109
|
|
|
110
110
|
## File rules
|
|
111
111
|
|
|
@@ -182,6 +182,8 @@ npm i @putout/plugin-putout -D
|
|
|
182
182
|
"putout/convert-replace-to-traverse": "on",
|
|
183
183
|
"putout/convert-replace-with": "on",
|
|
184
184
|
"putout/convert-replace-with-multiple": "on",
|
|
185
|
+
|
|
186
|
+
"putout/convert-replacer-to-includer": "on",
|
|
185
187
|
"putout/convert-report-to-function": "on",
|
|
186
188
|
"putout/convert-to-no-transform-code": "on",
|
|
187
189
|
"putout/convert-traverse-to-include": "on",
|
|
@@ -199,16 +201,18 @@ npm i @putout/plugin-putout -D
|
|
|
199
201
|
"putout/remove-empty-object-from-transform": "on",
|
|
200
202
|
"putout/remove-message-from-no-report-after-transform": "on",
|
|
201
203
|
"putout/remove-unused-get-properties-argument": "on",
|
|
204
|
+
|
|
205
|
+
"putout/remove-useless-match": "on",
|
|
202
206
|
"putout/remove-useless-printer-option": "on",
|
|
203
207
|
"putout/remove-useless-source-argument": "on",
|
|
208
|
+
|
|
209
|
+
"putout/remove-useless-type-check-declaration": "on",
|
|
204
210
|
"putout/replace-test-message": "on",
|
|
205
211
|
"putout/shorten-imports": "on",
|
|
212
|
+
|
|
213
|
+
"putout/shorten-path-get": "on",
|
|
206
214
|
"putout/simplify-replace-template": "on",
|
|
207
|
-
"putout/sort-readme-file": "on"
|
|
208
|
-
"putout/convert-replacer-to-includer": "on",
|
|
209
|
-
"putout/remove-useless-match": "on",
|
|
210
|
-
"putout/remove-useless-type-check-declaration": "on",
|
|
211
|
-
"putout/shorten-path-get": "on"
|
|
215
|
+
"putout/sort-readme-file": "on"
|
|
212
216
|
}
|
|
213
217
|
}
|
|
214
218
|
```
|
|
@@ -1096,6 +1100,22 @@ export const {
|
|
|
1096
1100
|
});
|
|
1097
1101
|
```
|
|
1098
1102
|
|
|
1103
|
+
## apply-type-check
|
|
1104
|
+
|
|
1105
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3176ff5d9bfb388723c977735e49d599/00036b9cbd71b1a778c8423e2e7a707abd9f2f1f).
|
|
1106
|
+
|
|
1107
|
+
### ❌ Example of incorrect code
|
|
1108
|
+
|
|
1109
|
+
```js
|
|
1110
|
+
if (a.type === 'CallExpression') {}
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
### ✅ Example of correct code
|
|
1114
|
+
|
|
1115
|
+
```js
|
|
1116
|
+
if (isCallExpression(a)) {}
|
|
1117
|
+
```
|
|
1118
|
+
|
|
1099
1119
|
## apply-vars
|
|
1100
1120
|
|
|
1101
1121
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/6b1a4b5dc75f2591faf580774d23b38f/7278945371ceb76942494f7caf88375d2eaca869).
|
|
@@ -1594,6 +1614,24 @@ module.exports.replace = () => ({
|
|
|
1594
1614
|
});
|
|
1595
1615
|
```
|
|
1596
1616
|
|
|
1617
|
+
## add-places-to-compare-places"
|
|
1618
|
+
|
|
1619
|
+
### ❌ Example of incorrect code
|
|
1620
|
+
|
|
1621
|
+
[`comparePlaces`](https://github.com/coderaiser/putout/tree/master/packages/test#compareplacesfilename-places-overrides) takes two or more arguments.
|
|
1622
|
+
|
|
1623
|
+
Checkout in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/a83b1a6785bb01102451df4510333f42/a2439f7f44da56318d9a0e44b2602972811d9afb).
|
|
1624
|
+
|
|
1625
|
+
```js
|
|
1626
|
+
comparePlaces('hello');
|
|
1627
|
+
```
|
|
1628
|
+
|
|
1629
|
+
### ✅ Example of correct code
|
|
1630
|
+
|
|
1631
|
+
```js
|
|
1632
|
+
comparePlaces('hello', []);
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1597
1635
|
## convert-replace-to-function
|
|
1598
1636
|
|
|
1599
1637
|
### ❌ Example of incorrect code
|
|
@@ -1618,24 +1656,6 @@ export const traverse = () => ({
|
|
|
1618
1656
|
});
|
|
1619
1657
|
```
|
|
1620
1658
|
|
|
1621
|
-
## add-places-to-compare-places"
|
|
1622
|
-
|
|
1623
|
-
### ❌ Example of incorrect code
|
|
1624
|
-
|
|
1625
|
-
[`comparePlaces`](https://github.com/coderaiser/putout/tree/master/packages/test#compareplacesfilename-places-overrides) takes two or more arguments.
|
|
1626
|
-
|
|
1627
|
-
Checkout in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/a83b1a6785bb01102451df4510333f42/a2439f7f44da56318d9a0e44b2602972811d9afb).
|
|
1628
|
-
|
|
1629
|
-
```js
|
|
1630
|
-
comparePlaces('hello');
|
|
1631
|
-
```
|
|
1632
|
-
|
|
1633
|
-
### ✅ Example of correct code
|
|
1634
|
-
|
|
1635
|
-
```js
|
|
1636
|
-
comparePlaces('hello', []);
|
|
1637
|
-
```
|
|
1638
|
-
|
|
1639
1659
|
## convert-replace-to-traverse
|
|
1640
1660
|
|
|
1641
1661
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a87ab50e500cd3aee3099063a48c0e3f/8dee3919638062563c9b39886d8bb8581f5722f2).
|
|
@@ -1694,6 +1714,29 @@ module.exports.include = () => [
|
|
|
1694
1714
|
];
|
|
1695
1715
|
```
|
|
1696
1716
|
|
|
1717
|
+
## convert-replacer-to-includer
|
|
1718
|
+
|
|
1719
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/4b5e172466fda5e8fb114e767639f7ee/d3af95da4418b8c0e761d8cd50c1fa38a412b55c).
|
|
1720
|
+
|
|
1721
|
+
### ❌ Example of incorrect code
|
|
1722
|
+
|
|
1723
|
+
```js
|
|
1724
|
+
export const replace = () => ({
|
|
1725
|
+
'const [__a, {__b}] = __c(__d, __e)': 'const [__a, {__b}] = __c(__d, __e)',
|
|
1726
|
+
'const [__a, {__b = {}} = {}] = __c(__d, __e)': 'const [__a, {__b = {}} = {}] = __c(__d, __e)',
|
|
1727
|
+
});
|
|
1728
|
+
```
|
|
1729
|
+
|
|
1730
|
+
### ✅ Example of correct code
|
|
1731
|
+
|
|
1732
|
+
```js
|
|
1733
|
+
export const fix = () => {};
|
|
1734
|
+
export const include = () => [
|
|
1735
|
+
'const [__a, {__b}] = __c(__d, __e)',
|
|
1736
|
+
'const [__a, {__b = {}} = {}] = __c(__d, __e)',
|
|
1737
|
+
];
|
|
1738
|
+
```
|
|
1739
|
+
|
|
1697
1740
|
## convert-report-to-function
|
|
1698
1741
|
|
|
1699
1742
|
### ❌ Example of incorrect code
|
|
@@ -1890,6 +1933,37 @@ const test = createTest(import.meta.url, {
|
|
|
1890
1933
|
});
|
|
1891
1934
|
```
|
|
1892
1935
|
|
|
1936
|
+
## convert-progress-to-track
|
|
1937
|
+
|
|
1938
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8736a0cf838a3660b0927e161e4fb06c/9f5c9f810babd4450898069d3d8dc28aceee1e2d).
|
|
1939
|
+
|
|
1940
|
+
### ❌ Example of incorrect code
|
|
1941
|
+
|
|
1942
|
+
```js
|
|
1943
|
+
module.exports.scan = (root, {push, progress}) => {
|
|
1944
|
+
const files = findFile(root, ['*']);
|
|
1945
|
+
const n = files.length;
|
|
1946
|
+
|
|
1947
|
+
for (const [i, file] of files.entries()) {
|
|
1948
|
+
push(file);
|
|
1949
|
+
progress({
|
|
1950
|
+
i,
|
|
1951
|
+
n,
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
```
|
|
1956
|
+
|
|
1957
|
+
### ✅ Example of correct code
|
|
1958
|
+
|
|
1959
|
+
```js
|
|
1960
|
+
module.exports.scan = (root, {push, trackFile}) => {
|
|
1961
|
+
for (const file of trackFile(root, ['*'])) {
|
|
1962
|
+
push(file);
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
```
|
|
1966
|
+
|
|
1893
1967
|
## declare-path-variable
|
|
1894
1968
|
|
|
1895
1969
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/b485bf55785ea836408d0d45c492c3e4/2a0b465076242ebf6a0d8015a90ccf7b0b660a42).
|
|
@@ -1932,37 +2006,6 @@ const test = createTest(import.meta.url, {
|
|
|
1932
2006
|
});
|
|
1933
2007
|
```
|
|
1934
2008
|
|
|
1935
|
-
## convert-progress-to-track
|
|
1936
|
-
|
|
1937
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/8736a0cf838a3660b0927e161e4fb06c/9f5c9f810babd4450898069d3d8dc28aceee1e2d).
|
|
1938
|
-
|
|
1939
|
-
### ❌ Example of incorrect code
|
|
1940
|
-
|
|
1941
|
-
```js
|
|
1942
|
-
module.exports.scan = (root, {push, progress}) => {
|
|
1943
|
-
const files = findFile(root, ['*']);
|
|
1944
|
-
const n = files.length;
|
|
1945
|
-
|
|
1946
|
-
for (const [i, file] of files.entries()) {
|
|
1947
|
-
push(file);
|
|
1948
|
-
progress({
|
|
1949
|
-
i,
|
|
1950
|
-
n,
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
1953
|
-
};
|
|
1954
|
-
```
|
|
1955
|
-
|
|
1956
|
-
### ✅ Example of correct code
|
|
1957
|
-
|
|
1958
|
-
```js
|
|
1959
|
-
module.exports.scan = (root, {push, trackFile}) => {
|
|
1960
|
-
for (const file of trackFile(root, ['*'])) {
|
|
1961
|
-
push(file);
|
|
1962
|
-
}
|
|
1963
|
-
};
|
|
1964
|
-
```
|
|
1965
|
-
|
|
1966
2009
|
## includer
|
|
1967
2010
|
|
|
1968
2011
|
### ❌ Example of incorrect code
|
|
@@ -2105,6 +2148,24 @@ await process('input', []);
|
|
|
2105
2148
|
await process('input');
|
|
2106
2149
|
```
|
|
2107
2150
|
|
|
2151
|
+
## remove-useless-match
|
|
2152
|
+
|
|
2153
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a813e8b3da2ccbe949a3156842c3112e/5e21a147247c2451f9f826ba384d62ab37c17a01).
|
|
2154
|
+
|
|
2155
|
+
### ❌ Example of incorrect code
|
|
2156
|
+
|
|
2157
|
+
```js
|
|
2158
|
+
export const match = () => ({
|
|
2159
|
+
'const [__a, {__b}] = __c(__d, __e)': () => true,
|
|
2160
|
+
'const [__a, {__b = {}} = {}] = __c(__d, __e)': () => true,
|
|
2161
|
+
});
|
|
2162
|
+
```
|
|
2163
|
+
|
|
2164
|
+
### ✅ Example of correct code
|
|
2165
|
+
|
|
2166
|
+
```js
|
|
2167
|
+
```
|
|
2168
|
+
|
|
2108
2169
|
## remove-useless-printer-option
|
|
2109
2170
|
|
|
2110
2171
|
Check it out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f176313cf67fd6d7138470385511319f/5b26aa45db21f250016d228b7bbabbb3c10b582b).
|
|
@@ -2158,6 +2219,41 @@ test('github: set-message-of-commit-fixes: no report after transform', (t) => {
|
|
|
2158
2219
|
});
|
|
2159
2220
|
```
|
|
2160
2221
|
|
|
2222
|
+
## remove-useless-type-check-declaration
|
|
2223
|
+
|
|
2224
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/443f742c8cda2b50e1722cdf2577d5c3/1f269a3d5ae0dcfa8661ca283b329c53c2450b39).
|
|
2225
|
+
|
|
2226
|
+
### ❌ Example of incorrect code
|
|
2227
|
+
|
|
2228
|
+
```js
|
|
2229
|
+
const isStringLiteral = (arg) => arg.type === 'StringLiteral';
|
|
2230
|
+
```
|
|
2231
|
+
|
|
2232
|
+
### ✅ Example of correct code
|
|
2233
|
+
|
|
2234
|
+
```js
|
|
2235
|
+
```
|
|
2236
|
+
|
|
2237
|
+
## apply-fixture-name-to-message"
|
|
2238
|
+
|
|
2239
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/66eb493ee966c2465a9fc783cd3ca362/f42ec60e393181b6d6aaf6df81640e93fabe8783).
|
|
2240
|
+
|
|
2241
|
+
```js
|
|
2242
|
+
test('flatlint: convert-comma-to-semicolon: no report: xxx', (t) => {
|
|
2243
|
+
t.noReport('array');
|
|
2244
|
+
t.end();
|
|
2245
|
+
});
|
|
2246
|
+
```
|
|
2247
|
+
|
|
2248
|
+
### ✅ Example of correct code
|
|
2249
|
+
|
|
2250
|
+
```js
|
|
2251
|
+
test('flatlint: convert-comma-to-semicolon: no report: array', (t) => {
|
|
2252
|
+
t.noReport('array');
|
|
2253
|
+
t.end();
|
|
2254
|
+
});
|
|
2255
|
+
```
|
|
2256
|
+
|
|
2161
2257
|
## replace-test-message
|
|
2162
2258
|
|
|
2163
2259
|
Checks that `test message` and used `operator` are synchronized.
|
|
@@ -2217,142 +2313,51 @@ const test = createTest(__dirname, {
|
|
|
2217
2313
|
});
|
|
2218
2314
|
```
|
|
2219
2315
|
|
|
2220
|
-
##
|
|
2221
|
-
|
|
2222
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a012fc12f4d38038da022f7c8f379fe2/c65bf97c42650aa31c5481849bc934323df892a6).
|
|
2223
|
-
|
|
2224
|
-
### ❌ Example of incorrect code
|
|
2225
|
-
|
|
2226
|
-
```js
|
|
2227
|
-
module.exports.replace = () => ({
|
|
2228
|
-
'if (__a) {__b} else {__c}': () => 'if (__a) __b; else __c',
|
|
2229
|
-
});
|
|
2230
|
-
```
|
|
2231
|
-
|
|
2232
|
-
### ✅ Example of correct code
|
|
2233
|
-
|
|
2234
|
-
```js
|
|
2235
|
-
module.exports.replace = () => ({
|
|
2236
|
-
'if (__a) {__b} else {__c}': 'if (__a) __b; else __c',
|
|
2237
|
-
});
|
|
2238
|
-
```
|
|
2239
|
-
|
|
2240
|
-
## sort-readme-file
|
|
2241
|
-
|
|
2242
|
-
Checkout in 🐊**Putout Editor**:
|
|
2243
|
-
|
|
2244
|
-
- ✅ [`sort-contents`](https://putout.cloudcmd.io/#/gist/647bcc98ba9eeaa619dfa90d129ee0ec/a19ba868e8c2f97292e763675de65cc1ec98ff66);
|
|
2245
|
-
- ✅ [`sort-headings`](https://putout.cloudcmd.io/#/gist/a5a23310a84cb209e7e5537bab294ab2/0ecd88ffa6e37ac2553cabe5333d307aed2c4a7d);
|
|
2246
|
-
- ✅ [`sort-config`](https://putout.cloudcmd.io/#/gist/41c9975090803fdee30c445868e5b93f/18f78a72eb4f4cf33f5137fca11de9314c12763c);
|
|
2247
|
-
- ✅ [`sort-readme-file`](https://putout.cloudcmd.io/#/gist/41c9975090803fdee30c445868e5b93f/a5edcb99b4769c05d6482a051f918442bdcc86e9);
|
|
2248
|
-
|
|
2249
|
-
## apply-fixture-name-to-message"
|
|
2250
|
-
|
|
2251
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/66eb493ee966c2465a9fc783cd3ca362/f42ec60e393181b6d6aaf6df81640e93fabe8783).
|
|
2252
|
-
|
|
2253
|
-
```js
|
|
2254
|
-
test('flatlint: convert-comma-to-semicolon: no report: xxx', (t) => {
|
|
2255
|
-
t.noReport('array');
|
|
2256
|
-
t.end();
|
|
2257
|
-
});
|
|
2258
|
-
```
|
|
2259
|
-
|
|
2260
|
-
### ✅ Example of correct code
|
|
2261
|
-
|
|
2262
|
-
```js
|
|
2263
|
-
test('flatlint: convert-comma-to-semicolon: no report: array', (t) => {
|
|
2264
|
-
t.noReport('array');
|
|
2265
|
-
t.end();
|
|
2266
|
-
});
|
|
2267
|
-
```
|
|
2268
|
-
|
|
2269
|
-
## apply-type-check
|
|
2316
|
+
## shorten-path-get
|
|
2270
2317
|
|
|
2271
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/
|
|
2318
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/afc8a421eee129910153939eae2eb79e/04304530529a53f5894a289bcd83d3ac2460c9ab).
|
|
2272
2319
|
|
|
2273
2320
|
### ❌ Example of incorrect code
|
|
2274
2321
|
|
|
2275
2322
|
```js
|
|
2276
|
-
|
|
2323
|
+
const elements = path.get('arguments')[0].get('elements');
|
|
2277
2324
|
```
|
|
2278
2325
|
|
|
2279
2326
|
### ✅ Example of correct code
|
|
2280
2327
|
|
|
2281
2328
|
```js
|
|
2282
|
-
|
|
2329
|
+
const elements = path.get('arguments.0.elements');
|
|
2283
2330
|
```
|
|
2284
2331
|
|
|
2285
|
-
##
|
|
2332
|
+
## simplify-replace-template
|
|
2286
2333
|
|
|
2287
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/
|
|
2334
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a012fc12f4d38038da022f7c8f379fe2/c65bf97c42650aa31c5481849bc934323df892a6).
|
|
2288
2335
|
|
|
2289
2336
|
### ❌ Example of incorrect code
|
|
2290
2337
|
|
|
2291
2338
|
```js
|
|
2292
|
-
|
|
2293
|
-
'
|
|
2294
|
-
'const [__a, {__b = {}} = {}] = __c(__d, __e)': 'const [__a, {__b = {}} = {}] = __c(__d, __e)',
|
|
2339
|
+
module.exports.replace = () => ({
|
|
2340
|
+
'if (__a) {__b} else {__c}': () => 'if (__a) __b; else __c',
|
|
2295
2341
|
});
|
|
2296
2342
|
```
|
|
2297
2343
|
|
|
2298
2344
|
### ✅ Example of correct code
|
|
2299
2345
|
|
|
2300
2346
|
```js
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
'const [__a, {__b}] = __c(__d, __e)',
|
|
2304
|
-
'const [__a, {__b = {}} = {}] = __c(__d, __e)',
|
|
2305
|
-
];
|
|
2306
|
-
```
|
|
2307
|
-
|
|
2308
|
-
## remove-useless-match
|
|
2309
|
-
|
|
2310
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a813e8b3da2ccbe949a3156842c3112e/5e21a147247c2451f9f826ba384d62ab37c17a01).
|
|
2311
|
-
|
|
2312
|
-
### ❌ Example of incorrect code
|
|
2313
|
-
|
|
2314
|
-
```js
|
|
2315
|
-
export const match = () => ({
|
|
2316
|
-
'const [__a, {__b}] = __c(__d, __e)': () => true,
|
|
2317
|
-
'const [__a, {__b = {}} = {}] = __c(__d, __e)': () => true,
|
|
2347
|
+
module.exports.replace = () => ({
|
|
2348
|
+
'if (__a) {__b} else {__c}': 'if (__a) __b; else __c',
|
|
2318
2349
|
});
|
|
2319
2350
|
```
|
|
2320
2351
|
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
```js
|
|
2324
|
-
```
|
|
2325
|
-
|
|
2326
|
-
## remove-useless-type-check-declaration
|
|
2327
|
-
|
|
2328
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/443f742c8cda2b50e1722cdf2577d5c3/1f269a3d5ae0dcfa8661ca283b329c53c2450b39).
|
|
2329
|
-
|
|
2330
|
-
### ❌ Example of incorrect code
|
|
2331
|
-
|
|
2332
|
-
```js
|
|
2333
|
-
const isStringLiteral = (arg) => arg.type === 'StringLiteral';
|
|
2334
|
-
```
|
|
2335
|
-
|
|
2336
|
-
### ✅ Example of correct code
|
|
2337
|
-
|
|
2338
|
-
```js
|
|
2339
|
-
```
|
|
2340
|
-
|
|
2341
|
-
## shorten-path-get
|
|
2342
|
-
|
|
2343
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/afc8a421eee129910153939eae2eb79e/04304530529a53f5894a289bcd83d3ac2460c9ab).
|
|
2344
|
-
|
|
2345
|
-
### ❌ Example of incorrect code
|
|
2346
|
-
|
|
2347
|
-
```js
|
|
2348
|
-
const elements = path.get('arguments')[0].get('elements');
|
|
2349
|
-
```
|
|
2352
|
+
## sort-readme-file
|
|
2350
2353
|
|
|
2351
|
-
|
|
2354
|
+
Checkout in 🐊**Putout Editor**:
|
|
2352
2355
|
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
+
- ✅ [`add-missing-semicolon`](https://putout.cloudcmd.io/#/gist/7c7ab5cbedef8d6021ce2a77b5caa4f0/aee514d0cc4ef0ea26f4fdcf4def03a078eb1bd0);
|
|
2357
|
+
- ✅ [`sort-contents`](https://putout.cloudcmd.io/#/gist/647bcc98ba9eeaa619dfa90d129ee0ec/a19ba868e8c2f97292e763675de65cc1ec98ff66);
|
|
2358
|
+
- ✅ [`sort-headings`](https://putout.cloudcmd.io/#/gist/a5a23310a84cb209e7e5537bab294ab2/0ecd88ffa6e37ac2553cabe5333d307aed2c4a7d);
|
|
2359
|
+
- ✅ [`sort-config`](https://putout.cloudcmd.io/#/gist/41c9975090803fdee30c445868e5b93f/18f78a72eb4f4cf33f5137fca11de9314c12763c);
|
|
2360
|
+
- ✅ [`sort-readme-file`](https://putout.cloudcmd.io/#/gist/41c9975090803fdee30c445868e5b93f/a5edcb99b4769c05d6482a051f918442bdcc86e9);
|
|
2356
2361
|
|
|
2357
2362
|
## License
|
|
2358
2363
|
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
stringLiteral,
|
|
6
6
|
} = types;
|
|
7
7
|
|
|
8
|
-
const {replaceWith} = operator;
|
|
8
|
+
const {compare, replaceWith} = operator;
|
|
9
9
|
|
|
10
10
|
export const report = () => `Use 'string' instead of 'template' in property key`;
|
|
11
11
|
|
|
@@ -19,6 +19,9 @@ export const fix = (path) => {
|
|
|
19
19
|
|
|
20
20
|
export const traverse = ({push}) => ({
|
|
21
21
|
ObjectProperty(path) {
|
|
22
|
+
if (!compare(path, 'export const replace = __'))
|
|
23
|
+
return;
|
|
24
|
+
|
|
22
25
|
const keyPath = path.get('key');
|
|
23
26
|
|
|
24
27
|
if (!isTemplateLiteral(keyPath))
|
|
@@ -2,6 +2,7 @@ import {operator} from 'putout';
|
|
|
2
2
|
import * as sortContents from './sort-contents/index.js';
|
|
3
3
|
import * as sortHeadings from './sort-headings/index.js';
|
|
4
4
|
import * as sortConfig from './sort-config/index.js';
|
|
5
|
+
import * as addMissingSemicolon from './add-missing-semicolon/index.js';
|
|
5
6
|
|
|
6
7
|
const {
|
|
7
8
|
matchFiles,
|
|
@@ -17,6 +18,7 @@ export const {
|
|
|
17
18
|
files: {
|
|
18
19
|
'README.md': {
|
|
19
20
|
plugins: [
|
|
21
|
+
['add-missing-semicolon', addMissingSemicolon],
|
|
20
22
|
['sort-contents', sortContents],
|
|
21
23
|
['sort-config', sortConfig],
|
|
22
24
|
['sort-headings', sortHeadings],
|
package/package.json
CHANGED