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

[gjs-gts-parser] fix parsing when there are multiple default <template> blocks (not allowed) #2005

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

patricklx
Copy link
Contributor

@patricklx patricklx commented Nov 15, 2023

I encountered this while working on implementing content-tag for prettier plugin, which has tests for multiple default templates.
It would fail to parse the file in that case.

Before i would have converted the template parts to template string literals.

`
Tpl1
`
`
Tpl2
`

But that makes it one tagged template literal... Instead of 2 separates.
Now i make them tagged already.

""
`
Tpl1
`
""
`
Tpl2
`

I use string as tag name, as otherwise eslint would complain about missing references to identifiers

@bmish
Copy link
Member

bmish commented Nov 21, 2023

Can you provide some context about this in the PR description?

@@ -91,6 +91,10 @@ const valid = [
<template>
<div {{on 'click' noop}} />
</template>

<template>
<div {{on 'click' noop}} />
Copy link
Contributor

Choose a reason for hiding this comment

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

@bmish this is the bad code -- can't have two default templates

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bmish it would have failed to parse it without this change

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 provide some context about the actual fix too? What was wrong before and how does your change fix it?

Copy link
Contributor Author

@patricklx patricklx Nov 26, 2023

Choose a reason for hiding this comment

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

Before i would have converted the template parts to template string literals.

`
Tpl1
`
`
Tpl2
`

But that makes it one tagged template literal... Instead of 2 separates.
Now i make them tagged already.

""
`
Tpl1
`
""
`
Tpl2
`

I use string as tag name, as otherwise eslint would complain about missing references to identifiers

@NullVoxPopuli NullVoxPopuli changed the title [gjs-gts-parser] fix when bad templates [gjs-gts-parser] fix behavior when there are multiple default <template> blocks (not allowed) Nov 21, 2023
@patricklx patricklx changed the title [gjs-gts-parser] fix behavior when there are multiple default <template> blocks (not allowed) [gjs-gts-parser] fix parsing when there are multiple default <template> blocks (not allowed) Nov 25, 2023
@bmish bmish merged commit a08f0ab into ember-cli:master Nov 30, 2023
8 checks passed
@patricklx patricklx deleted the fix-bad-templates branch November 30, 2023 23:19
bmish added a commit to bmish/eslint-plugin-ember that referenced this pull request Dec 12, 2023
* master: (46 commits)
  fix gts type aware by emulating them to ts files set our own ts.sys with ts.setSys typescript-eslint has handling for a lot of scenarios for file changes and project changes etc use mts extension to keep same offsets we also sync the mts with the gts files
  Switch to ESLint flat config internally (ember-cli#2018)
  [gjs-gts-parser] fix parsing when there are multiple default <template> blocks (not allowed) (ember-cli#2005)
  Release 12.0.0-alpha.2
  fix locations after template
  reference tag name parts (split up with dot) instead of whole tag
  add failing test
  Release 12.0.0-alpha.1
  docs: recommended-gts/gjs instead of gts/gjs-recommended
  add rule to gjs & gts
  build(deps-dev): Bump eslint from 8.52.0 to 8.53.0
  build(deps-dev): Bump npm-package-json-lint from 7.0.0 to 7.1.0
  build(deps-dev): Bump eslint-doc-generator from 1.5.3 to 1.5.4
  Update `@typescript-eslint/` dependencies to v6 (ember-cli#1984)
  Fix missing gjs/cts config icons (ember-cli#1982)
  improve gts gjs configuration example
  Release 12.0.0-alpha.0
  Switch to `@release-it-plugins/lerna-changelog` (ember-cli#1979)
  Set config `ecmaVersion` to `2022` (ember-cli#1978)
  Add new `recommended` rule: `template-no-let-reference` (ember-cli#1977)
  ...
@bmish bmish changed the title [gjs-gts-parser] fix parsing when there are multiple default <template> blocks (not allowed) [gjs-gts-parser] fix parsing when there are multiple default <template> blocks (not allowed) Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants