diff --git a/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.mdx b/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.mdx index d0ca9544a58..51c13eecb15 100644 --- a/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.mdx +++ b/packages/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.mdx @@ -114,11 +114,11 @@ if (someNullCondition !== false) { ```ts option='{ "allowComparingNullableBooleansToFalse": false }' declare const someUndefinedCondition: boolean | undefined; -if (someUndefinedCondition ?? true) { +if (!(someUndefinedCondition ?? true)) { } declare const someNullCondition: boolean | null; -if (!(someNullCondition ?? true)) { +if (someNullCondition ?? true) { } ``` @@ -127,16 +127,16 @@ if (!(someNullCondition ?? true)) { ## Fixer -| Comparison | Fixer Output | Notes | -| :-------------------------------: | ------------------------------- | ----------------------------------------------------------------------------------- | -| `booleanVar === true` | `booleanVar` | | -| `booleanVar !== true` | `!booleanVar` | | -| `booleanVar === false` | `!booleanVar` | | -| `booleanVar !== false` | `booleanVar` | | -| `nullableBooleanVar === true` | `nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` | -| `nullableBooleanVar !== true` | `!nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` | -| `!(nullableBooleanVar === false)` | `nullableBooleanVar ?? true` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` | -| `!(nullableBooleanVar !== false)` | `!(nullableBooleanVar ?? true)` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` | +| Comparison | Fixer Output | Notes | +| :----------------------------: | ------------------------------- | ----------------------------------------------------------------------------------- | +| `booleanVar === true` | `booleanVar` | | +| `booleanVar !== true` | `!booleanVar` | | +| `booleanVar === false` | `!booleanVar` | | +| `booleanVar !== false` | `booleanVar` | | +| `nullableBooleanVar === true` | `nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` | +| `nullableBooleanVar !== true` | `!nullableBooleanVar` | Only checked/fixed if the `allowComparingNullableBooleansToTrue` option is `false` | +| `nullableBooleanVar === false` | `!(nullableBooleanVar ?? true)` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` | +| `nullableBooleanVar !== false` | `nullableBooleanVar ?? true` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` | ## When Not To Use It diff --git a/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unnecessary-boolean-literal-compare.shot b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unnecessary-boolean-literal-compare.shot index 3397a172781..878e1149f7d 100644 --- a/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unnecessary-boolean-literal-compare.shot +++ b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unnecessary-boolean-literal-compare.shot @@ -78,11 +78,11 @@ exports[`Validating rule docs no-unnecessary-boolean-literal-compare.mdx code ex Options: { "allowComparingNullableBooleansToFalse": false } declare const someUndefinedCondition: boolean | undefined; -if (someUndefinedCondition ?? true) { +if (!(someUndefinedCondition ?? true)) { } declare const someNullCondition: boolean | null; -if (!(someNullCondition ?? true)) { +if (someNullCondition ?? true) { } " `;