Skip to content

Commit 755af73

Browse files
authored
Merge pull request #211 from gitKrystan/upgrade-content-tag
2 parents cfe3d7e + e045879 commit 755af73

File tree

5 files changed

+12
-50
lines changed

5 files changed

+12
-50
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
},
5252
"dependencies": {
5353
"@babel/core": "^7.23.6",
54+
"content-tag": "^1.2.2",
5455
"prettier": "^3.1.1"
5556
},
5657
"devDependencies": {
@@ -65,7 +66,6 @@
6566
"@typescript-eslint/parser": "^6.16.0",
6667
"@vitest/ui": "^1.1.0",
6768
"concurrently": "^8.2.2",
68-
"content-tag": "^1.1.2",
6969
"eslint": "^8.56.0",
7070
"eslint-config-prettier": "^9.1.0",
7171
"eslint-plugin-eslint-comments": "^3.2.0",

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parse/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import type {
66
ObjectExpression,
77
StaticBlock,
88
} from '@babel/types';
9+
import type { Parsed as RawGlimmerTemplate } from 'content-tag';
910
import { Preprocessor } from 'content-tag';
1011
import type { Parser } from 'prettier';
1112
import { parsers as babelParsers } from 'prettier/plugins/babel.js';
1213

1314
import { PRINTER_NAME } from '../config.js';
1415
import type { Options } from '../options.js';
15-
import type { GlimmerTemplate, RawGlimmerTemplate } from '../types/glimmer.js';
16+
import type { GlimmerTemplate } from '../types/glimmer.js';
1617
import { isDefaultTemplate } from '../types/glimmer.js';
1718
import { assert } from '../utils/index.js';
1819
import { preprocessTemplateRange } from './preprocess.js';
@@ -88,7 +89,7 @@ function preprocess(code: string): {
8889
code: string;
8990
rawTemplates: RawGlimmerTemplate[];
9091
} {
91-
const rawTemplates = p.parse(code) as RawGlimmerTemplate[];
92+
const rawTemplates = p.parse(code);
9293

9394
let output = code;
9495
for (const rawTemplate of rawTemplates) {

src/parse/preprocess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { RawGlimmerTemplate } from '../types/glimmer.js';
1+
import type { Parsed as RawGlimmerTemplate } from 'content-tag';
22

33
function replaceRange(
44
original: string,

src/types/glimmer.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,6 @@
11
import type { NodePath } from '@babel/core';
22
import type { Node } from '@babel/types';
3-
4-
/** The raw GlimmerTemplate node as parsed by the content-tag parser. */
5-
export interface RawGlimmerTemplate {
6-
type: 'expression' | 'class-member';
7-
8-
tagName: 'template';
9-
10-
/** Raw template contents */
11-
contents: string;
12-
13-
/**
14-
* Range of the contents, inclusive of inclusive of the
15-
* `<template></template>` tags.
16-
*/
17-
range: {
18-
start: number;
19-
end: number;
20-
};
21-
22-
/**
23-
* Range of the template contents, not inclusive of the
24-
* `<template></template>` tags.
25-
*/
26-
contentRange: {
27-
start: number;
28-
end: number;
29-
};
30-
31-
/** Range of the opening `<template>` tag. */
32-
startRange: {
33-
end: number;
34-
start: number;
35-
};
36-
37-
/** Range of the closing `</template>` tag. */
38-
endRange: {
39-
start: number;
40-
end: number;
41-
};
42-
}
3+
import type { Parsed as RawGlimmerTemplate } from 'content-tag';
434

445
export interface GlimmerTemplate {
456
type: 'FunctionDeclaration';

0 commit comments

Comments
 (0)