-
Notifications
You must be signed in to change notification settings - Fork 12
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
Replace ember-template-imports with content-tag #153
Merged
+60
−38
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replace ember-template-imports with content-tag
commit dcfb56f4e9b5c1eb9fa0a774e61c27c81a74e5cf
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
// @ts-expect-error FIXME: TS7016 Get ETI to export these + types | ||
import * as util from 'ember-template-imports/src/util.js'; | ||
|
||
export const PARSER_NAME = 'ember-template-tag'; | ||
export const PRINTER_NAME = 'ember-template-tag-estree'; | ||
|
||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
export const TEMPLATE_TAG_NAME = util.TEMPLATE_TAG_NAME as string; | ||
export const TEMPLATE_TAG_PLACEHOLDER = util.TEMPLATE_TAG_PLACEHOLDER as string; | ||
/* eslint-enable @typescript-eslint/no-unsafe-member-access */ | ||
// FIXME: Are these still accurate? | ||
export const TEMPLATE_TAG_NAME = 'template'; | ||
export const TEMPLATE_TAG_PLACEHOLDER = '__GLIMMER_TEMPLATE'; | ||
|
||
export const TEMPLATE_TAG_OPEN = `<${TEMPLATE_TAG_NAME}>`; | ||
export const TEMPLATE_TAG_CLOSE = `</${TEMPLATE_TAG_NAME}>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { getTemplateLocals } from '@glimmer/syntax'; | ||
import { Preprocessor } from 'content-tag'; | ||
import { preprocessEmbeddedTemplates } from 'ember-template-imports/lib/preprocess-embedded-templates.js'; | ||
import { | ||
TEMPLATE_TAG_NAME, | ||
TEMPLATE_TAG_PLACEHOLDER, | ||
} from 'ember-template-imports/lib/util.js'; | ||
// FIXME: Do we need this? | ||
// import { | ||
// TEMPLATE_TAG_NAME, | ||
// TEMPLATE_TAG_PLACEHOLDER, | ||
// } from 'ember-template-imports/lib/util.js'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import { AMBIGUOUS_PLACEHOLDER } from '../helpers/ambiguous.js'; | ||
|
@@ -13,11 +15,41 @@ import { format } from '../helpers/format.js'; | |
import type { Config } from '../helpers/make-suite.js'; | ||
import { makeSuite } from '../helpers/make-suite.js'; | ||
|
||
// FIXME: Are these still accurate? | ||
export const TEMPLATE_TAG_NAME = 'template'; | ||
export const TEMPLATE_TAG_PLACEHOLDER = '__GLIMMER_TEMPLATE'; | ||
|
||
const p = new Preprocessor(); | ||
|
||
describe('format', () => { | ||
makeSuite(getAllCases, preprocessedTest)({ name: 'with preprocessed code' }); | ||
|
||
/* | ||
FIXME: We might not be able to maintain compatibility with | ||
ember-template-imports preprocessed code, which would mean we'd have to | ||
drop support for it altogether (and remove the set of tests below). | ||
|
||
This would cause compat issues with eslint-plugin-ember until they are using | ||
content-tag. Additionally, if they start using content-tag, running prettier | ||
via eslint-plugin-ember won't be possible until _this_ library supports | ||
content-tag. | ||
*/ | ||
makeSuite( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FIXME: It turns out we won't need this compat, so can remove these tests. |
||
getAllCases, | ||
preprocessedTestLegacy, | ||
)({ name: 'with legacy ember-template-imports preprocessed code' }); | ||
}); | ||
|
||
function preprocessedTest(config: Config, testCase: TestCase): void { | ||
test(`it formats ${testCase.name}`, async () => { | ||
const code = testCase.code.replaceAll(AMBIGUOUS_PLACEHOLDER, ''); | ||
const preprocessed = p.process(code); | ||
const result = await format(preprocessed, config.options); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
} | ||
|
||
function preprocessedTestLegacy(config: Config, testCase: TestCase): void { | ||
test(`it formats ${testCase.name}`, async () => { | ||
const code = testCase.code.replaceAll(AMBIGUOUS_PLACEHOLDER, ''); | ||
const preprocessed = preprocessEmbeddedTemplates(code, { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXME: Can remove this bc we won't need to maintain compat.