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 runes #425

Merged
merged 27 commits into from Nov 17, 2023
Merged

feat: Support runes #425

merged 27 commits into from Nov 17, 2023

Conversation

baseballyama
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Nov 14, 2023

🦋 Changeset detected

Latest commit: 0a61e91

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte-eslint-parser Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link

coveralls commented Nov 14, 2023

Pull Request Test Coverage Report for Build 6898873227

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 39 of 43 (90.7%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 91.045%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser/typescript/analyze/index.ts 33 37 89.19%
Totals Coverage Status
Change from base Build 6863793483: 0.07%
Covered Lines: 2276
Relevant Lines: 2415

💛 - Coveralls

@baseballyama
Copy link
Member Author

I could not figure out how to test this because the globals are different for Svelte4 and Svelte5. Once I created the expected files for Svelte5, but there are too many additional lines. Any suggestions?

@ota-meshi
Copy link
Member

Wow! I noticed this PR after opening #426. This PR seems to be a little more advanced than #426 as type information for runes is added.

I could not figure out how to test this because the globals are different for Svelte4 and Svelte5. Once I created the expected files for Svelte5, but there are too many additional lines. Any suggestions?

In #426, the idea is to explicitly opt in to runes mode using an option to make it work.
https://github.com/sveltejs/svelte-eslint-parser/blob/runes-vars/README.md#parseroptionssveltefeaturesrunes

@baseballyama
Copy link
Member Author

In #426, the idea is to explicitly opt in to runes mode using an option to make it work.

From the user's point of view, using Svelte5 = being able to use runes, so if there is a way to not force users to configure it, that would be good.

About test, how about to extract variables part and prepare only this part for Svelte4 and Svelte5 separately.
Then we can prevent to make duplicated expected files.

https://github.com/sveltejs/svelte-eslint-parser/pull/425/files#diff-8907e5126cad5dd0dd35d0025fdd3086e01a29d3cb72fd9bb5f37b6352ba9048R3-R52

One question, my understanding is that the Svelte compiler is not bundled with svelte-eslint-parser so it always uses the version installed by the user, correct?

@baseballyama
Copy link
Member Author

baseballyama commented Nov 15, 2023

I think my todo is there.

  • Reduce duplicated expected files
  • Add tests for runes types
  • Handle $derived (I need to understand about this issue at first)

@baseballyama
Copy link
Member Author

Oh but your PR supports .svelte.js files.
So somehow we need to combine these PRs.

@ota-meshi
Copy link
Member

One question, my understanding is that the Svelte compiler is not bundled with svelte-eslint-parser so it always uses the version installed by the user, correct?

Yeah, we specifying svelte in peerDependencies and peerDependenciesMeta, so I expect the user to be able to use whatever version they want to use.

@baseballyama
Copy link
Member Author

What do you think is the best way to do Next Action?

  • My opinion is that runes should not be configurable and should be reconize automatically by the parser, but since you are more professional in this field than me, please make a decision.
  • As for testing, it is possible to eliminate duplicates and I can handle that.
  • Regarding support for the .svelte.js file, would it be better to merge your PR after this PR is merged? Or we can collaborate on this branch and put them together as one PR, but I have no opinion here.

@ota-meshi
Copy link
Member

My opinion is that runes should not be configurable and should be reconize automatically by the parser, but since you are more professional in this field than me, please make a decision.

I think we can consider what our options are after Svelte v5 is released. I believe we can remove options or even change the defaults for options.
However, it currently needs to be marked as an experimental feature, so I think it makes sense to provide it as an option for now.

would it be better to merge your PR after this PR is merged?

Yeah, I would like to change and merge #426 after this PR is merged.

@ota-meshi
Copy link
Member

However, it currently needs to be marked as an experimental feature, so I think it makes sense to provide it as an option for now.

Oh, I think it's a good idea to judge by svelte version rather than using options. Installing svelte v5 means the user is explicitly using pre-release.

https://github.com/sveltejs/svelte-eslint-parser/pull/425/files#diff-cc6f76d59c9667a8e87dc3efb2b017199c77faed21c60201fc2633a0725c8217R15

"$state",
"$derived",
"$effect",
"$effect.pre",
Copy link
Member

Choose a reason for hiding this comment

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

Since $effect.pre is a member of $effect, I don't think it is necessary to define it here.

Suggested change
"$effect.pre",

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

@baseballyama
Copy link
Member Author

Tomorrow I will add more tests for runes.

@baseballyama baseballyama marked this pull request as ready for review November 16, 2023 15:00
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

It looks mostly good, but I did make one comment 😃

Comment on lines 224 to 228
if (
scopeManager.globalScope!.through.some(
(reference) => reference.identifier.name === svelte5Global,
)
) {
Copy link
Member

Choose a reason for hiding this comment

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

By moving this judgment before the switch, I think we can eliminate the four same implementations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohhhhh...
0a61e91

@ota-meshi ota-meshi mentioned this pull request Nov 17, 2023
16 tasks
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

LGTM!

@ota-meshi ota-meshi merged commit ff242c4 into main Nov 17, 2023
14 checks passed
@ota-meshi ota-meshi deleted the support-runes branch November 17, 2023 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants