Skip to content

Commit

Permalink
docs: [prefer-optional-chain] fix boolean option being specified inco…
Browse files Browse the repository at this point in the history
…rrectly (#8658)

fix boolean option being specified incorrectly
  • Loading branch information
kirkwaiblinger committed Mar 13, 2024
1 parent fc08f96 commit e95d90a
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Specifically the argument of the not operator (`!loose`) or a bare value in a lo

### `allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing`

When this option is `true`, the rule will not provide an auto-fixer for cases where the return type of the expression would change. For example for the expression `!foo || foo.bar` the return type of the expression is `true | T`, however for the equivalent optional chain `foo?.bar` the return type of the expression is `undefined | T`. Thus changing the code from a logical expression to an optional chain expression has altered the type of the expression.
When this option is `true`, the rule will provide an auto-fixer for cases where the return type of the expression would change. For example for the expression `!foo || foo.bar` the return type of the expression is `true | T`, however for the equivalent optional chain `foo?.bar` the return type of the expression is `undefined | T`. Thus changing the code from a logical expression to an optional chain expression has altered the type of the expression.

In some cases this distinction _may_ matter - which is why these fixers are considered unsafe - they may break the build! For example in the following code:

Expand Down

0 comments on commit e95d90a

Please sign in to comment.