Skip to content

Commit 80f424f

Browse files
kresimir-cokobryceosterhaus
authored andcommitted
fix(eslint-plugin): move code examples to one block and move an example from correct to incorrect
1 parent 9cb3fba commit 80f424f

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

projects/eslint-plugin/rules/general/docs/rules/no-conditional-object-keys.md

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,30 @@ This rule enforces that engineers don't use a truthy or falsy value that `Object
77
Examples of **incorrect** code for this rule:
88

99
```js
10-
if (!Object.keys({foo: 'bar'})) {
10+
if (Object.keys({foo: 'bar'})) {
1111
// do your magic
1212
}
13-
```
1413

15-
or
14+
if (!Object.keys({foo: 'bar'})) {
15+
// do your magic
16+
}
1617

17-
```js
1818
!!Object.keys({foo: 'bar'}) && 'test';
19-
```
20-
21-
or
2219

23-
```js
2420
const negatedObjectKeys = !Object.keys({foo: 'bar'});
25-
```
26-
27-
or
2821

29-
```js
3022
!Object.keys({foo: 'bar'}) && true;
3123
```
3224

3325
Examples of **correct** code for this rule:
3426

35-
```js
36-
if (Object.keys({foo: 'bar'})) {
37-
// do your magic
38-
}
39-
```
40-
41-
or
42-
4327
```js
4428
if (Object.keys({foo: 'bar'}).length) {
4529
// do your magic
4630
}
47-
```
48-
49-
or
5031

51-
```js
5232
Object.keys({foo: 'bar'}) && 'test';
53-
```
54-
55-
or
5633

57-
```js
5834
if (Object.keys({foo: 'bar'}).find((i) => true)) {
5935
// do your magic
6036
}

0 commit comments

Comments
 (0)