Skip to content
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

feat: support Auto Accessor syntax #5926

Merged
merged 22 commits into from Nov 28, 2022

Conversation

sosukesuzuki
Copy link
Contributor

PR Checklist

Overview

Based on #5716
Supports Auto Accessors.
ref: ESTree definition

@nx-cloud
Copy link

nx-cloud bot commented Nov 4, 2022

☁️ Nx Cloud Report

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

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @sosukesuzuki!

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 Nov 4, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit e510ce4
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6384072380ad6700083afd0e
😎 Deploy Preview https://deploy-preview-5926--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

# Conflicts:
#	package.json
#	patches/typescript+4.8.3.patch
#	patches/typescript+4.9.2-rc.patch
#	patches/typescript+4.9.3.patch
#	yarn.lock
@bradzacher
Copy link
Member

Clarifying ESTree naming consistency before we move forward on this - estree/estree#292

@bradzacher
Copy link
Member

Looks like babel doesn't support type annotations on auto-accessors: babel/babel#15205

@bradzacher
Copy link
Member

In 3c326c4 I added tooling to the ast-spec fixture tester which allows us to add config for specific fixtures.
This allows us to add a flag to certain fixtures explicitly expecting that babel should error due to it missing support. This lets us assert that some of the fixtures fail due to babel/babel#15205.

For context, changes I have made to this PR:

  1. merged main
  2. add TSAbstractAccessorProperty, which aligns with TSAbstractPropertyDefinition.
  3. add above testing tooling changes
  4. add ast-spec fixture tests for the feature.

This PR is waiting for a decision on naming alignment discussion with ESTree (estree/estree#292) AccessorProperty vs AccessorPropertyDefinition.
This PR is ready to go with the name AccessorProperty though.

@codecov
Copy link

codecov bot commented Nov 18, 2022

Codecov Report

Merging #5926 (e510ce4) into main (fe67b1e) will decrease coverage by 0.03%.
The diff coverage is 73.91%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5926      +/-   ##
==========================================
- Coverage   91.28%   91.24%   -0.04%     
==========================================
  Files         366      366              
  Lines       12363    12380      +17     
  Branches     3617     3621       +4     
==========================================
+ Hits        11285    11296      +11     
- Misses        768      774       +6     
  Partials      310      310              
Flag Coverage Δ
unittest 91.24% <73.91%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
packages/typescript-estree/src/convert.ts 97.13% <55.55%> (-0.50%) ⬇️
...kages/scope-manager/src/referencer/ClassVisitor.ts 92.74% <75.00%> (-1.43%) ⬇️
packages/visitor-keys/src/visitor-keys.ts 100.00% <100.00%> (ø)

@bradzacher
Copy link
Member

The AST is staying named as is, so no changes needed there.

Just need to add scope analysis support then this will be good to go.

@bradzacher bradzacher marked this pull request as ready for review November 28, 2022 00:56
* The value should be a description of why there isn't support - for example a github issue URL.
*/
readonly expectBabelToNotSupport?: string;
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

just noting - this is also ripe for #5932 & #6027

const type = (() => {
if (isAccessor) {
if (isAbstract) {
return AST_NODE_TYPES.TSAbstractAccessorProperty;
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused why codecov thinks this isn't covered by tests. I can debug it locally to see the TSAbstractAccessorProperty and AccessorProperty cases being hit. Though, sourcemaps seem to not be working - maybe that's the issue?

Screenshot of debugging in VS Code, on a breakpoint in the `const result` variable below. A watch view shows type to be 'TSAbstractAccessorProperty'.

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 because the tests are in ast-spec instead of in here?
maybe we need to adjust how the coverage is collected?

Copy link
Member

Choose a reason for hiding this comment

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

Filed #6116 🤷

Comment on lines +104 to +111
readonly // require keys for all nodes NOT defined in `eslint-visitor-keys`
[T in Exclude<
AST_NODE_TYPES,
KeysDefinedInESLintVisitorKeysCore
>]: readonly GetNodeTypeKeys<T>[];
} & {
readonly // optionally allow keys for all nodes defined in `eslint-visitor-keys`
[T in KeysDefinedInESLintVisitorKeysCore]?: readonly GetNodeTypeKeys<T>[];
Copy link
Member

Choose a reason for hiding this comment

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

oooooof i didn't see that prettier formatted like this
disgusting.

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.

I played around with this a bunch locally and it works great. Additional 🌟 for the testing infrastructure cleanups. This was also a great excuse for me to get more familiar with #6065 😄

🚢 !

@bradzacher bradzacher merged commit becd1f8 into typescript-eslint:main Nov 28, 2022
@sosukesuzuki sosukesuzuki deleted the auto-accesors branch November 28, 2022 07:07
@sosukesuzuki
Copy link
Contributor Author

Thank you!!

@StanislavKharchenko
Copy link

Hello!
When this feature will be available?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants