From 8f4d9391b76786790e13cb9ca3b6a0da04014636 Mon Sep 17 00:00:00 2001 From: cigui Date: Mon, 9 Oct 2023 05:11:43 +0800 Subject: [PATCH] docs: fix prefer-optional-chain example for the unsafe fixes option (#7711) docs: fix the example for the option allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing in prefer-optional-chain --- packages/eslint-plugin/docs/rules/prefer-optional-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md index 6efb88b17ae..41682819487 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -76,7 +76,7 @@ declare function acceptsBoolean(arg: boolean): void; acceptsBoolean(foo != null && foo.bar); // ❌ typechecks UNSUCCESSFULLY as the expression returns `boolean | undefined` -acceptsBoolean(foo != null && foo.bar); +acceptsBoolean(foo?.bar); ``` This style of code isn't super common - which means having this option set to `true` _should_ be safe in most codebases. However we default it to `false` due to its unsafe nature. We have provided this option for convenience because it increases the autofix cases covered by the rule. If you set option to `true` the onus is entirely on you and your team to ensure that each fix is correct and safe and that it does not break the build.