Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e1241b

Browse files
authored
docs: fix no-unnecessary-boolean-literal-compare example (typescript-eslint#8981)
* docs: fix no-unnecessary-boolean-literal-compare example * docs: use simpler expressions on no-unnecessary-boolean-literal-compare examples
1 parent ee677f6 commit 6e1241b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ if (someNullCondition !== false) {
114114

115115
```ts option='{ "allowComparingNullableBooleansToFalse": false }'
116116
declare const someUndefinedCondition: boolean | undefined;
117-
if (someUndefinedCondition ?? true) {
117+
if (!(someUndefinedCondition ?? true)) {
118118
}
119119

120120
declare const someNullCondition: boolean | null;
121-
if (!(someNullCondition ?? true)) {
121+
if (someNullCondition ?? true) {
122122
}
123123
```
124124

@@ -127,16 +127,16 @@ if (!(someNullCondition ?? true)) {
127127

128128
## Fixer
129129

130-
| Comparison | Fixer Output | Notes |
131-
| :-------------------------------: | ------------------------------- | ----------------------------------------------------------------------------------- |
132-
| `booleanVar === true` | `booleanVar` | |
133-
| `booleanVar !== true` | `!booleanVar` | |
134-
| `booleanVar === false` | `!booleanVar` | |
135-
| `booleanVar !== false` | `booleanVar` | |
136-
| `nullableBooleanVar === true` | `nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` |
137-
| `nullableBooleanVar !== true` | `!nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` |
138-
| `!(nullableBooleanVar === false)` | `nullableBooleanVar ?? true` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` |
139-
| `!(nullableBooleanVar !== false)` | `!(nullableBooleanVar ?? true)` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` |
130+
| Comparison | Fixer Output | Notes |
131+
| :----------------------------: | ------------------------------- | ----------------------------------------------------------------------------------- |
132+
| `booleanVar === true` | `booleanVar` | |
133+
| `booleanVar !== true` | `!booleanVar` | |
134+
| `booleanVar === false` | `!booleanVar` | |
135+
| `booleanVar !== false` | `booleanVar` | |
136+
| `nullableBooleanVar === true` | `nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` |
137+
| `nullableBooleanVar !== true` | `!nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` |
138+
| `nullableBooleanVar === false` | `!(nullableBooleanVar ?? true)` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` |
139+
| `nullableBooleanVar !== false` | `nullableBooleanVar ?? true` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` |
140140

141141
## When Not To Use It
142142

packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unnecessary-boolean-literal-compare.shot

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)