Skip to content

feat(typescript-estree): forbid invalid keys in EnumMember #11232

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

fisker
Copy link
Contributor

@fisker fisker commented May 21, 2025

PR Checklist

Overview

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @fisker!

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 May 21, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 2d56333
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/684553415dde120008641bdb
😎 Deploy Preview https://deploy-preview-11232--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: 93 (🔴 down 6 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 your Netlify project configuration.

Copy link

nx-cloud bot commented May 21, 2025

View your CI Pipeline Execution ↗ for commit 2d56333.

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 1s View ↗
nx run-many -t typecheck ✅ Succeeded 2m 15s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 18s View ↗
nx run-many -t lint ✅ Succeeded 13s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 6s View ↗
nx run generate-configs ✅ Succeeded 9s View ↗
nx run integration-tests:test ✅ Succeeded <1s View ↗
nx run types:build ✅ Succeeded 1s View ↗
Additional runs (27) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-06-08 09:19:29 UTC

@fisker fisker force-pushed the non-computed-enum-member branch from 45c92cb to 82e8533 Compare May 21, 2025 17:18
@fisker fisker marked this pull request as draft May 21, 2025 17:31
Comment on lines +636 to +637
// Unknown reason, can't get the correct type
const id = node.id as TSESTree.Identifier | TSESTree.StringLiteral;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the build script is using the published package instead of local one. I tried to use workspace:^, but still can't build.

Copy link
Member

Choose a reason for hiding this comment

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

it might be due to nx not seeing the changes to ast-spec?

Copy link

codecov bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 69.04762% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.88%. Comparing base (1e0ba62) to head (2d56333).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/typescript-estree/src/convert.ts 65.78% 13 Missing ⚠️

❌ Your patch check has failed because the patch coverage (69.04%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11232      +/-   ##
==========================================
- Coverage   90.91%   90.88%   -0.03%     
==========================================
  Files         501      501              
  Lines       50869    50890      +21     
  Branches     8382     8380       -2     
==========================================
+ Hits        46248    46253       +5     
- Misses       4606     4622      +16     
  Partials       15       15              
Flag Coverage Δ
unittest 90.88% <69.04%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
...kages/eslint-plugin/src/rules/naming-convention.ts 97.79% <100.00%> (-0.02%) ⬇️
...ackages/scope-manager/src/referencer/Referencer.ts 97.93% <100.00%> (-0.01%) ⬇️
packages/typescript-estree/src/convert.ts 30.87% <65.78%> (+0.21%) ⬆️

... and 2 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.

@fisker fisker marked this pull request as ready for review May 21, 2025 19:52
@fisker
Copy link
Contributor Author

fisker commented May 27, 2025

Wait for microsoft/TypeScript#61772

@fisker fisker marked this pull request as draft May 27, 2025 20:22
@fisker
Copy link
Contributor Author

fisker commented Jun 8, 2025

microsoft/TypeScript#61772 has been fixed.

@fisker fisker marked this pull request as ready for review June 8, 2025 08:56
@fisker fisker force-pushed the non-computed-enum-member branch from f60ffa6 to e45b631 Compare June 8, 2025 08:58
@fisker fisker marked this pull request as draft June 8, 2025 09:04
@fisker fisker changed the title feat(typescript-estree): forbid computed EnumMember feat(typescript-estree): forbid invalid keys in EnumMember Jun 8, 2025
@fisker fisker marked this pull request as ready for review June 8, 2025 09:15
Comment on lines +3211 to +3217
const computed = node.name.kind === ts.SyntaxKind.ComputedPropertyName;
if (computed) {
this.#throwUnlessAllowInvalidAST(
node.name,
'Computed property names are not allowed in enums.',
);
}
Copy link
Member

Choose a reason for hiding this comment

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

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250608#code/KYOwrgtgBAYg9nKBvAsAKClA2gcgII4C6UAvFAIzoC+6QA

It looks like computed members are still allowed in the nightly (which includes the fix for microsoft/TypeScript#61772)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

microsoft/TypeScript#61772 forbids bigint, may computed string literals not be forbidden? I'll ask.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +636 to +637
// Unknown reason, can't get the correct type
const id = node.id as TSESTree.Identifier | TSESTree.StringLiteral;
Copy link
Member

Choose a reason for hiding this comment

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

it might be due to nx not seeing the changes to ast-spec?

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party AST PRs and Issues about the AST structure labels Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AST PRs and Issues about the AST structure awaiting response Issues waiting for a reply from the OP or another party
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants