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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typescript-estree): warn on deprecated AST property accesses #6525


Copy link

@JoshuaKGoldberg JoshuaKGoldberg commented Feb 24, 2023

PR Checklist


Follows up on #5384 by wrapping the @deprecated properties with a getter that, when a new suppressDeprecatedPropertyWarnings option isn't enabled, console.warns about the properties.

suppressDeprecatedPropertyWarnings defaults to process.env.NODE_ENV !== "test" (false in Jest and similar). Meaning, it'll only log in tests by default.

This also has the benefit of making the new property not enumerable, which cleans up the AST snapshots and playground representation of the AST to not have the seemingly duplicate properties. 馃Ч

Copy link

nx-cloud bot commented Feb 24, 2023

鈽侊笍 Nx Cloud Report

CI is running/has finished running commands for commit 9a8066f. 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 51 targets

Sent with 馃拰 from NxCloud.

Copy link

Thanks for the PR, @JoshuaKGoldberg!

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

Copy link

netlify bot commented Feb 24, 2023

Deploy Preview for typescript-eslint ready!

Name Link
馃敤 Latest commit 9a8066f
馃攳 Latest deploy log
馃槑 Deploy Preview
馃摫 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.

Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #6525 (9a8066f) into v6 (f0f45a9) will increase coverage by 0.01%.
The diff coverage is 46.15%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v6    #6525      +/-   ##
+ Coverage   87.40%   87.42%   +0.01%     
  Files         365      365              
  Lines       12508    12517       +9     
  Branches     3694     3696       +2     
+ Hits        10933    10943      +10     
+ Misses       1213     1212       -1     
  Partials      362      362              
Flag Coverage 螖
unittest 87.42% <46.15%> (+0.01%) 猬嗭笍

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

Impacted Files Coverage 螖
packages/typescript-estree/src/ast-converter.ts 100.00% <酶> (酶) 85.71% <0.00%> (-1.79%) 猬囷笍
packages/typescript-estree/src/convert.ts 31.76% <47.36%> (+1.23%) 猬嗭笍

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review February 24, 2023 02:40
@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0 milestone Feb 25, 2023
Copy link

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

this is looking good to me! should be really helpful to help people migrate.

I wonder if we should only log during testing scenarios..? It might spam users otherwise. Hmmm

Copy link
Member Author

only log during testing scenarios

Right now that's the default:

options.suppressDeprecatedPropertyWarnings ??
process.env.NODE_ENV !== 'test',

Copy link

@JoshuaKGoldberg rebase this on v6 and fix the build and you're good to land!

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Mar 13, 2023
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Mar 13, 2023
@bradzacher bradzacher changed the title feat: warn on deprecated AST property accesses feat(typescript-estree): warn on deprecated AST property accesses Mar 13, 2023
@bradzacher bradzacher merged commit 79c058d into typescript-eslint:v6 Mar 13, 2023
41 of 43 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the warn-on-deprecated-ast-property branch March 13, 2023 14:19
Copy link

fisker commented Mar 17, 2023

@JoshuaKGoldberg This change breaks Prettier, we do an AST transform after parse, which will override some of those properties. I decide not to use the new properties because babel still use those old properties, I was thinking to update print logic after babel adopt those changes. Do you think maybe we can add a setter? CI Log

Copy link

fisker commented Mar 17, 2023

Or maybe when suppressDeprecatedPropertyWarnings: false, not to use Object.defineProperty?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants