Skip to content

Conversation

@nayounsang
Copy link
Contributor

@nayounsang nayounsang commented Nov 9, 2025

PR Checklist

Overview

  1. change type arg of analyze: Program
  2. change err msg, not aaa

Since changed the type of analyze, I'm wondering if it's correct to write the test as it is now.(I don't know if that makes sense!)

Furthermore, this error message was caused by passing a Node instead of a Program, so is an error message even necessary?

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @nayounsang!

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.

@nayounsang nayounsang marked this pull request as draft November 9, 2025 14:30
@netlify
Copy link

netlify bot commented Nov 9, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 1282ebc
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/6910a5779626700008eb8d0f
😎 Deploy Preview https://deploy-preview-11747--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: 90 (🔴 down 6 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 Nov 9, 2025

View your CI Pipeline Execution ↗ for commit 1282ebc

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 12s View ↗
nx run-many -t lint ✅ Succeeded 3m 5s View ↗
nx run-many -t typecheck ✅ Succeeded 2m 8s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 10s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 2s View ↗
nx run types:build ✅ Succeeded 5s 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-11-09 14:43:05 UTC

@nayounsang nayounsang changed the title fix(scope-manager): scope-manager throws unhelpful aaa error message because analyze expects Program fix(scope-manager): scope-manager throws unhelpful aaa error message because analyze expects Program Nov 9, 2025
@nayounsang nayounsang changed the title fix(scope-manager): scope-manager throws unhelpful aaa error message because analyze expects Program fix(scope-manager): throws unhelpful aaa error message because analyze expects Program Nov 9, 2025
@codecov
Copy link

codecov bot commented Nov 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.67%. Comparing base (189a7f7) to head (1282ebc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11747   +/-   ##
=======================================
  Coverage   90.66%   90.67%           
=======================================
  Files         518      518           
  Lines       52444    52447    +3     
  Branches     8690     8691    +1     
=======================================
+ Hits        47548    47554    +6     
+ Misses       4882     4879    -3     
  Partials       14       14           
Flag Coverage Δ
unittest 90.67% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/scope-manager/src/analyze.ts 100.00% <100.00%> (ø)
...ackages/scope-manager/src/referencer/Referencer.ts 97.94% <100.00%> (+<0.01%) ⬆️

... and 1 file with indirect coverage changes

🚀 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.

@nayounsang nayounsang changed the title fix(scope-manager): throws unhelpful aaa error message because analyze expects Program fix(scope-manager): change unhelpful aaa error message and analyze to expects Program Nov 10, 2025
@nayounsang nayounsang changed the title fix(scope-manager): change unhelpful aaa error message and analyze to expects Program fix(scope-manager): change unhelpful aaa error message and change analyze to expects Program Nov 10, 2025
@nayounsang
Copy link
Contributor Author

nayounsang commented Nov 10, 2025

But also the docs to have an (IMO) clear and explicit example of how to call it:
https://typescript-eslint.io/packages/scope-manager#analyzetree-options
I.e. You haven't parsed with ranges either and that'll potentially cause a crash later too.

range doesn't related to the issue.
range is used by packages/scope-manager/src/scope/FunctionScope.ts.
This may lead to incorrect comparisons, but I think it should be addressed as a different issue anyway.

    const bodyStart = this.block.body?.range[0] ?? -1;
    // It's invalid resolution in the following case:
    return !(
      (
        variable.scope === this &&
        ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
        variable.defs.every(d => d.name.range[0] >= bodyStart)
      ) // the variable is in the body.
    );

@nayounsang nayounsang marked this pull request as ready for review November 10, 2025 13:21
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: scope-manager throws unhelpful aaa error message

1 participant