Skip to content

Commit 0e5d39a

Browse files
committed
test: @putout/plugin-convert-object-entries-to-object-keys
1 parent 7c455af commit 0e5d39a

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

packages/plugin-convert-object-entries-to-object-keys/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
1414
🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to convert `Object.entries()` to `Object.keys()`
1515

16-
Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f902e1f52d551545cede97db4cfba345/dbae8bfd2c4b0b4ec9612e2002a87c2a5961204d).
17-
1816
## Install
1917

2018
```
2119
npm i @putout/plugin-convert-object-entries-to-object-keys -D
2220
```
2321

24-
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/82cf60991515c274d0ba08f2ca36e9e6/bf3021f992f596d4316469c062cafd257c44c487).
22+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/82cf60991515c274d0ba08f2ca36e9e6/a56a4bddfb45007434f2d24e9573a3d7646ea11d).
2523

2624
## Rule
2725

@@ -39,6 +37,10 @@ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/82cf609915
3937
for (const [name] of Object.entries(tokens)) {
4038
console.log(name);
4139
}
40+
41+
for (const [name] of entries(tokens)) {
42+
console.log(name);
43+
}
4244
```
4345

4446
## ✅ Example of correct code
@@ -47,6 +49,10 @@ for (const [name] of Object.entries(tokens)) {
4749
for (const name of Object.keys(tokens)) {
4850
console.log(name);
4951
}
52+
53+
for (const name of keys(tokens)) {
54+
console.log(name);
55+
}
5056
```
5157

5258
## License

packages/plugin-convert-object-entries-to-object-keys/test/fixture/convert-object-entries-to-object-keys-fix.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ for (const name of Object.keys(tokens)) {
55
for (const name of keys(tokens)) {
66
console.log(name);
77
}
8+
9+
for (const name of keys(tokens)) {
10+
for (const x of keys(y)) {
11+
console.log(name, x);
12+
}
13+
}

packages/plugin-convert-object-entries-to-object-keys/test/fixture/convert-object-entries-to-object-keys.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@ for (const [name] of Object.entries(tokens)) {
44

55
for (const [name] of entries(tokens)) {
66
console.log(name);
7-
}
7+
}
8+
9+
for (const [name] of entries(tokens)) {
10+
for (const [x] of entries(y)) {
11+
console.log(name, x);
12+
}
13+
}
14+

0 commit comments

Comments
 (0)