🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@mdm317
Copy link
Contributor

@mdm317 mdm317 commented Dec 10, 2025

PR Checklist

Problem

BinaryExpression nodes where both left and right are MemberExpression are not checked,
a === null || a.b !== foo.three; // bug: should be flagged/fixable, is not
and CallExpression nodes whose callee is a MemberExpression are not treated as MemberExpression.
a === null || a.b !== a.c();

Fix

  • Introduced MemberBasedExpression, which covers both a.b and a.b().
  • Added unknown to the yoda enum

Logic for yoda: unknown

  1. For BinaryExpression nodes where both sides are MemberBasedExpression, set yoda to unknown.
    • e.g., a.b != a.c, a.b != c.d
  2. When yoda is unknown and both sides are subsets of the previous chain, skip the transformation in analyzeChain.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @mdm317!

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 on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 2838efc
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/69396cf79b4d87000864b910
😎 Deploy Preview https://deploy-preview-11835--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 85 (🔴 down 12 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link

nx-cloud bot commented Dec 10, 2025

View your CI Pipeline Execution ↗ for commit 2838efc

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 12s View ↗
nx run-many -t lint ✅ Succeeded 3m 17s View ↗
nx run-many -t typecheck ✅ Succeeded 2m 9s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 20s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 10s View ↗
nx run types:build ✅ Succeeded 2s View ↗
nx run generate-configs ✅ Succeeded 8s View ↗
nx run integration-tests:test ✅ Succeeded 3s View ↗
Additional runs (29) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-12-10 13:04:03 UTC

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 96.33028% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.55%. Comparing base (dd96947) to head (2838efc).

Files with missing lines Patch % Lines
packages/typescript-estree/src/convert.ts 0.00% 3 Missing ⚠️
packages/type-utils/src/predicates.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11835      +/-   ##
==========================================
+ Coverage   90.53%   90.55%   +0.01%     
==========================================
  Files         523      523              
  Lines       53096    53140      +44     
  Branches     8838     8846       +8     
==========================================
+ Hits        48073    48122      +49     
+ Misses       5010     5005       -5     
  Partials       13       13              
Flag Coverage Δ
unittest 90.55% <96.33%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...lugin/src/rules/consistent-generic-constructors.ts 97.46% <100.00%> (-0.02%) ⬇️
...s/eslint-plugin/src/rules/no-dupe-class-members.ts 100.00% <100.00%> (ø)
...ges/eslint-plugin/src/rules/no-misused-promises.ts 99.12% <100.00%> (-0.01%) ⬇️
packages/eslint-plugin/src/rules/no-redeclare.ts 98.57% <100.00%> (-0.01%) ⬇️
packages/eslint-plugin/src/rules/no-type-alias.ts 100.00% <100.00%> (ø)
...slint-plugin/src/rules/prefer-namespace-keyword.ts 100.00% <100.00%> (ø)
...lint-plugin/src/rules/prefer-nullish-coalescing.ts 98.27% <100.00%> (-0.01%) ⬇️
.../rules/prefer-optional-chain-utils/analyzeChain.ts 100.00% <100.00%> (ø)
...efer-optional-chain-utils/gatherLogicalOperands.ts 100.00% <100.00%> (ø)
...ages/eslint-plugin/src/rules/unified-signatures.ts 94.26% <100.00%> (-0.07%) ⬇️
... and 6 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mdm317 mdm317 marked this pull request as ready for review December 10, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: @typescript-eslint/prefer-optional-chain produces incorrect autofix

1 participant