Skip to content

fix(eslint-plugin): properly coerce all types to string in getStaticMemberAccessValue #10004

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 22, 2024

Conversation

abrahamguo
Copy link
Contributor

PR Checklist

Overview

#9836 had some bugs with how various data types are coerced to strings when used in a computed MemberAccess; this PR fixes those bugs.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @abrahamguo!

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.

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 731412b
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66f0a15078ae0f00082fe3ed
😎 Deploy Preview https://deploy-preview-10004--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 4 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (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 site configuration.

Copy link

nx-cloud bot commented Sep 17, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 731412b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

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.

abrahamguo commented 5 hours ago:

... I will plan on opening a PR with the fix in the next 12 hours ...

You work fast! 😄

...and, thanks for this! We can ship a quick patch release to get this to users.

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 17, 2024
@abrahamguo abrahamguo changed the title fix(eslint-plugin): [getStaticMemberAccessValue] properly coerce all types to string fix(eslint-plugin): [getStaticMemberAccessValue] properly coerce all types to string Sep 17, 2024
@abrahamguo abrahamguo changed the title fix(eslint-plugin): [getStaticMemberAccessValue] properly coerce all types to string fix(eslint-plugin): properly coerce all types to string in getStaticMemberAccessValue Sep 17, 2024
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.70%. Comparing base (7b149b9) to head (731412b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10004   +/-   ##
=======================================
  Coverage   88.69%   88.70%           
=======================================
  Files         426      426           
  Lines       14829    14835    +6     
  Branches     4313     4312    -1     
=======================================
+ Hits        13153    13159    +6     
  Misses       1533     1533           
  Partials      143      143           
Flag Coverage Δ
unittest 88.70% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...t-plugin/src/rules/class-literal-property-style.ts 100.00% <100.00%> (ø)
.../eslint-plugin/src/rules/class-methods-use-this.ts 93.47% <100.00%> (+0.14%) ⬆️
...-plugin/src/util/isArrayMethodCallWithPredicate.ts 100.00% <100.00%> (ø)
packages/eslint-plugin/src/util/misc.ts 100.00% <100.00%> (ø)

@abrahamguo
Copy link
Contributor Author

Lint failed due to CI flake.

@github-actions github-actions bot removed the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 17, 2024
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Some syntax changes requested, but I think the logic is good

kirkwaiblinger
kirkwaiblinger previously approved these changes Sep 20, 2024
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

I think this looks good! Thanks!

? String(key.value)
: (key as TSESTree.Identifier | TSESTree.PrivateIdentifier).name;
const { type } = key;
if (type === AST_NODE_TYPES.Literal) {
Copy link
Member

Choose a reason for hiding this comment

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

(question, no specific action/resolution implied) is this conditional necessary? Or will it just be caught by the getStaticValue?

Copy link
Member

Choose a reason for hiding this comment

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

checked locally and all the tests pass if I comment it out 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, removed!

@kirkwaiblinger kirkwaiblinger added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 20, 2024
@kirkwaiblinger kirkwaiblinger requested a review from a team September 20, 2024 22:36
@github-actions github-actions bot removed the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 20, 2024
@kirkwaiblinger kirkwaiblinger added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 21, 2024
@Josh-Cena Josh-Cena merged commit 1c183ab into typescript-eslint:main Sep 22, 2024
61 of 62 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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: [prefer-promise-reject-errors (and other rules too)] Cannot convert Symbol to string (8.6.0 regression)
4 participants