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

fix: parsing error for nesting {#snippet} #540

Merged
merged 2 commits into from
Jun 23, 2024
Merged

fix: parsing error for nesting {#snippet} #540

merged 2 commits into from
Jun 23, 2024

Conversation

ota-meshi
Copy link
Member

fixes #522

Copy link

changeset-bot bot commented Jun 18, 2024

🦋 Changeset detected

Latest commit: 4e8b170

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 Patch

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 Jun 18, 2024

Pull Request Test Coverage Report for Build 9559791113

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.009%) to 90.373%

Totals Coverage Status
Change from base Build 9549359097: 0.009%
Covered Lines: 2997
Relevant Lines: 3205

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9559807428

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.009%) to 90.373%

Totals Coverage Status
Change from base Build 9549359097: 0.009%
Covered Lines: 2997
Relevant Lines: 3205

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9560319146

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.009%) to 90.373%

Totals Coverage Status
Change from base Build 9560317447: 0.009%
Covered Lines: 2997
Relevant Lines: 3205

💛 - Coveralls

@ota-meshi ota-meshi requested a review from baseballyama June 19, 2024 06:30
@Caleb-T-Owens
Copy link

Hey! Within my project I've managed to get three different parser errors which seem to have the root cause lying in the usage of snippets https://github.com/gitbutlerapp/gitbutler/actions/runs/9582690351/job/26422242794?pr=4109.

I was wondering if this was related & fixed by this PR, or whether I should make a separate issue.

In my case, it doesn't seem to be a problem when when have a snippet passed directly as a prop, but it causes parser errors whenever I define a snippet at the top level and then consume it elsewhere within the same svelte file.

IE:

<div class="commit-list-item">
	<div class="commit-card-wrapper">
		{@render moveCommitDropzone()}
	</div>
</div>

{#snippet moveCommitDropzone()}
	<Dropzone
		accepts={actions.acceptMoveCommit.bind(actions)}
		ondrop={actions.onMoveCommit.bind(actions)}
		fillHeight
	>
		{@render branchDropDropzone()}

		{#snippet overlay({ hovered, activated })}
			<CardOverlay {hovered} {activated} label="Move here" />
		{/snippet}
	</Dropzone>
{/snippet}

{#snippet branchDropDropzone()}
	<Dropzone
		accepts={actions.acceptBranchDrop.bind(actions)}
		ondrop={actions.onBranchDrop.bind(actions)}
		fillHeight
	>
		{@render children()}

		{#snippet overlay({ hovered, activated })}
			<CardOverlay {hovered} {activated} label="Move here" />
		{/snippet}
	</Dropzone>
{/snippet}
/home/runner/work/gitbutler/gitbutler/app/src/lib/components/BranchCard/Dropzones.svelte
  0:0  error  Parsing error: Cannot read properties of undefined (reading 'type')

/home/runner/work/gitbutler/gitbutler/app/src/lib/components/CommitDragItem.svelte
  0:0  error  Parsing error: Cannot set properties of undefined (setting 'parent')

/home/runner/work/gitbutler/gitbutler/app/src/lib/components/CommitList.svelte
  0:0  error  Parsing error: Cannot read properties of undefined (reading 'typeAnnotation')

@Caleb-T-Owens
Copy link

I've actually ended up building the branch locally, and can confirm that this PR does fix my snippet related errors too!!! Thanks for your hard work

Caleb-T-Owens added a commit to gitbutlerapp/gitbutler that referenced this pull request Jun 21, 2024
I'm making use of a self-build version of svelte-eslint-parser which contains a fix for nested snippet definitions. https://github.com/gitbutlerapp/svelte-eslint-parser

When sveltejs/svelte-eslint-parser#540 is released we can revert back to the standard track
Copy link
Member

@baseballyama baseballyama left a comment

Choose a reason for hiding this comment

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

Thank you!

@baseballyama baseballyama merged commit 48a7001 into main Jun 23, 2024
13 checks passed
@baseballyama baseballyama deleted the nest-snippet branch June 23, 2024 17:34
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.

Nested snippets cause parsing error
4 participants