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: add babel parser and traverse and migrate some rules #448

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

David-Pena
Copy link
Collaborator

Summary

Adds babel parser and traverse packages for AST parsing for some rules.

Description

  • rule functionSize refactored with babel
  • rule parameterCount refactored with babel
  • rule computedSideEffects refactored with babel
  • Extract some reusable blocks to /helpers

Related Issues

Supports #368
Fixes #365 #364 #431

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Screenshots (if applicable)

N/A

@David-Pena David-Pena added the enhancement New feature or request label Nov 4, 2024
@David-Pena David-Pena requested a review from rrd108 November 4, 2024 09:55
@David-Pena David-Pena self-assigned this Nov 4, 2024
Copy link

github-actions bot commented Nov 4, 2024

logo Vue Mess Detector Analysis Results

PR Code Health Full Code Health

🚨 New Errors: 3
⚠️ New Warnings: 4
✅ Fixed Errors: 0
🔧 Fixed Warnings: 0
📝 Total Lines: 227
📁 Total Files: 2

New Issues

- src/rules/rrd/repeatedCss.ts:
  rrd ~ else conditions: else clauses found (1) 🚨
  rrd ~ function size: function (checkRepeatedCss#14) is too long: 32 lines 🚨
  rrd ~ magic numbers: magic numbers found (line #53 magic number: 3) 🚨
- src/rules/rrd/repeatedCss.test.ts:
  rrd ~ Long <script> blocks: (152 lines) 🚨

🔍 Download Full Analysis Details

For any issues or feedback, feel free to report them here.

Copy link

pkg-pr-new bot commented Nov 4, 2024

Open in Stackblitz

npm i https://pkg.pr.new/rrd108/vue-mess-detector@448

commit: cc38221

@David-Pena
Copy link
Collaborator Author

not ready to merge, there is a weird bug when running the cli tests
image

@David-Pena
Copy link
Collaborator Author

not ready to merge, there is a weird bug when running the cli tests
image

It seems to be something with the traverse logic because if functionSize, parameterCount and computedSideEffects rules are commented, the error dissapears.

There is a file inside the project which is causing that error when walking through it... I'm still debugging 👀

@rrd108
Copy link
Owner

rrd108 commented Nov 23, 2024

@David-Pena there are too many conflicts to fix manually. Can you just delete and regenrate the lock file?

@David-Pena
Copy link
Collaborator Author

David-Pena commented Nov 23, 2024

Oh no worries, I will. I'll be sitting in front of this issue this weekend🫡

@rrd108
Copy link
Owner

rrd108 commented Dec 27, 2024

@David-Pena can you check the failing tests and update yarn.lock?

@David-Pena
Copy link
Collaborator Author

I'm back 👨🏼‍💻

Copy link

logo Vue Mess Detector Analysis Results

PR Code Health Full Code Health

🚨 New Errors: 0
⚠️ New Warnings: 0
✅ Fixed Errors: 0
🔧 Fixed Warnings: 0
📝 Total Lines: 0
📁 Total Files: 0

🔍 Download Full Analysis Details

For any issues or feedback, feel free to report them here.

@rrd108
Copy link
Owner

rrd108 commented Dec 30, 2024

did the tests passed on your end?

@David-Pena
Copy link
Collaborator Author

did the tests passed on your end?

Still debugging...

I'm getting an error traverse is not a function but I'm pretty sure I'm importing it correctly, so I doing a bit of research

@rrd108
Copy link
Owner

rrd108 commented Dec 30, 2024

Ah ok. I thought it is ready to merge and then I saw the failing tests.

No worries, take your time.

It is ok if it is ready only next year.

@David-Pena
Copy link
Collaborator Author

David-Pena commented Jan 3, 2025

The weird thing is that the specific tests for each of the changed rules pass! and the traverse logic is working because its logging something I just add
image
image

But when I run this test
image

The output says this: traverse is not a function
image

I'm not sure if its because the runCLI function runs the npx command and as the released version does not have the new package @babel/parser or smth like that... @rrd108 what do you think?

@rrd108
Copy link
Owner

rrd108 commented Jan 3, 2025

Try to run build and then run the test

@David-Pena
Copy link
Collaborator Author

Try to run build and then run the test

Done it already and the same... would you mind moving to my branch and try to build then run the tests?

I shouldnt need to use another parser I think... (but I'm kind of stuck)

@David-Pena David-Pena mentioned this pull request Jan 3, 2025
@rrd108
Copy link
Owner

rrd108 commented Jan 4, 2025

I am confused...

I switched to this branch, yarn install yarn build and I get compeltely different error messages for the test.

I confirm the computedSideEffect test is passing by its own.

But here is the output for me running the tests
test output

And here is the output running analyze
analyze output

@rrd108 rrd108 marked this pull request as draft January 4, 2025 09:52
@David-Pena
Copy link
Collaborator Author

Oh for the screenshot I showed you I commented the parameterCount and functionSize rule in ruleCheck/ruleReport and the array of rules because my plan was to debug first one of the changed rules computedSideEffects.

And I printed the entire response, not only the stdout, I think that way I found the traverse is not a function error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parameter Count seems failed in destructuring object parameters
2 participants