@putout/plugin-putout 29.36.0 → 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 +171 -167
- package/lib/apply-string-to-property-key/index.js +4 -1
- package/package.json +1 -1
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,6 +2313,22 @@ const test = createTest(__dirname, {
|
|
|
2217
2313
|
});
|
|
2218
2314
|
```
|
|
2219
2315
|
|
|
2316
|
+
## shorten-path-get
|
|
2317
|
+
|
|
2318
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/afc8a421eee129910153939eae2eb79e/04304530529a53f5894a289bcd83d3ac2460c9ab).
|
|
2319
|
+
|
|
2320
|
+
### ❌ Example of incorrect code
|
|
2321
|
+
|
|
2322
|
+
```js
|
|
2323
|
+
const elements = path.get('arguments')[0].get('elements');
|
|
2324
|
+
```
|
|
2325
|
+
|
|
2326
|
+
### ✅ Example of correct code
|
|
2327
|
+
|
|
2328
|
+
```js
|
|
2329
|
+
const elements = path.get('arguments.0.elements');
|
|
2330
|
+
```
|
|
2331
|
+
|
|
2220
2332
|
## simplify-replace-template
|
|
2221
2333
|
|
|
2222
2334
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a012fc12f4d38038da022f7c8f379fe2/c65bf97c42650aa31c5481849bc934323df892a6).
|
|
@@ -2247,114 +2359,6 @@ Checkout in 🐊**Putout Editor**:
|
|
|
2247
2359
|
- ✅ [`sort-config`](https://putout.cloudcmd.io/#/gist/41c9975090803fdee30c445868e5b93f/18f78a72eb4f4cf33f5137fca11de9314c12763c);
|
|
2248
2360
|
- ✅ [`sort-readme-file`](https://putout.cloudcmd.io/#/gist/41c9975090803fdee30c445868e5b93f/a5edcb99b4769c05d6482a051f918442bdcc86e9);
|
|
2249
2361
|
|
|
2250
|
-
## apply-fixture-name-to-message"
|
|
2251
|
-
|
|
2252
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/66eb493ee966c2465a9fc783cd3ca362/f42ec60e393181b6d6aaf6df81640e93fabe8783).
|
|
2253
|
-
|
|
2254
|
-
```js
|
|
2255
|
-
test('flatlint: convert-comma-to-semicolon: no report: xxx', (t) => {
|
|
2256
|
-
t.noReport('array');
|
|
2257
|
-
t.end();
|
|
2258
|
-
});
|
|
2259
|
-
```
|
|
2260
|
-
|
|
2261
|
-
### ✅ Example of correct code
|
|
2262
|
-
|
|
2263
|
-
```js
|
|
2264
|
-
test('flatlint: convert-comma-to-semicolon: no report: array', (t) => {
|
|
2265
|
-
t.noReport('array');
|
|
2266
|
-
t.end();
|
|
2267
|
-
});
|
|
2268
|
-
```
|
|
2269
|
-
|
|
2270
|
-
## apply-type-check
|
|
2271
|
-
|
|
2272
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3176ff5d9bfb388723c977735e49d599/00036b9cbd71b1a778c8423e2e7a707abd9f2f1f).
|
|
2273
|
-
|
|
2274
|
-
### ❌ Example of incorrect code
|
|
2275
|
-
|
|
2276
|
-
```js
|
|
2277
|
-
if (a.type === 'CallExpression') {}
|
|
2278
|
-
```
|
|
2279
|
-
|
|
2280
|
-
### ✅ Example of correct code
|
|
2281
|
-
|
|
2282
|
-
```js
|
|
2283
|
-
if (isCallExpression(a)) {}
|
|
2284
|
-
```
|
|
2285
|
-
|
|
2286
|
-
## convert-replacer-to-includer
|
|
2287
|
-
|
|
2288
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/4b5e172466fda5e8fb114e767639f7ee/d3af95da4418b8c0e761d8cd50c1fa38a412b55c).
|
|
2289
|
-
|
|
2290
|
-
### ❌ Example of incorrect code
|
|
2291
|
-
|
|
2292
|
-
```js
|
|
2293
|
-
export const replace = () => ({
|
|
2294
|
-
'const [__a, {__b}] = __c(__d, __e)': 'const [__a, {__b}] = __c(__d, __e)',
|
|
2295
|
-
'const [__a, {__b = {}} = {}] = __c(__d, __e)': 'const [__a, {__b = {}} = {}] = __c(__d, __e)',
|
|
2296
|
-
});
|
|
2297
|
-
```
|
|
2298
|
-
|
|
2299
|
-
### ✅ Example of correct code
|
|
2300
|
-
|
|
2301
|
-
```js
|
|
2302
|
-
export const fix = () => {};
|
|
2303
|
-
export const include = () => [
|
|
2304
|
-
'const [__a, {__b}] = __c(__d, __e)',
|
|
2305
|
-
'const [__a, {__b = {}} = {}] = __c(__d, __e)',
|
|
2306
|
-
];
|
|
2307
|
-
```
|
|
2308
|
-
|
|
2309
|
-
## remove-useless-match
|
|
2310
|
-
|
|
2311
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a813e8b3da2ccbe949a3156842c3112e/5e21a147247c2451f9f826ba384d62ab37c17a01).
|
|
2312
|
-
|
|
2313
|
-
### ❌ Example of incorrect code
|
|
2314
|
-
|
|
2315
|
-
```js
|
|
2316
|
-
export const match = () => ({
|
|
2317
|
-
'const [__a, {__b}] = __c(__d, __e)': () => true,
|
|
2318
|
-
'const [__a, {__b = {}} = {}] = __c(__d, __e)': () => true,
|
|
2319
|
-
});
|
|
2320
|
-
```
|
|
2321
|
-
|
|
2322
|
-
### ✅ Example of correct code
|
|
2323
|
-
|
|
2324
|
-
```js
|
|
2325
|
-
```
|
|
2326
|
-
|
|
2327
|
-
## remove-useless-type-check-declaration
|
|
2328
|
-
|
|
2329
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/443f742c8cda2b50e1722cdf2577d5c3/1f269a3d5ae0dcfa8661ca283b329c53c2450b39).
|
|
2330
|
-
|
|
2331
|
-
### ❌ Example of incorrect code
|
|
2332
|
-
|
|
2333
|
-
```js
|
|
2334
|
-
const isStringLiteral = (arg) => arg.type === 'StringLiteral';
|
|
2335
|
-
```
|
|
2336
|
-
|
|
2337
|
-
### ✅ Example of correct code
|
|
2338
|
-
|
|
2339
|
-
```js
|
|
2340
|
-
```
|
|
2341
|
-
|
|
2342
|
-
## shorten-path-get
|
|
2343
|
-
|
|
2344
|
-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/afc8a421eee129910153939eae2eb79e/04304530529a53f5894a289bcd83d3ac2460c9ab).
|
|
2345
|
-
|
|
2346
|
-
### ❌ Example of incorrect code
|
|
2347
|
-
|
|
2348
|
-
```js
|
|
2349
|
-
const elements = path.get('arguments')[0].get('elements');
|
|
2350
|
-
```
|
|
2351
|
-
|
|
2352
|
-
### ✅ Example of correct code
|
|
2353
|
-
|
|
2354
|
-
```js
|
|
2355
|
-
const elements = path.get('arguments.0.elements');
|
|
2356
|
-
```
|
|
2357
|
-
|
|
2358
2362
|
## License
|
|
2359
2363
|
|
|
2360
2364
|
MIT
|
|
@@ -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))
|
package/package.json
CHANGED