Skip to content

fix(ast-spec): use Expression in argument of ThrowStatement #9632

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

Conversation

dak2
Copy link
Contributor

@dak2 dak2 commented Jul 24, 2024

PR Checklist

Overview

  • Use Expression in argument of ThrowStatement
  • Remove statement and null type from ThrowStatement

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @dak2!

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 Jul 24, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 1567418
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66cb1e7a50358f00088821fe
😎 Deploy Preview https://deploy-preview-9632--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 (no change 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 Jul 24, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1567418. 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.

@dak2 dak2 changed the title feat(ast-spec): remove statement and null type from ThrowStatement fix(ast-spec): remove statement and null type from ThrowStatement Jul 24, 2024
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 isn't correct! The type of argument should just be Expression as per the title of the issue.

@dak2 dak2 changed the title fix(ast-spec): remove statement and null type from ThrowStatement fix(ast-spec): use Expression in argument of ThrowStatement Jul 24, 2024
@dak2
Copy link
Contributor Author

dak2 commented Jul 24, 2024

@bradzacher

Thanks! Looks like I was mistaken, I fixed it to use Expression.

@dak2 dak2 requested a review from bradzacher July 24, 2024 14:56
@dak2
Copy link
Contributor Author

dak2 commented Jul 25, 2024

I don't know why CI failed. Perhaps there is an error when running yarn, but I can't reproduce it locally.

@Josh-Cena
Copy link
Member

Josh-Cena commented Jul 25, 2024

Here's the relevant log in CI (I believe):

  ➤ YN0000: │ @typescript-eslint/typescript-eslint@workspace:. STDOUT > nx run eslint-plugin:build
  Error: ➤ YN0000: │ @typescript-eslint/typescript-eslint@workspace:. STDOUT src/rules/no-throw-literal.ts(93,28): error TS2345: Argument of type 'TSAsExpression | Statement | null' is not assignable to parameter of type 'Node'.
  ➤ YN0000: │ @typescript-eslint/typescript-eslint@workspace:. STDOUT   Type 'null' is not assignable to type 'Node'.
  Error: ➤ YN0000: │ @typescript-eslint/typescript-eslint@workspace:. STDOUT src/rules/only-throw-error.ts(92,28): error TS2345: Argument of type 'TSAsExpression | Statement | null' is not assignable to parameter of type 'Node'.

bradzacher
bradzacher previously approved these changes Jul 25, 2024
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.

Brilliant - thanks for this!
Once we fix the build errors we're good to land this

@bradzacher
Copy link
Member

cc @JamesHenry - I think that NX is improperly caching the build here.
The AST spec has changed so that the property is just argument: Expression, yet the compilation step from ast-spec src to types/src/generated/ast-spec.ts is reusing the old output.

@bradzacher bradzacher added bug Something isn't working 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labels Jul 25, 2024
@dak2
Copy link
Contributor Author

dak2 commented Jul 25, 2024

@bradzacher @Josh-Cena
Thanks for your help!
I think rebuild without cache before run yarn install --immutable --inline-builds in GitHub Actions.
Any concerns about this approach? Or is there another effective way?

@dak2
Copy link
Contributor Author

dak2 commented Jul 25, 2024

I've tried deleting cache, tried prebuild, but it doesn't seem to work.

@Josh-Cena
Copy link
Member

@dak2 You don't need to worry about CI failures. As long as your code is valid, the burden of fixing the CI is on the team.

Comment on lines 58 to 62
- name: Check if ast-spec files changed
id: changed-files
uses: tj-actions/changed-files@v41
with:
files: packages/ast-spec/src/**
Copy link
Member

Choose a reason for hiding this comment

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

Can you revert this or move this to a separate PR/issue if it's necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Josh-Cena

You don't need to worry about CI failures. As long as your code is valid, the burden of fixing the CI is on the team.

Thanks!!

Can you revert this or move this to a separate PR/issue if it's necessary?

Undo file changes in github actions.

a899544

Copy link

codecov bot commented Aug 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.03%. Comparing base (90cebbb) to head (1567418).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9632      +/-   ##
==========================================
- Coverage   88.03%   88.03%   -0.01%     
==========================================
  Files         407      407              
  Lines       13942    13941       -1     
  Branches     4072     4071       -1     
==========================================
- Hits        12274    12273       -1     
  Misses       1355     1355              
  Partials      313      313              
Flag Coverage Δ
unittest 88.03% <100.00%> (-0.01%) ⬇️

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

Files Coverage Δ
...ckages/eslint-plugin/src/rules/only-throw-error.ts 100.00% <100.00%> (ø)

@dak2 dak2 requested a review from Josh-Cena August 11, 2024 05:40
@bradzacher bradzacher requested a review from JamesHenry August 11, 2024 07:06
@JamesHenry
Copy link
Member

@bradzacher Sorry I missed your comment here, let's double check and make sure we have the cache inputs set up correctly for this case

@JoshuaKGoldberg JoshuaKGoldberg removed the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Aug 12, 2024
@JamesHenry
Copy link
Member

JamesHenry commented Aug 25, 2024

The reason for the failure was that we were telling nx to exclude test files from build cache inputs. spec.ts is a super common naming convention for test files and so that's why it was included in the pattern, but our more unique "ast spec" convention was therefore caught in the crossfire and changes to ast spec.ts files were appropriately (based on our config) not causing the build cache to be invalidated.

In our repo we are actually consistent with our usage of test.ts for test files, so the solution here is to stop classing spec.ts as test files in the build inputs (and I did some minor consistency cleanup for old references to spec in the test context)

@JamesHenry JamesHenry merged commit 9f70ed1 into typescript-eslint:main Aug 25, 2024
59 checks passed
@JamesHenry
Copy link
Member

Thanks again @dak2!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2024
@dak2 dak2 deleted the throw-statement-arg-should-be-expression branch December 26, 2024 07:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: ThrowStatement's argument should be Expression
5 participants