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(typescript-estree): warn on deprecated AST property accesses #6525

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Feb 24, 2023

PR Checklist

Overview

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. 🧹

@nx-cloud
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.

@typescript-eslint
Copy link
Contributor

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 https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Feb 24, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 9a8066f
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/640eb9e61eef190008144572
😎 Deploy Preview https://deploy-preview-6525--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.

@codecov
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% <ø> (ø)
...pt-estree/src/parseSettings/createParseSettings.ts 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
Member

@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

@JoshuaKGoldberg
Copy link
Member Author

only log during testing scenarios

Right now that's the default:

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

@bradzacher
Copy link
Member

@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
39 of 41 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the warn-on-deprecated-ast-property branch March 13, 2023 14:19
@fisker
Copy link
Contributor

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

@fisker
Copy link
Contributor

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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants