fix(linter/unicorn): do not report on optionals in prefer-array-flat-map#21082
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Unicorn prefer-array-flat-map rule to avoid reporting (and therefore auto-fixing) map().flat() patterns when optional chaining is involved, re-enabling previously skipped upstream test cases.
Changes:
- Skip diagnostics when the outer
.flat()call is an optional call (.flat?.()/?.flat()). - Skip diagnostics when the
.flatmember access is optionally chained (?.flat). - Skip diagnostics when the inner
.mapcall is an optional call (map?.(…)), and re-enable the associated pass tests.
Merging this PR will not alter performance
Comparing Footnotes
|
fixes commented out tests for optionals in #19428