Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): [no-deprecated] support for computed literal member access#11006

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

Open
undsoft wants to merge9 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
fromundsoft:10958-string-literals-in-deprecated

Conversation

undsoft
Copy link
Contributor

PR Checklist

Overview

Adds support for literal member access likea['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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedMar 28, 2025
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit7223496
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/68050fe2e838f60008cb1d87
😎 Deploy Previewhttps://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: 99 (🟢 up 3 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (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 yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedMar 28, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commit7223496.

CommandStatusDurationResult
nx typecheck ast-spec✅ Succeeded<1sView ↗
nx run-many --target=build --exclude website --...✅ Succeeded2sView ↗
nx run-many --target=clean✅ Succeeded11sView ↗

☁️Nx Cloud last updated this comment at2025-04-28 05:42:16 UTC

@codecovCodecov
Copy link

codecovbot commentedMar 28, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is98.41270% with1 line in your changes missing coverage. Please review.

Project coverage is 90.83%. Comparing base(f30a20e) to head(7223496).

Files with missing linesPatch %Lines
packages/eslint-plugin/src/rules/no-deprecated.ts98.41%1 Missing⚠️
Additional details and impacted files
@@           Coverage Diff           @@##             main   #11006   +/-   ##=======================================  Coverage   90.82%   90.83%           =======================================  Files         497      497             Lines       50204    50253   +49       Branches     8274     8289   +15     =======================================+ Hits        45600    45648   +48- Misses       4589     4590    +1  Partials       15       15
FlagCoverage Δ
unittest90.83% <98.41%> (+<0.01%)⬆️

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

Files with missing linesCoverage Δ
packages/eslint-plugin/src/rules/no-deprecated.ts96.81% <98.41%> (+0.18%)⬆️
🚀 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

@JoshuaKGoldbergJoshuaKGoldberg 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?

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelMar 31, 2025
@undsoft
Copy link
ContributorAuthor

undsoft commentedApr 4, 2025
edited
Loading

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

constmyObject={/**@deprecated */recommended:null,};constkey='recommended';constk2='recom';constk3='mended';myObject[key];// WorksmyObject[`${k2}${k3}`];// Works

However, more complex identifiers like:

constmyObject={/**@deprecated */recommended:null,};constkey={nested:'recommended'}asconst;myObject[key.nested];// Doesn't work

are not supported, becausegetPropertyName 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.

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelApr 4, 2025
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg 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! 💪

Comment on lines 291 to 293
if (node.type === AST_NODE_TYPES.MemberExpression && node.computed) {
return getComputedPropertyDeprecation(node);
}

Choose a reason for hiding this comment

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

[Refactor]getComputedPropertyDeprecation is already being called ingetDeprecationReason, just after thegetCallLikeDeprecation. If we swap the order to try the computed property check first then we'll be able to remove this call here:

Suggested change
if(node.type===AST_NODE_TYPES.MemberExpression&&node.computed){
returngetComputedPropertyDeprecation(node);
}
functiongetDeprecationReason(node:IdentifierLike):string|undefined{if(isInComputedProperty(node)){returngetComputedPropertyDeprecation(node.parentasTSESTree.MemberExpression,);}constcallLikeNode=getCallLikeNode(node);if(callLikeNode){returngetCallLikeDeprecation(callLikeNode);}

errors: [
{
column: 11,
data: { name: 'key' },

Choose a reason for hiding this comment

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

@@ -232,7 +266,7 @@ export default createRule<Options, MessageIds>({
}
}

function getCallLikeNode(node: TSESTree.Node):CallLikeNode | undefined {
function getCallLikeNode(node: TSESTree.Node):CalleeNode | undefined {

Choose a reason for hiding this comment

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

[Naming] If the type's name is switched fromCalleeNode toCallLikeNode, the correspondingget* function's name should too:

Suggested change
functiongetCallLikeNode(node:TSESTree.Node):CalleeNode|undefined{
functiongetCalleNode(node:TSESTree.Node):CalleeNode|undefined{

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelApr 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
Copy link
ContributorAuthor

Okay, I believe I've addressed the comments.

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelApr 20, 2025
@kirkwaiblingerkirkwaiblinger changed the titlefix(eslint-plugin): [no-deprecated] support for literal member access (#10958)fix(eslint-plugin): [no-deprecated] support for computed literal member accessApr 28, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergAwaiting requested review from JoshuaKGoldberg

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
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
2 participants
@undsoft@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp