Skip to content

Conversation

@undsoft
Copy link
Contributor

@undsoft undsoft commented Mar 28, 2025

PR Checklist

Overview

Adds support for literal member access like a['b']

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @undsoft!

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 Mar 28, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit f710059
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/6909037b605398000812224d
😎 Deploy Preview https://deploy-preview-11006--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: 98 (🟢 up 2 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 Mar 28, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit f710059

Command Status Duration Result
nx run-many -t typecheck ❌ Failed 2m 12s View ↗
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 11s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 2s View ↗
nx run types:build ✅ Succeeded 5s View ↗
nx run integration-tests:test ✅ Succeeded 9s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 4s View ↗
nx run generate-configs ✅ Succeeded 6s View ↗
nx run-many --target=build --parallel --exclude... ✅ Succeeded 21s View ↗
Additional runs (28) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-11-03 19:45:09 UTC

@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.66%. Comparing base (9530e02) to head (f710059).
⚠️ Report is 62 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11006      +/-   ##
==========================================
- Coverage   90.93%   90.66%   -0.28%     
==========================================
  Files         506      518      +12     
  Lines       51394    52442    +1048     
  Branches     8482     8690     +208     
==========================================
+ Hits        46735    47546     +811     
- Misses       4646     4882     +236     
- Partials       13       14       +1     
Flag Coverage Δ
unittest 90.66% <100.00%> (-0.28%) ⬇️

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

Files with missing lines Coverage Δ
packages/eslint-plugin/src/rules/no-deprecated.ts 96.66% <100.00%> (-0.49%) ⬇️

... and 40 files 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.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 Great start, thanks for kicking it off! I think there's just one case around [key] that I think is still missing?

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Mar 31, 2025
@undsoft
Copy link
Contributor Author

undsoft commented Apr 4, 2025

@JoshuaKGoldberg
Okay, I've added support for simple identifiers and template strings.

const myObject = {
  /** @deprecated */
  recommended: null,
};
const key = 'recommended';
const k2 = 'recom';
const k3 = 'mended';

myObject[key]; // Works
myObject[`${k2}${k3}`]; // Works

However, more complex identifiers like:

const myObject = {
  /** @deprecated */
  recommended: null,
};
const key = {
  nested: 'recommended'
} as const;

myObject[key.nested]; // Doesn't work

are not supported, because getPropertyName that I use doesn't seem to understand this construction.

I feel like fixing this may be outside of the scope for this PR? Or otherwise I could use some guidance as to how to do this.

@undsoft undsoft requested a review from JoshuaKGoldberg April 4, 2025 14:18
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Apr 4, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really lovely progress! 💪

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Apr 7, 2025
@JoshuaKGoldberg
Copy link
Member

fixing this may be outside of the scope for this PR?

Agreed, yeah - I think it'd be good as a followup issue.

@undsoft undsoft requested a review from JoshuaKGoldberg April 20, 2025 15:35
@undsoft
Copy link
Contributor Author

undsoft commented Apr 20, 2025

Okay, I believe I've addressed the comments.

@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Apr 20, 2025
@kirkwaiblinger kirkwaiblinger changed the title fix(eslint-plugin): [no-deprecated] support for literal member access (#10958) fix(eslint-plugin): [no-deprecated] support for computed literal member access Apr 28, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay - the summer really got away from us, and I wanted to give this tricky PR the detailed review it deserves. But it looks great - thanks so much for working on it! 😍

@JoshuaKGoldberg
Copy link
Member

I'll handle the merge conflicts so we can ideally merge this in time for the release today.

@JoshuaKGoldberg
Copy link
Member

😬 these are non-trivial merge conflicts. I ran out of time today to try to get this to work.

@undsoft I don't suppose you have bandwidth to fix these up?

@undsoft
Copy link
Contributor Author

undsoft commented Sep 19, 2025

@JoshuaKGoldberg Hi, at the moment unfortunately I don't have spare time to fix this. I may have time in a couple of months.
It looks like there was a PR for similar functionality that partially implemented was this PR is trying to achieve. It will probably be necessary to re-do this PR.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this rule did need redoing because of the merge conflicts. There were really two areas of logic:

  • checkIdentifier: already in existence
  • checkMemberExpression: recently added

...and this addition of using checkIdentifier on literals caused double-reporting in quite a few test cases. I ended up removing checkMemberExpression altogether and merging its new logic into checkIdentifier.

Someone else from @typescript-eslint/triage-team should review this PR since I'm essentially a co-author on it now.

],
},
],
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔. This is an existing test, from #10867, that no longer passes with the new unified logic. But I now think that it's not correct. The AllowedType interface is itself what's marked as allowed, not its prop. I think that that kind of allow property lookup is separately tracked by #10740.

Copy link
Member

@ronami ronami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀🚀🚀

@ronami ronami added the awaiting response Issues waiting for a reply from the OP or another party label Sep 29, 2025
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): [no-deprecated] support for computed literal member access fix(eslint-plugin): [no-deprecated] support for computed literal identifier calls Nov 3, 2025
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): [no-deprecated] support for computed literal identifier calls fix(eslint-plugin): [no-deprecated] support for computed literal identifiers Nov 3, 2025
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): [no-deprecated] support for computed literal identifiers fix(eslint-plugin): [no-deprecated] fix double-report on computed literal identifiers Nov 3, 2025
@JoshuaKGoldberg
Copy link
Member

Ok! You're right, this become much cleaner after a reset onto main. Nice.

@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 3, 2025
Copy link
Member

@ronami ronami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing, thanks! 🚀

@ronami ronami added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Nov 5, 2025
@JoshuaKGoldberg JoshuaKGoldberg merged commit c779f3c into typescript-eslint:main Nov 7, 2025
74 of 77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: [no-deprecated] does not report on computed member expressions with a known string literal property

3 participants