Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.9k
fix(eslint-plugin): do not suggest unsafe optional-chain + strict null in prefer-optional-chain#11844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Thanks for the PR,@BeauRussell! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedDec 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify project configuration. |
nx-cloudbot commentedDec 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx test eslint-plugin --coverage=false | ❌ Failed | 5m 18s | View ↗ |
nx test eslint-plugin | ❌ Failed | 5m 13s | View ↗ |
nx run-many -t lint | ✅ Succeeded | 3m 19s | View ↗ |
nx run-many -t typecheck | ✅ Succeeded | 2m 1s | View ↗ |
nx run generate-configs | ✅ Succeeded | 7s | View ↗ |
nx test typescript-estree --coverage=false | ✅ Succeeded | 2s | View ↗ |
nx run integration-tests:test | ✅ Succeeded | 3s | View ↗ |
nx run types:build | ✅ Succeeded | 2s | View ↗ |
Additional runs (28) | ✅ Succeeded | ... | View ↗ |
☁️Nx Cloud last updated this comment at2025-12-15 12:45:55 UTC
codecovbot commentedDec 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report❌ Patch coverage is Pleaseupload reports for the commit5810d95 to get more accurate results.
Additional details and impacted files@@ Coverage Diff @@## main #11844 +/- ##======================================= Coverage 90.58% 90.58% ======================================= Files 524 524 Lines 53324 53365 +41 Branches 8892 8912 +20 =======================================+ Hits 48301 48340 +39- Misses 5010 5012 +2 Partials 13 13
Flags with carried forward coverage won't be shown.Click here to find out more.
🚀 New features to boost your workflow:
|
BeauRussell commentedDec 15, 2025
Going to take a minute and make this more robust to handle && !== as well as reverse versions |


PR Checklist
Overview
The
prefer-optional-chainrule was suggesting an unsafe transformation when an OR-chain mixed a strict=== undefinedcheck with a strict=== nullcheck on a property access.The Problem
Given:
The rule suggested:
foo?.bar === nullThis isnot equivalent because optional chaining returns
undefinedfor nullish receivers, so whenfooisundefined, the rewritten condition evaluates tofalseinstead oftrue, changing control flow.The Fix
The rule now reports the pattern but does not offer a fix/suggestion when:
=== undefinedcheck=== null/!== nullThis prevents the unsafe transformation while preserving valid suggestions (e.g., when using loose equality or when all checks are for the same literal).