Skip to content

Commit

Permalink
docs: fix prefer-optional-chain example for the unsafe fixes option (#…
Browse files Browse the repository at this point in the history
…7711)

docs: fix the example for the option allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing in prefer-optional-chain
  • Loading branch information
cigui committed Oct 8, 2023
1 parent d948dc4 commit 8f4d939
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/docs/rules/prefer-optional-chain.md
Expand Up @@ -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.
Expand Down

0 comments on commit 8f4d939

Please sign in to comment.